我使用中央COM +组件,通过以下代码调用其他C#类:
var comType = Type.GetTypeFromProgID("NameSpace.Class1");
Assembly assembly = Assembly.LoadFrom("Class1.dll");
var abc = Activator.CreateInstance(comType);
通常这种代码安静工作正常。当模拟此中央COM +组件上的重负载时,Activator无法创建任何实例。 class1与中央COM +组件不在同一文件夹中。
我得到以下异常:
System.Runtime.Remoting.RemotingException: Cannot load type 'NameSpace, Class1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=95a767s6d7'.
at System.Runtime.Remoting.RemotingServices.GetOrCreateProxy(Identity idObj, Object proxy, Boolean fRefine)
at System.Runtime.Remoting.RemotingServices.InternalUnmarshal(ObjRef objectRef, Object proxy, Boolean fRefine)
at System.EnterpriseServices.ServicedComponentProxyAttribute.CreateInstance(Type serverType)
at System.Runtime.Remoting.Activation.ActivationServices.IsCurrentContextOK(RuntimeType serverType, Object[] props, Boolean bNewObj)
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
at Dummy.CreateBusinessLayerInstance(Type businessLayerType, Boolean remoteObject)
任何解决问题的想法?当我通过DCOM创建实例时,一切都很好。