Click here to Skip to main content
15,886,137 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: How can I create a short cut key any button in .net Pin
indian14328-Jan-07 23:27
indian14328-Jan-07 23:27 
QuestionExtending large project to Unix (Mono) Pin
Libor Tinka28-Jan-07 10:36
Libor Tinka28-Jan-07 10:36 
QuestionDetecting AxWebBrowser scroll bars Pin
the red baron27-Jan-07 20:37
the red baron27-Jan-07 20:37 
Questioncan any body tell me the code for customizing the crystal reports Pin
indian14326-Jan-07 18:30
indian14326-Jan-07 18:30 
Question.Net Reactor Pin
Glen Harvy26-Jan-07 13:55
Glen Harvy26-Jan-07 13:55 
Questionwebcam preview Pin
sini8725-Jan-07 12:15
sini8725-Jan-07 12:15 
AnswerRe: webcam preview Pin
Christian Graus26-Jan-07 10:51
protectorChristian Graus26-Jan-07 10:51 
Questionmanaged c++.net: allocating the memory for an array of struct in a coherent memory area Pin
HUMPPAAA!25-Jan-07 9:43
HUMPPAAA!25-Jan-07 9:43 
Hi,

first of all, plz excuse my rusty english Wink | ;)

I'm writing a little wrapper in c++ .net which allows me to access some old unmanaged win32 c++ dlls from a c# program.

There is one function in the dll which drives my crazy.

It wants an array of struct as an argument, called by reference.

Its code is looking like that (a bit simplified):
the struct in c++.net and in the dll code:
<br />
struct ParaList<br />
{<br />
  BYTE adress;<br />
  WORD length;<br />
};<br />


the dll function prototype (in the dll -> non c++.net):
<br />
BOOL RequestValues(ParaList list[], int listlength);<br />


I included it into my c++ .net like following code:
<br />
[DllImport("mydll.dll",EntryPoint="_RequestValues@12")]<br />
extern "C" bool_cdecl RequestValues(ParaList *list, int listlength); <br />


What it does is: I can request the values of some parameters by executing the RequestValues() function.
After that I can read the requested values by executing a readfunction().

I'm calling the function in managed c++.net like that:
<br />
ParaList list[8];<br />
list[0].adress = 0x1;<br />
list[0].length = 0x1;<br />
bool error = RequestValues(list, 1); //querying for one parameter value<br />

The problem now is: when the list only has one parameter (like in the example above) the function works correct. But when I request more than one parameter, the dll will put out some error.

In a c++ mfc example the dll is working correct!

I think the problem is related in the memory management of c++.net.
I'm pretty new to c++.net. Am I right that in managed c++.net the allocated memory for an array must not be in sequence? So the single elements of the array are distributed all over the memory?
In that case the dll would get only the pointer on the first array element but the second element is not the neighbour, so the dll reads garbage when it wants to read the data of the second array element.

I tried a few things with __pin and __nogc keywords which led to nothing Frown | :(

Does anyone have a clue how I can tell c++.net to allocate the memory for the array in a coherent memory area?

Thanks for reading this!
~Sepp
AnswerRe: managed c++.net: allocating the memory for an array of struct in a coherent memory area Pin
Christian Graus26-Jan-07 10:51
protectorChristian Graus26-Jan-07 10:51 
GeneralRe: managed c++.net: allocating the memory for an array of struct in a coherent memory area Pin
HUMPPAAA!31-Jan-07 23:25
HUMPPAAA!31-Jan-07 23:25 
GeneralRe: managed c++.net: allocating the memory for an array of struct in a coherent memory area Pin
Luc Pattyn1-Feb-07 1:56
sitebuilderLuc Pattyn1-Feb-07 1:56 
QuestionDataBinding the UI control to the array element ? Pin
Patrick Sky24-Jan-07 20:57
Patrick Sky24-Jan-07 20:57 
AnswerRe: DataBinding the UI control to the array element ? Pin
Patrick Sky24-Jan-07 21:02
Patrick Sky24-Jan-07 21:02 
QuestionSharing A Folder through WebApplication In .Net Pin
Nagaraju_Focus24-Jan-07 19:42
Nagaraju_Focus24-Jan-07 19:42 
Questionfrom .NET to src code (and all points between...) Pin
john john mackey24-Jan-07 8:22
john john mackey24-Jan-07 8:22 
AnswerRe: from .NET to src code (and all points between...) Pin
Pete O'Hanlon24-Jan-07 9:26
mvePete O'Hanlon24-Jan-07 9:26 
GeneralRe: from .NET to src code (and all points between...) Pin
john john mackey24-Jan-07 12:02
john john mackey24-Jan-07 12:02 
GeneralRe: from .NET to src code (and all points between...) Pin
Pete O'Hanlon24-Jan-07 22:36
mvePete O'Hanlon24-Jan-07 22:36 
GeneralRe: from .NET to src code (and all points between...) Pin
john john mackey26-Jan-07 10:14
john john mackey26-Jan-07 10:14 
AnswerRe: from .NET to src code (and all points between...) Pin
Guffa24-Jan-07 23:19
Guffa24-Jan-07 23:19 
QuestionCan I customize the paper size and print a crystal report Pin
indian14323-Jan-07 17:57
indian14323-Jan-07 17:57 
QuestionIs .Net 2.0 is backward compatible with .Net 1.1? Pin
Sunil Jampa23-Jan-07 17:17
Sunil Jampa23-Jan-07 17:17 
AnswerRe: Is .Net 2.0 is backward compatible with .Net 1.1? Pin
Christian Graus23-Jan-07 17:33
protectorChristian Graus23-Jan-07 17:33 
QuestionRe: Is .Net 2.0 is backward compatible with .Net 1.1? Pin
Sunil Jampa23-Jan-07 18:08
Sunil Jampa23-Jan-07 18:08 
AnswerRe: Is .Net 2.0 is backward compatible with .Net 1.1? Pin
Christian Graus23-Jan-07 18:16
protectorChristian Graus23-Jan-07 18:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.