I used two Com interop object in my method and one of them has to call some function to do some initilizeing by passing in the other com object. I declared the object as following:
B2K_Server2.clsAppBroker Broker = new B2K_Server2.clsAppBroker();
B2K_Server2.clsBLL_RequisitionClass objReq = new B2K_Server2.clsBLL_RequisitionClass();
objReq.Init(ref Broker);
I release them like this:
Marshal.ReleaseComObject(Broker);
Marshal.ReleaseComObject(objReq);
However, after the process is finished, I found the object objReq is released but Broker is not released. I think the problem is the way to declare the variable is different . Borker is using the original class from COM and the objReq is declared using the class the RCW generated. However, I cannot decalre the broker in the same way otherewise the
objReq.Init(ref Broker) will generate an error because of the different type of argument.
Anyone know how I can solve this problem?
Thanks in advance!
B2K_Server2.clsAppBroker Broker = new B2K_Server2.clsAppBroker();
B2K_Server2.clsBLL_RequisitionClass objReq = new B2K_Server2.clsBLL_RequisitionClass();
objReq.Init(ref Broker);
I release them like this:
Marshal.ReleaseComObject(Broker);
Marshal.ReleaseComObject(objReq);
However, after the process is finished, I found the object objReq is released but Broker is not released. I think the problem is the way to declare the variable is different . Borker is using the original class from COM and the objReq is declared using the class the RCW generated. However, I cannot decalre the broker in the same way otherewise the
objReq.Init(ref Broker) will generate an error because of the different type of argument.
Anyone know how I can solve this problem?
Thanks in advance!