UWP problem with library using Microsoft.IdentityModel.Clients.ActiveDirectory - c#

I am working on a UWP application and I'm trying to call a library which uses Microsoft.IdentityModel.Clients.ActiveDirectory but it keeps throwing the following exception:
Could not load type 'Microsoft.IdentityModel.Clients.ActiveDirectory.ClientAssertionCertificate' from assembly 'Microsoft.IdentityModel.Clients.ActiveDirectory, Version=3.17.2.31801, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
I've tried updating the version to 5.2.6 but to no avail. I've also tried installing the Microsoft.IdentityModel.Clients.ActiveDirectory NuGet package directly into the UWP project, yet again to no avail.
I'm thinking this package is just not compatible with UWP? Because it works fine in a .NET Core or Framework console app. Is there a way I can shim it or force compatibility?

Related

Could not load file or assembly 'Newtonsoft.Json, Version=13.0.0.0 .NET Standard and WPF

We have a solution with two projects:
A desktop App using WPF (.NET 4.6)
A class Library (.NET Standard) that connects to remote REST API.
We are using NewtonSoft JSON 13.0.0.1 (installed via NuGet) in the class library project. We referenced the class library project in the WPF project. Whenever we call a method in the library project from WPF application, we get the following error:
Could not load file or assembly 'Newtonsoft.Json, Version=13.0.0.0... could not find the file...
I am clueless as to why 13.0.0.0 is being searched when 13.0.0.1 version is installed, I even tried with the 12.x. version, it also gives the same error only searching for 12.0.0.0 version.
Is this a WPF .NET and Libary .NET Stanard conflict issue? How to resolve this?

using vb dll in .net core 3.1 project

I have a.net core 3.1 Web API project and I have to use functions from a dll programmed in vb.
and I am not allowed to modify the dll.
when running the service,I get the error:
"Could not load type 'Microsoft.VisualBasic.Devices.Computer' from assembly 'Microsoft.VisualBasic, Version=10.0.0.0, Culture=neutral, PublicKeyToken=fghda'.",
I tried addind this dll in .netframework web API project and by adding "Microsoft.CodeDom.Providers.DotNetCompilerPlatform" nuget to the references ,I could successfully run the service.
the problem is this nuget is not working in .net core and using similiar nugets were useless.
I also added microsoft.visualbasic dll but nothing changed.
So anybody knows how to resolve the issue?
.NET Core still does not seem to support VB .NET. It was mentioned in the previous statement that it will be supported in the future.
https://devblogs.microsoft.com/vbteam/visual-basic-in-net-core-3-0/

SingalR in Xamarin.Forms

I'm trying to create a Xamarin.Forms PCL client for SignalR. Every tutorial I found it's how to add SignalR to either Xamarin.Android or Xamarin.iOS. How can I add SignalR to Xamarin.Forms project?
Should I create an separate PCL, call it "Proxy" and then just use this PCL in Xamarin.iOS, Android and Windows Mobile projects?
If 1), should I add SignalR also in every project (besides PCL, where I'm really using it)?
Should I add to the PCL created by default, while creating Xamarin.Forms solution?
Thanks for help,
Here's the problem I'm getting:
I have a fully working Xamarin.Forms PCL project. I removed all windows stuff though. I just left PCL, iOS and Android projects. It works! I added CocosSharp only, but don't use it. Plain, empty, never touched Xamarin.Forms. Then I've added SingalR to PCL project. Complied, run - works! BUT when I add JUST this line:
var connection = new HubConnection("http://localhost:52128");
it doesn't even compile. I'm getting errors:
Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'. Perhaps it doesn't exist in the Mono for Android profile
I'm totally lost.
I've tried:
Installing nuget just on the PCL - error
Installing on every project - error
Creating new PCL, implementing that line there, adding it as a reference to the main PCL. Calling a method from the second PCL - error.
I met the same error as you did, it seems that when installing SignalRMicrosoft.AspNet.SignalR.Client package, the dependency packages cannot be automatically installed, the references got somehow corrupted.
To solve this issue, you can manually install those packages.
Install the following three Packages separately from Nuget:
SignalRMicrosoft.AspNet.SignalR.Client.
Newtonsoft.Json.
Microsoft.Net.Http.

Portable class library for referred nuget packages dll not generated

I created a .net standard 1.3 PCL and referred newtonsoft.json package in that library using visual studio 2015.
After that i tried referring this dll to a console application of .net framework 4.5.2 , in the console application on execution, i get an error as
Could not load file or assembly 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
I see that in PCL on building project i am not getting the dlls of dependent package , why does that problem exist?
How to fix this?
Note -
build location for console application and PCL library is same.
best way i found on exploration is to create nuget package using dotnet pack and refer it in project

Exception using System.IdentityModel.Tokens.Jwt 5.0.0.127 in Web Api 2 built on .Net 4.6

I have updated my existing Web Api project to use the latest System.IdenityModel.Tokens.Jwt package and I am getting the following error:
Could not load type 'System.IdentityModel.Tokens.TokenValidationParameters' from assembly 'System.IdentityModel.Tokens.Jwt, Version=5.0.0.127, Culture=neutral,
PublicKeyToken=31bf3856ad364e35'.
Everything works fine with 4.0 version of the same package. How can I resolve this?
If you want to use the new version(v5) of System.IdentityModel.Tokens.Jwt and don't want to restrict your project to the v4 version, I have created a Nuget and Github project called EasyJwtAuth that uses v5(Very simple to use):
Nuget package:
https://www.nuget.org/packages/EasyJwtAuth
Instructions on how to use:
https://github.com/Xela101/EasyJwtAuth
Feel free to update the repository with more features, or just learn/copy the code and make your own authentication wrapper.

Categories

Resources