I’m making a Grasshopper plugin that already works on Rhino 7. It uses the Grasshopper package and also the Microsoft.Identity.Client package for auth (it’s an internal work plugin so needs to use this).
When running on Rhino 8 and we get to any part of the code that uses Identity.Client package, we get the error:
Could not load type 'Microsoft.Identity.Client.BaseAbstractAcquireTokenParameterBuilder 1' from assembly 'Microsoft.Identity.Client, Version=4.22.0.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae'.
We use Identity.Client v4.61.1, so I’m not sure which part is looking for v4.22.0.
I know that for Rhino 8 we need to make sure that we’re compatible with .Net 7, which I have done. The plugin is multi-targetting both framework and .net 7 and it builds fine, there are no build errors the above error only comes up when running in Grasshopper.
Has anyone experienced this/a similar issue? I don’t have any other plugins installed on Grasshopper so don’t think that there should be any conflicts there.
Hi, is there any other solution to this? My Grasshopper plugin uses Azure.Identity which requires Microsoft.Identity.Client >= 4.61.3. I can’t downgrade.
Hi @Erron_Estrado did you end up solving this? In case this would help you, or anyone else reading this:
I hit this problem today and my solution seems to work for me now, where I am able to use version 4.66.2 (which has an accompanying Microsoft.Identity.Client.Broker package) in Rhino 8; I tested it in Debug and Release builds for Rhino 7 and 8.
After trying Costura.Fody and ILRepack and encountering some issues, I went back to the old ILMerge.
In short, I added ilmerge as a nuget package and inserted post-build commands in my csproj to:
merge the Microsoft.Identity.Client-related packages into the main DLL, with internalize set (important)
deleting the Microsoft.Identity.Client-related files afterwards
If explaining more could help in any way, let me know.
For now I choose to forgo the embedded web view and just use the browser because it feels a bit more reliable, it simplifies it slightly and I don’t think people mind if this happens because they’ll just confirm the account that they would have likely already logged into via the browser previously.
I now use ILRepack now to merge the Microsoft.Identity.Client.dll and Microsoft.IdentityModel.Abstractions.dll, as well as my own Microsoft-Graph-centric library that calls them, into my main gha file.
I’ve done some more research and there are some indications that even this, although it seems to be working at the moment, could have some issues. Being a plug-in it is inherently difficult to isolate all your own DLLs for your plug-ins into a context that truly separate from the main context or from other plug-ins, so eventually I might think of other ways to communicate with these APIs other than MSAL.
I’m also using the browser but some aspects are quite annoying. No auto-close after auth is complete, and no obvious way to customize the redirect page depending on server response (success/fail/expired/etc.).
I’d love to know if you find a way to bypass MSAL entirely!