[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.interop

COM Interop for Out Proc C++ Server from C#

Debasish Bose, Oracle Corp

7/22/2007 9:24:00 PM

I have a legacy C++ realtime appwhich is being wrapped in a out of process
COM server - fooServer. Now the IDL has four interfaces which are all
dispinterfaces. Two of them are shown -

[ uuid(FAD83C4D-7AB7-4a23-B03B-3A1339C4E68B) ]
dispinterface IfooSettings
{
methods:
[id(1), helpstring("method loadSettings")]
HRESULT loadSettings([in]BSTR buffer, [out]VARIANT_BOOL* ret);

...
};

[ uuid(CC6CE3E0-466D-43e9-8CD3-799A44F60166) ]
dispinterface IfooEventCallback
{
methods:
[id(1),helpstring("method SetExtCallStateEventCallback")]
HRESULT SetfooEventDelegate([in]_Delegate* cb);

...
};

The server is being created as a MFC CCmdTarget way. The IfooEventCallback
ideally should be a classic COM style event interface but it is not.

Now I have created a C# COM Interop dll by tlbimp. The generated interfaces
seem just fine. Infact I am able to create "CoClass Interfaces" from C#
triggering the fooServer.exe up -

_fooEventCallback = new fooEventCallback();

_fooSettings = new fooSettings();

but just when I am invoking any methods on _fooSettings interface following
get exception get dumped -

Error Occured while application start: Internal application error.
Source: SIPXSE~1
Trace: at System.RuntimeType.ForwardCallToInvokeMember(String memberName,
BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData&
msgData)

Strangely enough this doesn't happen for _fooEventCallback. Also I'm unable
to debug even using two different instances of VS.NET one launching the
client, other attached with fooServer.exe with all symbols loaded. Also when
trying setting breakpoint, "source, binary mismatch" happens resulting
breakpoints go erratic. I checked that PDBs are up-to-date. Could it be for
heavy MACRO usage in the MFC app?

Also is it ok to have HRESULT as return type for methods of a dispinterface.
Other than performance penalty in IDispatch::Invoke, is there anything wrong?
Are C# COM Interop does well with such dispinterfaces other than events?

Anyway any pointer on this would be seriously appreciated as I'm stuck on
this for a while.