System.ObservableExtensions.Subscribe: ambiguous reference - c#

CrossBleAdapter.Current.WhenStatusChanged().Subscribe(obj => { });
I'm getting the following error for the subscribe method
/Users/sarath/Developer/Workspace/GCH Mobile
App/Gogch.iOS/TMAirController.cs(57,57): Error CS0121: The call is
ambiguous between the following methods or properties:
'System.ObservableExtensions.Subscribe(System.IObservable,
System.Action)' and
'System.ObservableExtensions.Subscribe(System.IObservable,
System.Action)' (CS0121) (_SmartFHR.iOS)
How can I resolve this?
Edit
Upon further investigation I found that ObservableExtensions exists both System.Reactive.Core and System.Reactive. I can't remove either because other packages depend on it.
Update
Thank you for pointing me in the right direction.
I found the problem. I was using System.Reactive version 4.0.0 and System.Core.Reactive version 3.0.0. Once I changed core version to 4.0.0, problem solved.

Related

Azure.Mobile in app and AppCenter in framework triggers a "Cannot register two managed types"

I've been having conflicts with Microsoft.Azure.Mobile and Microsoft.AppCenter in a Xamarin iOS project.
I'm creating a framework that will be released as a nuget, in that framework I reference AppCenter. The app where I'm testing my nuget has a reference to Microsoft.Azure.Mobile, which references the same Microsoft.AppCenter nuget triggering the following error:
Project/iOS/MTOUCH: Error MT4116: Could not register the assembly 'Microsoft.Azure.Mobile.iOS.Bindings': error MT4118: Cannot register two managed types ('Microsoft.Azure.Mobile.iOS.Bindings.MSCustomProperties, Microsoft.Azure.Mobile.iOS.Bindings' and 'Microsoft.AppCenter.iOS.Bindings.MSCustomProperties, Microsoft.AppCenter.iOS.Bindings') with the same native name ('MSCustomProperties'). (MT4116)(Project.iOS)
I tried the following solutions with no success:
1: https://forums.xamarin.com/discussion/comment/54126/#Comment_54126
2: https://github.com/xamarin/xamarin-macios/issues/4721
Would love some help :)
The problem was that the Microsoft.Azure.Mobile it's an old package no longer being supported and is using the AppCenter services, I removed that package and just added the most recent package from AppCenter which uses the same services.

Resolve CS0121 in System.Web.Http

This code:
Request.CreateResponse(HttpStatusCode.PartialContent);
Yields following compilation error:
Error CS0121 The call is ambiguous between the following methods or
properties:
'System.Net.Http.HttpRequestMessageExtensions.CreateResponse(System.Net.Http.HttpRequestMessage,
System.Net.HttpStatusCode)' and
'System.Web.Http.HttpRequestMessageCommonExtensions.CreateResponse(System.Net.Http.HttpRequestMessage,
System.Net.HttpStatusCode)'
Both are in System.Net.Http namespace, one in System.Web.Http assembly the other in System.Net.Http.Formatting but I need them both as a reference. Even worse System.Net.Http.HttpRequestMessageExtensions class is present in both assemblies.
As a workaround, I could use this overload, which seems to be in only one of them:
Request.CreateResponse<object>(HttpStatusCode.PartialContent, null);
But is there any other way to resolve the conflict?
[Steps to reproduce]
Create a console app
Add the reference to System.Net.Http
Add the reference to System.Net.Http.Formatting from NuGet
Add using System.Net.Http
Add var req = new HttpRequestMessage();
Try adding req.CreateResponse(HttpStatusCode.OK);
You should see 12 extension method overloads. Some are duplicated, those are the problem.
In general, you can use extension methods directly to resolve such ambiguities:
Instead of
myRequest.CreateResponse(HttpStatusCode.PartialContent);
use
HttpRequestMessageExtensions.CreateResponse(myRequest, HttpStatusCode.PartialContent);
In this specific case, I could not reproduce the issue following your instructions. However, I have downloaded the Microsoft.AspNet.WebApi.Client Nuget instead of the System.Net.Http.Formatting Nuget since the later one is marked as deprecated. Maybe try to update to the newer Nuget?
Update: I can reproduce the issue when also installing the System.Web.Http.Common Nuget and adding using System.Web.Http; to the file. Using the explicit call to the method as shown above resolves the issue.

