gcroot and ArrayList
-
Hello, this question may come from a very wrong approach:wtf:, feel free to suggest a better way to solve this :-D I want to store a global dynamic list of structs inside a managed code dll. First I create the array list
gcrootSystem::Collections::ArrayList\* parameters;
parameters=new System::Collections::ArrayList();But i get a very weired exception during runtime:
Handle has not been initialized
when creating the ArrayList. How can I initialize this variable the correct way? Thx for your time.. -
Hello, this question may come from a very wrong approach:wtf:, feel free to suggest a better way to solve this :-D I want to store a global dynamic list of structs inside a managed code dll. First I create the array list
gcrootSystem::Collections::ArrayList\* parameters;
parameters=new System::Collections::ArrayList();But i get a very weired exception during runtime:
Handle has not been initialized
when creating the ArrayList. How can I initialize this variable the correct way? Thx for your time..Is that code verbatim? If so, shoiuldn't you be using gcnew instead of new? (__gc new in managed extensions) Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
Is that code verbatim? If so, shoiuldn't you be using gcnew instead of new? (__gc new in managed extensions) Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
Thank you for the answer, I'm fairly new to this topic (gcroot). This is the new code according to your suggestion.
parameters=__gc new System::Collections::ArrayList();
But still, the same exception is raised when I try to create the ArrayList... Any idea? :-D -
Thank you for the answer, I'm fairly new to this topic (gcroot). This is the new code according to your suggestion.
parameters=__gc new System::Collections::ArrayList();
But still, the same exception is raised when I try to create the ArrayList... Any idea? :-Dhmmm it worked for me on VS2005... Where is this code located? The gcroot<> line is at global scope - outside of any method/function, right? What about the parameters= line? Where's that at? Where does the exception get thrown? Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
hmmm it worked for me on VS2005... Where is this code located? The gcroot<> line is at global scope - outside of any method/function, right? What about the parameters= line? Where's that at? Where does the exception get thrown? Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
Yes, the gcroot<> line is at global scope. I wrote an ManagedCode-DLL based on a .NET-Assembly that is dynamically linked by a standard MFC application. The gcroot variable is created during DLL initialization (called via a procedure). Hopefully this will help you.. Currently I am working on a different approach (linked list class) to solve my problem. This seems to be the best solution as gcroot more like a "dirty" fix for something that can be solved in a more correct way, i suppose. ;) Thanks for your time