开发者

How do I connect from a C# client to a VB6 Com+ server

开发者 https://www.devze.com 2023-03-06 04:17 出处:网络
I have the following code in my C# class which remotely connects to a COM+ server on a remote machine.

I have the following code in my C# class which remotely connects to a COM+ server on a remote machine.

Initailly it was failing at Activator.CreateInstance, as I didnt have a user on the COM+ server who was the same as the user launching the client.

Ive installed COM+ proxy stubs on my client machine, and imported these into my C# project. In the IDL file, there is only one interface definition, _AddressLookup, which inherits from IDispatch, but in the object viewer in C# i seem to get two interfaces, _AddressLookup and AddressLookup.

private string开发者_如何学编程 CreateEarly(string server)
  {
   try
   {
    Type typeADLClass = typeof(LookupBusiness.AddressLookupClass);
    Type typeDCOM = Type.GetTypeFromCLSID(typeADLClass.GUID, 
     server, 
     true);

    object objAdd = Activator.CreateInstance(typeDCOM);

    AddressLookupClass AddressLookupClass_result = (AddressLookupClass) Marshal.CreateWrapperOfType(objAdd, typeADLClass);

   }
   catch(Exception e)
   {
    return e.Message;
   }
   return "Create - success";

  }

When I run this code, I get:

Source object can not be converted to the destination type since it does not support all the required interfaces.

If I try and use late binding:

            object[] myArguments= {"www.zenei.co.uk", "39"};
            object c;
            c = typeDCOM.InvokeMember("Gett", BindingFlags.InvokeMethod, null, objAdd, myArguments);

I get Interface does not support IDispatch.

Can anyone help?


It looks as if there were network port issues, ie they were being blocked by a firewall. Which may have caused this issue.

Running a netstat on the machine running the above code, shows COM initialising on port 135, but then returning calls on a new port (in the range 1024 - 5000, seaching for RPC server ports will find more details on this)

We had the return port blocked, so the COM+ server was spinning up, in DCOMCNFG, but then timeouts were occurring.

0

精彩评论

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