Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Issue of access COM from AppDomains

3 views
Skip to first unread message

Chris

unread,
Dec 6, 2009, 7:59:01 PM12/6/09
to
Hi there,

I have two dotnet winform applications -- one is C# app (CSharpApp.exe) and
the other is managed C++ app (MngCPPApp.exe). I also developed a COM
component registered with regsvr32 and use tlbimp to create CLI interface
skeleton for managed application code to access the COM component. The two
applications can access the COM component's interface without any problem
when they run individually.
I now create a second AppDomain in the C# app (CSharpApp.exe) and execute
the managed C++ app (MngCPPApp.exe) in the second AppDomain (using
AppDomain's ExecuteAssembly) in a separate thread. I start C# appilcation (in
VS2008 IDE debug mode). As part of the running application, the managed C++
app gets run in the second AppDomain some stage later. However, the managed
C++ app throws an exception upon calling the COM interface. The exception
looks like
[
An unhandled exception of type 'System.InvalidCastException' occurred in
CSharpApp.exe
Additional information: Unable to cast COM object of type
'MyCommTLB.CommClass' to interface type MyCommTLB.IComm'. This operation
failed because the QueryInterface call on the COM component for the interface
with IID '{74ADCB23-C9AB-463F-ABA2-9BFDB959E43F}' failed due to the following
error: No such interface supported (Exception from HRESULT: 0x80004002
(E_NOINTERFACE)).
]

Note: accessing the COM component inside CSharpApp.exe itself (i.e. in the
main AppDomain) is still ok.

Could anyone shed some light on why running an executable in a second
AppDomain broke down the access to a COM component interface?

Many thanks
Chris

0 new messages