473,383 Members | 1,877 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

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

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
1 2051
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: lolomgwtf | last post by:
I have a managed C++ method that wraps unmanaged code and creates a managed object holding data retrieved form an unmanged one. I want create an instance of this managed class in C#, pass it to...
5
by: dvtaylor | last post by:
We write everything in plain old C. We have a potential customer that wants to provide us a DLL written in C#. How can we call it's functions?
7
by: Staale L. Hansen | last post by:
We have an application which uses some mixed-mode code to expose a .NET 1.1 managed API. Only the necessary files are compiled with /clr. We want to be able to load the application without .NET...
1
by: Russell Mangel | last post by:
Sorry about the Cross-Post, I posted my question in the wrong group. Hello, What is the simplest way to create a dynamic collection (during run-time), using basic C (Struct data types). Since...
3
by: Mali Guven | last post by:
Hello, I have a native DLL (written in C) which is supposed to call a managed DLL (was written in C#, and an entry point was injected modifying the ildasm'd code). The exectuable calls the...
10
by: ajtaylor | last post by:
Hello, I have a load of native C++ code that I want to use in a CLR class library. My "logic" being that I create a C++/CLI managed class that acts as an interface to the unmanged code. I...
0
by: ElysianEagle | last post by:
Hi, I have a DLL written in C that creates a structure as a local variable, populates it, and then calls a function in managed c#. here is what im talking about: //-----unmanged code's header...
14
by: Mohamed Mansour | last post by:
Hey there, this will be somewhat a long post, but any response is appreciated! I have done many PInvoke in the past from C++ to C#, but I did PInvoke within C# not C++/CLI. Can someone explain...
3
by: Pixel.to.life | last post by:
All, A question on JIT debugging with VS2005. I have a managed app that builds great on one machine (Vista Home basic, VS2005, JIT enabled for managed/unmanaged code). I can also debug it...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.