开发者

How to call a DCOM object from C#?

I have a CLSID and I need to instantiate this in a Different server (i.e. DCS ) where as my working machine is (i.e. MWS ).

Now, if I use following :

var type = Type.GetTypeFromCLSID(new Guid(CLSID),
       Environment.MachineName, true);
 var COMObject = Activator.CreateInstance(type);
 var returnValue = COMObject.GetType().InvokeMember(methodName,
                        flags, null, COMObject, args, argModifiers, null, null);

Then I get "COM target does not implement IDispatch" error. Ok, I understand that probably the COM target object doesn't have the IDispatch, so it fails.

Now then tried something else, If I add a reference of that COM DLL in VS, then VS generate the interop assemblies and then everything works like regular .net object creation, but in that case the object is actu开发者_如何学Goally generating in my local machine (MWS pc) not into the server what I want.

Guys any suggestion how can I deal this situation?

Thanks in advance.


You could export your COM+ from the target machine as a proxy and install it on your machine running the application.

Go to Component Service console on your target machine, right click on your COM+ application and choose Export ... Then select Application Proxy radio button. This will export a proxy to that COM+ application as a MSI file. You need to install it on your machine instead of real COM+ application (that means deleting it if it's installed there) and then try your interop.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