By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,509 Members | 1,301 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,509 IT Pros & Developers. It's quick & easy.

C# App using Mixed Managed C++ crashes when access COM object through interop and unmanged code

P: n/a
I am using .NET 2.0

I have a C#.Net App, which uses a .NET Class Library, which accesses a
COM object through interop.
The C#.Net App also uses a mixed mode C++.Net Class library which uses
an unmanaged win32 DLL, which uses another unmanaged win32 DLL which
accesses the same COM object

The COM object is in another process.

Problem is When I attempt to access the COM object through both roots
the Application crashes without any messages. I can access the COM
object through either root but not both.
In the c# library I have something like:

LoggerClass _Logger = new LoggerClass() // interop wrapper for com
object

// this is called from the C#.Net app
public CSharp.Interface.Write(string strData)
{
_Logger.Write(strData);
}

In the C++ Win32 DLL I have something like:

void Write(LPCTSTR strData) // this is call from within another win32
DLL
{
// g_Logger is created in the first call using CoCreateInstance
g_Logger.Write(T2BSTR(strData));
}

Nov 23 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Thankfully this was not a conceptual problem but due to my own
incompedence. I had a problem where I was overwriting memory.

ropo wrote:
I am using .NET 2.0

I have a C#.Net App, which uses a .NET Class Library, which accesses a
COM object through interop.
The C#.Net App also uses a mixed mode C++.Net Class library which uses
an unmanaged win32 DLL, which uses another unmanaged win32 DLL which
accesses the same COM object

The COM object is in another process.

Problem is When I attempt to access the COM object through both roots
the Application crashes without any messages. I can access the COM
object through either root but not both.
In the c# library I have something like:

LoggerClass _Logger = new LoggerClass() // interop wrapper for com
object

// this is called from the C#.Net app
public CSharp.Interface.Write(string strData)
{
_Logger.Write(strData);
}

In the C++ Win32 DLL I have something like:

void Write(LPCTSTR strData) // this is call from within another win32
DLL
{
// g_Logger is created in the first call using CoCreateInstance
g_Logger.Write(T2BSTR(strData));
}
Nov 24 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.