I have a C # solution with two projects:
- Class library with several classes: one of the classes authenticates using ADAL.NET, so I have a link to the package "Microsoft.IdentityModel.Clients.ActiveDirectory" (v3.10)
- I also have a ConsoleApplication application that is used as a test platform. From here, I enter the class library to quickly test the prototype code, and then drop it. By itself, in addition to using Console.ReadLine () and Console.WriteLine (), this console application simply calls the class library mentioned in 1)
Now it’s strange that if I don’t include the nuget link in “Microsoft.IdentityModel.Clients.ActiveDirectory” in my console application, it gives an error message:
[FileLoadException: Could not load file or assembly "Microsoft.IdentityModel.Clients.ActiveDirectory, Version = 3.10.0.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35" or one of its dependencies. The manifest definition of the hosted assembly does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
However, when I just add this link, everything works.
I am confused, why is this so? The class library already has a link to the package, and the class library is the only one using the package, so why should I also add a link to the console application?
The funny part is that I turned on WebApp and posted everything to an Azure subscription. The same problem arises from a web application. If I add a link to the nuget package "Microsoft.IdentityModel.Clients.ActiveDirectory" in the web application, everything will work, but if I remove it, it throws an exception above. Note that WebApp does not directly use the package, it simply calls the class library (which already has a link and uses it).
Can someone shed light on what is happening here?
source share