Method not found: 'System.Linq.IQueryable`1<!!0> NHibernate.Linq.LinqExtensionMethods.Query(NHibernate.IStatelessSession)'

I have a problem when upgrading NHibernate from 4.1.2 to 5.2.3 and Target Framework from 4.5 to 4.6.2 (to compatible with NH 5.x). The problem occurs when I execute the query using LINQ (it worked well before):
service.Query.Where(p => p.Approved).FirstOrDefault();
This is detail message exception:
Method not found: 'System.Linq.IQueryable`1 NHibernate.Linq.LinqExtensionMethods.Query(NHibernate.IStatelessSession)'.
I notice when I call service.Query, the system will throw an exception:
'service.Query' threw an exception of type 'System.MissingMethodException'
What did I miss?
Your app is still trying to call old extension Query method which was removed in NHibernate 5. Query is IStatelessSession/ISession interface method since NHibernate 5.
Exception you see means that your app is not properly recompiled with new NHibernate dlls. Make sure that all your projects reference new dlls (or nuget package) and you have no compilation errors (possible case - you run last successful build before upgrade but with newer dlls).

Get Changes Between Builds from VSO API using Microsoft.TeamFoundation.Build2.WebApi package

I'm working on my app which gets data via VSO API. I'm using
Microsoft.TeamFoundation.Build.WebApi.BuildHttpClient
class to get the data. There is the
GetChangesBetweenBuildsAsync
method which would be a great help for me, but there is something strange.
When I call this method I get the following exception:
{
"Method not found:
'System.Threading.Tasks.Task`1<System.Collections.Generic.List`1<Microsoft.TeamFoundation.Build.WebApi.Change>>
Microsoft.TeamFoundation.Build.WebApi.BuildHttpClientBase.GetChangesBetweenBuildsAsync(
System.String,
System.Nullable`1<Int32>,
System.Nullable`1<Int32>,
System.Nullable`1<Int32>,
System.Object,
System.Threading.CancellationToken)'."
}
I did the following so far to solve the problem:
At first I thought something went wrong during compile. I compiled the code in release and in debug many times but the problem was not solved. I still have the issue.
I have checked the references, all of the projects related to work with data coming from VSO have the same references. Did not help.
I decompiled the binary but it has the code in place
The strange is that there is another method,
GetBuildsAsync
which I use and it works well, and they are in the same class.
It seems I have found what is the root of the problem above. I had two version of the packages installed and it seems the references were messed up. I have removed and reinstalled the packages below. Now it is working, at least the request hits the server but I always get that error there is no earlier build.
Microsoft.TeamFoundationServer.Client
Microsoft.TeamFoundationServer.ExtendedClient
Microsoft.VisualStudio.Services.InteractiveClient
Microsoft.VisualStudio.Services.Client

io.konik.PdfHandler constructor error

I have a c# dotnet 4 solution with one main wpf project which
refer as project a class library with references the local IKVM.*.dll version Version=8.0.5449.1 and ZUGFeRD.NET.dll version 1.0.0.0. When trying to do
PdfHandler handler = new PdfHandler();
I'm getting the next error :
java.util.NoSuchElementException was unhandled
HResult=-2146233088
Message=""
Source=IKVM.OpenJDK.Core
StackTrace:
at java.util.ServiceLoader.LazyIterator.nextService()
at java.util.ServiceLoader.LazyIterator.next()
at java.util.ServiceLoader.1.next()
at io.konik.PdfHandler..ctor() ...
The strange part is that if I use the the IKVM.*.dll and
ZUGFeRD.NET.dll in first project and remove the second project, the example from Github
works. Do you have any ideea? Thank you.
I had the same Problem. This problem could be solved by adding
ikvm.runtime.Startup.addBootClassPathAssembly(typeof(ObjectFactory).Assembly);
before using the ZUGFeRD.NET framework.
I put this code in the constructor of my own ZUGFeRD class.

Categories