Microsoft.Identity.Web with Graph and Graphbeta in Parallell - c#

I am working on a asp.net core MVC project and want to use Graph and GrahBeta packages
using Microsoft.Identity.Web.MicrosoftGraph adn Microsoft.Identity.Web.MicrosoftGraphBeta.
I define an external alias for the beta version of the package as described here:
https://github.com/microsoftgraph/msgraph-beta-sdk-dotnet#using-the-beta-client-along-with-the-v10-library
This works as excpected, but in Startup.cs, when registering Graph like
services.AddAuthentication[...].AddMicrosoftGraph(Configuration.GetSection("GraphAPI"))
I get the following error:
The call is ambiguous between the following methods or properties: 'Microsoft.Identity.Web.MicrosoftGraphExtensions.AddMicrosoftGraph(Microsoft.Identity.Web.MicrosoftIdentityAppCallsWebApiAuthenticationBuilder, string, string)' and 'Microsoft.Identity.Web.MicrosoftGraphExtensions.AddMicrosoftGraph(Microsoft.Identity.Web.MicrosoftIdentityAppCallsWebApiAuthenticationBuilder, string, string)'
As this seems to come from the exact same package, I have no idea about how to handle this. Thank you for your help.

Related

HostingEnvironment.QueueBackgroundWorkItem method is missing

I am working in .NET framework 4.8 (correction: my Visual Studio installation was 4.8, the application was targeting 4.5 - this was the source of the problem, which is now solved) and trying to use the QueueBackgroundWorkItem method of the HostingEnvironment class, but when I write it into my code, I get this message:
BC30456: 'QueueBackgroundWorkItem' is not a member of 'HostingEnvironment'.
I have used Imports System.Web.Hosting at the top of my script. System.Web.Hosting imports OK and the HostingEnvironment class shows up highlighted in my code, as it should. The class HostingEnvironment is recognised and has methods, but QueueBackgroundWorkItem isn't one of them.
I get a similar error when I try to use this method in C#.
CS0426: The type name 'QueueBackgroundWorkItem' does not exist in the type 'HostingEnvironment'.
I've searched for the System.Web.Hosting library in NuGet to see if there were any updates, but nothing came up. Google searches for these errors haven't got me anywhere, other than to links explaining how to use the HostingEnvironment method.

AppCenter analytics not starting for WPF

I try to use AppCenter for measuring crashes and telemetrics in my application.
The application is a WPF application, using .NET framework 4.7.2.
I register AppCenter the following way:
AppCenter.Start("MY_KEY", typeof(Analytics), typeof(Crashes));
Directly after the registration I see the following output message:
ERROR: Failed to start service 'Analytics'; skipping it.
Microsoft.AppCenter.AppCenterException: Service type does not contain static 'Instance' property of type IAppCenterService. The service is either not an App Center service or it's unsupported on this platform or the SDK is used from a .NET standard library and the nuget was not also added to the UWP/WPF/WinForms project.
vid Microsoft.AppCenter.AppCenter.StartInstance(Type[] services)
I have the following NuGet versions of AppCenter installed:
Microsoft.AppCenter.Analytics: 3.4.2
Microsoft.AppCenter.Crashes: 3.4.2
Has anybody faced the same problem and knows how to solve this?
Thanks in advance.
The issue is located and corrected.
The cause of this issue was caused by a namespace conflict, another package named Analytics.
Refering the correct namespace with full name, resolved this issue:
AppCenter.Start("MY_KEY", typeof(Microsoft.AppCenter.Analytics.Analytics), typeof(Crashes));

Sytem.Reflection.Emit error when establishing XML client in Azure Function

Trying to establish an xmlrpc to a third party web service from my function app. It works fine from localhost, and indeed, it works in other functions but when published to Azure I'm getting this error:
System.MissingMethodException: Method not found: 'System.Reflection.Emit.AssemblyBuilder System.AppDomain.DefineDynamicAssembly(System.Reflection.AssemblyName, System.Reflection.Emit.AssemblyBuilderAccess)'.
at CookComputing.XmlRpc.XmlRpcProxyGen.BuildAssembly(Type itf, String assemblyName, String moduleName, String typeName, AssemblyBuilderAccess access)
at CookComputing.XmlRpc.XmlRpcProxyGen.Create(Type itf)
at CookComputing.XmlRpc.XmlRpcProxyGen.Create[T]()
It's failing at this line:
_serviceClient = XmlRpcProxyGen.Create<IServiceClient>();
IServiceClient is an interface that looks like this:
using CookComputing.XmlRpc;
using System;
namespace App.Core.Helpers.Service
{
[XmlRpcUrl("https://some.url")]
public interface IServiceClient : IXmlRpcProxy
// methods
}
I've manually added the System.Reflection.Emit package to the solution in an attempt to fix it, but no joy. The exact same code is running fine in other apps we have in Azure. The app is running .Net framework 4.6.1.
This is a problem which can occur when there is an old version of a DLL still lingering somewhere around. Make sure that the latest assemblies are deployed and no duplicated older assemblies are hiding in certain folders. Your best bet would be to delete every built item(Clean Build) and Rebuild/redeploy the entire solution.
In particular, be sure an old version is not in the GAC.
This can help to Remove an Assembly from the Global Assembly Cache.
I was facing same issue as you were facing.
What I found solution is that, I was using asp.net core framework So I have to change it into net 4.5 framework. And that's all.
Issue resolved.
So you may try that.

System.ObservableExtensions.Subscribe: ambiguous reference

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.

Azure Functions: Adding Neo4j Driver dependency to C# HTTP Trigger throws Error

Im creating a Azure function which should connect to a neo4j database after receiving a https request. I used the Visual Studio 2015 function preview to set up my project and to create a C# HTTP trigger function.
I then added a Neo4j dependency to my project.json
"dependencies": {
"Neo4j.Driver": "1.2.0"
}
After a NuGet rebuild i get multiple error like the following:
run.csx(8,19): error CS1929: 'HttpRequestMessage' does not contain a definition for 'GetQueryNameValuePairs' and the best extension method overload 'HttpRequest MessageExtensions.GetQueryNameValuePairs(HttpRequestMessage)' requires a receiver of type 'HttpRequestMessage'
I didn't change anything else of the default function code and after adding the dependent the Framework Versions are still the same.
Do i have to add some default dependencies so that i can still use the HTTP trigger?
Edit: i uploaded the Content of the project.lock.json files maybe this helps
Without dependency https://api.myjson.com/bins/1f5hrv
With dependency (3000 lines) https://api.myjson.com/bins/14fovv
The reference to Neo4j.Driver causes a reference to System.Net.Http to be added, using a version that leads to a type mismatch between what is referenced and the extension methods from the assemblies provided by the runtime.
Please add your own references to System.Net.Http, see this stackoverflow question: Azure Functions - System.Net.Http

Categories