Link to home
Start Free TrialLog in
Avatar of Finch
Finch

asked on

How do I create a 2-dimensional Array in a fixed location (on the stack?) so it can be passed to a DLL in "unsafe" mode.

I need to create a 2-dimensional array of bytes (byte[,] bfrArray) in my main C# project but I need it in a fixed location so I can pass it to a DLL that is written in C++ and is built as "unsafe". So I guess there are two questions: (a) How do I create the array, (b) how do I get it marshalled through tho the unsafe DLL.

I am writing the main project in C# and the DLL is in C++ (it is legacy code).  Both projects are devloped in Visual Studio 2005.
Avatar of bramsquad
bramsquad
Flag of United States of America image

i dont know if creating your project in its own location is what you want.  check this post out...

http://archives.neohapsis.com/archives/microsoft/various/dcom/2001-q3/0279.html

pretty much what it says, is that every instance of the com object that is created is created in its own address space.  therefore you wont have any of your global/static variables being accessed by more than one thread.

how do you do this?

not quite sure, but this should get you started (or other experts thinking)

~b
Avatar of Finch
Finch

ASKER

I'm not trying to create a project in it's own space.  I'm trying to create an array in a fixed location that does not get moved around do to garbage collection or any other OS function.
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial