   .NET InvalidCastException
  Hello!My application throws an InvalidCastException in the following line:IScriptProvider^ prov = (IScriptProvider^)asme->CreateInstance("Wrapper.ScriptProvider", true);With the text: "The object of type "Wrapper.ScriptProvider" cannot be converted to the type "IScriptProvider"."But basically this cannot be as the classes are like that:public interface class IScriptProvider{public:void InitLib(ScriptMgr^ pMgr);};In the project that gets loaded in the above code this class gets implemented:namespace Wrapper{    public class ScriptProvider : IScriptProvider    {   public ScriptProvider()   {   }   public void InitLib(ScriptMgr init)   {  init.RegisterChatHook(new ChatHooker.ChatHook());   }    }}I made a test in another application and there isnt an exception. What could be the reason for that?Greetings and thanksPlerion   
  Hold the returned result from asme->CreateInstance() a local object variable before casting it. Then put a break point on the line where is casted. Then you can see what is really being returned.   ;  Its a bit a bad setup to debug via breakpoints. I made the following:System::Object^ obj = asme->CreateInstance("Wrapper.ScriptProvider", true);Console::WriteLine("Type: {0}", obj->GetType()->ToString());IScriptProvider^ prov = (IScriptProvider^)obj;It displays "Wrapper.ScriptProvider".   ;  i found the reason for the exception but not the solution...Imagine the situation:.\Server.exe.\scripts\Wrapper.dll.\scripts\Managed\Script.dllServer.exe calls a exported function of Wrapper.dll. This function creates instance of my ScriptMgr from the Assembly scripts\Wrapper.dll. Now it loads the assembly scripts\Managed\Script.dll. This depends on scripts\Wrapper.dll (it is referenced there). But the problem is that it is expecting just "Wrapper.dll". So it searches for Wrapper.dll in .\ . There of course is no Wrapper.dll and CreateInstance returns 0.Ok, if i copy the Wrapper.dll to .\ CreateInstance loads the ScriptProvider which inherits from IScriptProvider. But now there is a problem as i could read on MSDN. This instance is of the type .\Wrapper.dll:IScriptProvider. If i now try to cast that in my .\scripts\Wrapper.dll to IScriptProvider it wants to cast it to .\scripts\Wrapper.dll:IScriptProvider. This is differenct for .NET and therefore invalid cast.I tried to set the current directory of my application to .\scripts when i load the assembly .\scripts\Managed\Script.dll but it still wants to have the Wrapper.dll in .Does anybody know a possbile solution for that?GreetingsPlerion   