HighTechTalks DotNet Forums  

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

Dotnet Framework (Interop) microsoft.public.dotnet.framework.interop


Discuss COM Interop for Out Proc C++ Server from C# in the Dotnet Framework (Interop) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
=?Utf-8?B?RGViYXNpc2ggQm9zZSwgT3JhY2xlIENvcnA=?=
 
Posts: n/a

Default COM Interop for Out Proc C++ Server from C# - 07-22-2007 , 05:24 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(Strin g 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.

Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.