Comments
2 comments
-
Rather than Reflecting across the assembly (which is going to find two types that implement IServiceProvider), you could new an instance of ApplicationManager.
IServiceProvider sp = new Reflector.ApplicationManager(null); IAssemblyManager am = (IAssemblyManager)sp.GetService(typeof(IAssemblyManager)); ITranslatorManager tm = (ITranslatorManager)sp.GetService(typeof(ITranslatorManager));
-
That worked! Thank you!
In the past, Reflector types were obfuscated so I could not create the ApplicationManager directly, but now it is possible. Great!
Add comment
Please sign in to leave a comment.
I developed a Reflector.NET add-in few years ago. It transforms .NET assemblies in native unmanaged C++ (can be used for embedded system - http://crossnet.codeplex.com/).
The most efficient workflow is to use the command line API. To be able to access the Reflector API (mostly IAssemblyManager instance and ITranslaterManager) I need to create an IServiceProvider instance.
That worked in the past, but with the more recent version of Reflector.NET, this line is now throwing an exception:
typeof(Reflector.IPackage).Assembly.GetTypes().
Here is the TypeLoadException:
{"Could not load type 'Invalid_Token.0x02003FFF' from assembly 'Reflector, Version=5.0.0.0, Culture=neutral, PublicKeyToken=18ca6bb8dd6a03c3'.":"Invalid_Token.0x02003FFF"}
Because of this I can't find and create the IServiceProvider implementation. Is there another way to get the IServiceProvider implementation that I could use?
Thanks!
Olivier