I created a new Console App using the Microsoft.Graph library (4.41.0) and Azure.Core (1.25.0). When compiling the console app and run it, it will work correctly. When I choose voor: Class Library. Compile it. Register the .DLL with:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe /codebase GraphTest.dll
and call the resulting .dll from cscript it gives the error below.
It isn't the .dll registration. If I call a HelloResponse() class I get the correct result back: "Hello World!".
The target framework is DotNet 4.6.2. Also tried standard2.0.
Looked at GitHub for open issues but none seems to match my issue.
Update
As commented: "Use fusion++".
The problem seems that the main packages is using a higher version of the Microsoft.Identity.Client.dll (version: 4.46.1.0) and the subpackages are requesting an older version (4.39.0.0).
The app.config won't solve this, in my opinion, because the sub pacakages aren't re-compiled but have a hard reference.
How can I get both libraries to work?
System.IO.FileNotFoundException: Kan bestand of assembly Microsoft.Identity.Client, Version=4.39.0.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae of een van de afhankelijkheden hiervan niet laden. Het systeem kan het opgegeven bestand niet vinden.
Bestandsnaam: Microsoft.Identity.Client, Version=4.39.0.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae
bij System.Signature.GetSignature(Void* pCorSig, Int32 cCorSig, RuntimeFieldHandleInternal fieldHandle, IRuntimeMethodInfo methodHandle, RuntimeType declaringType)
bij System.Reflection.RuntimeConstructorInfo.GetParametersNoCopy()
bij System.Reflection.RuntimeConstructorInfo.GetParameters()
bij System.Diagnostics.StackTrace.ToString(TraceFormat traceFormat) bij System.Exception.GetStackTrace(Boolean needFileInfo)
bij System.IO.FileNotFoundException.ToString()
bij System.IO.TextWriter.WriteLine(Object value)
bij System.IO.TextWriter.SyncTextWriter.WriteLine(Object value)
bij System.Console.WriteLine(Object value)
bij GraphTest.ADFOAuthGraphConnector.ConnectGraphClient(String appId, String clientSecret, String tenantId, String exchangeURI) in C:\Users\xx\bitbucket\GraphTest\ADFOAuthGraphConnector.cs:regel 47
bij GraphTest.ADFOAuthGraphConnector.<GetNumber>d__5.MoveNext() in C:\Users\xx\bitbucket\GraphTest\ADFOAuthGraphConnector.cs:regel 72