473,413 Members | 1,727 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,413 software developers and data experts.

gcroot crashes in DLL

I have a DLL with vanilla C functions implemented. I'd like these functions
to become wrappers for a managed object. So, I was thinking that the first
call would save a pointer statically to the managed object that future calls
could use. I found this:
http://msdn.microsoft.com/library/de...omixedmode.asp
and have implemented it to make sure the runtime is initialized. Now I have
strangeness. If I allocate the gcroot object on the stack, it works. If I
allocate the gcroot object on the heap or statically, I get exceptions.
static gcroot<GCPO::POAddr*> addr; // #1

int po_open()
{
addr = new GCPO::POAddr; // this crashes with
System.NullReferenceException in my dll

gcroot<GCPO::POAddr*> addr1;
addr1 = new GCPO::POAddr; // This WORKS

gcroot<GCPO::POAddr*>* addr2;
addr2 = new gcroot<GCPO::POAddr*>; // this crashes with
System.ExecutionEngineException in Unknown Module.
return 0;
}
Nov 17 '05 #1
0 1449

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: igal.ioffe | last post by:
Hi All, I've run into a problem, converting a native project into mixed mode, where usage of gcroot point in mixed mode causes a fatal CLR engine exception. Here is a tiny code extract:...
2
by: Steve McLellan | last post by:
Hi, I see that GCHandle can encapsulate a weak reference, but gcroot appears to only allow 'normal' GCHandles. Is this correct or is there something I've missed? Ta, Steve
5
by: Gerhard Menzl | last post by:
Has anyone ever tried to sort a Standard Library container of gcroots? I have run into the problem that somewhere deep in the Library logic (in line 338 of <memory>, to be precise) the destructor...
2
by: Dave | last post by:
I have a few C# .NET components which might implement one or several interfaces, let say I1, I2 and I3. The unmanaged C++ client consumes this component using gcroot template pointer. How...
2
by: Maxwell | last post by:
Hello, Im using MC++ VS.NET 2003 and am quite confused with with gcroot template and its use. The issue I am confused about is the need to (or not) delete a pointer to a managed object that you...
4
by: John | last post by:
I'm having a major problem trying to use value types like System::Drawing::Rectangle with std::vector. Is it possible to use STL containers with these type of objects, or am I just doing something...
6
by: =?Utf-8?B?QWw=?= | last post by:
I am storing an array of strings in an unmanaged MFC class using gcroot as follows: gcroot<array<System::String^>^m_pArr; Nothing out of the ordinary there. However, if I try to use "delete...
6
by: =?Utf-8?B?RmFiaWFu?= | last post by:
Hello, I have a class hierarchy distributed over 3 native C++ dlls. The base class has a .NET Windows.Form for status output via a gcroot<>. The gcroot is declared private - the sub classes only...
6
by: Bob Altman | last post by:
Hi all, In C++/CLI (VS 2005) I have a C++ module compiled with /clr that contains a module-level gcroot variable: static gcroot<MyList^m_myList = gcnew MyList; In the above statement,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.