Click here to Skip to main content
15,921,577 members
Home / Discussions / C#
   

C#

 
AnswerRe: Encrypting the password Pin
Mark Greenwood6-Jun-07 19:36
Mark Greenwood6-Jun-07 19:36 
GeneralRe: Encrypting the password Pin
M. J. Jaya Chitra6-Jun-07 19:58
M. J. Jaya Chitra6-Jun-07 19:58 
GeneralRe: Encrypting the password Pin
andre_swnpl6-Jun-07 20:00
andre_swnpl6-Jun-07 20:00 
GeneralRe: Encrypting the password Pin
M. J. Jaya Chitra8-Jun-07 0:21
M. J. Jaya Chitra8-Jun-07 0:21 
QuestionReturning nested objects through WCF service Pin
Ravi Bhavnani6-Jun-07 17:44
professionalRavi Bhavnani6-Jun-07 17:44 
AnswerRe: Returning nested objects through WCF service Pin
Horia Tudosie7-Jun-07 3:27
Horia Tudosie7-Jun-07 3:27 
GeneralRe: Returning nested objects through WCF service Pin
Ravi Bhavnani7-Jun-07 4:49
professionalRavi Bhavnani7-Jun-07 4:49 
QuestionAn issue with 'parameter wiring' Pin
jozsurf6-Jun-07 17:30
jozsurf6-Jun-07 17:30 
Hi all,

I've been stuck for the last two days on quite a strange problem. Here's what's happening: I'm calling a C++ function defined in some dll. Some of the parameters in the function are defined as 'out'. The problem that I am facing is with the out parameters, some of the data is 'lost' in transition.

Perhaps some code will help. The following is the C# wrapper function:

[DllImport("SomeDll.dll", EntryPoint = "SomeFunction")]<br />
      private static extern bool SomeFunction(<br />
         [MarshalAs(UnmanagedType.LPStr)] string str1,<br />
         [MarshalAs(UnmanagedType.LPStr)] string str2,<br />
         [MarshalAs(UnmanagedType.LPStr)] string str3,<br />
         [MarshalAs(UnmanagedType.LPStr)] string str4,<br />
         long longNum,<br />
         out SomeStruct dataStruct,<br />
         out int int1,<br />
         out int int2);<br />


And this is the prototype of the C++ function that is being called:

BOOL SomeFunction(<br />
  const char* str1,<br />
  const char* str2,<br />
  const char* str3,<br />
  const char* str4,<br />
  const long  longNum,           <br />
  SomeStruct* dataStruct,<br />
  int& int1,<br />
  int& int2)<br />


When I step through the C# code, I find that the dataStruct structure is returned as 'null' (i.e. all values zeroed). The value of int2 is being returned correctly but in the 'position' of int1. The int2 that is returned is unchanged from before the function was invoked. I.e. if I expect to get 5000 from int2, int1 would instead give me that value of 5000 and int2 would be unchanged.

When I step through the C++ code, I find that the dataStruct structure is being received as null from the C# caller but the two ints are set to the correct values before the routine finishes.

The four strings and the long are passed in without any problems.

Based on what I see with the null structure (it should not be observed as being null on the C++ side as it had already been allocated some memory in the C# side of things) and the strange behaviour of int1 and int2, my guess is that the problem lies in how the parameters are being 'wired up'. Unfortunately, I can't see where I've screwed up (the SomeStruct structure is used in other routines in almost exactly the same way and works fine there).

Would appreciate any ideas/comments.

cheers!
AnswerRe: An issue with 'parameter wiring' Pin
Luc Pattyn7-Jun-07 0:12
sitebuilderLuc Pattyn7-Jun-07 0:12 
GeneralRe: An issue with 'parameter wiring' Pin
jozsurf7-Jun-07 16:50
jozsurf7-Jun-07 16:50 
GeneralRe: An issue with 'parameter wiring' Pin
Luc Pattyn7-Jun-07 20:12
sitebuilderLuc Pattyn7-Jun-07 20:12 
GeneralRe: An issue with 'parameter wiring' Pin
jozsurf12-Jun-07 15:40
jozsurf12-Jun-07 15:40 
GeneralRe: An issue with 'parameter wiring' Pin
Luc Pattyn12-Jun-07 15:48
sitebuilderLuc Pattyn12-Jun-07 15:48 
QuestionCustom Image in MessageBox.Show Pin
orly00136-Jun-07 16:31
orly00136-Jun-07 16:31 
AnswerRe: Custom Image in MessageBox.Show Pin
Christian Graus6-Jun-07 16:44
protectorChristian Graus6-Jun-07 16:44 
AnswerRe: Custom Image in MessageBox.Show Pin
Ravi Bhavnani6-Jun-07 20:24
professionalRavi Bhavnani6-Jun-07 20:24 
AnswerRe: Custom Image in MessageBox.Show Pin
Chintan.Desai7-Jun-07 0:23
Chintan.Desai7-Jun-07 0:23 
Questiondatabase connection Pin
fijian6-Jun-07 14:41
fijian6-Jun-07 14:41 
AnswerRe: database connection Pin
Harini N K6-Jun-07 18:36
Harini N K6-Jun-07 18:36 
QuestionHello Is theres away to convert GraphicsPath to Image ? Pin
Epsilone36-Jun-07 12:58
Epsilone36-Jun-07 12:58 
AnswerRe: Hello Is theres away to convert GraphicsPath to Image ? Pin
Christian Graus6-Jun-07 13:39
protectorChristian Graus6-Jun-07 13:39 
QuestionBrowsing a .dll file. Pin
Ylno6-Jun-07 12:21
Ylno6-Jun-07 12:21 
AnswerRe: Browsing a .dll file. Pin
Christian Graus6-Jun-07 12:36
protectorChristian Graus6-Jun-07 12:36 
GeneralRe: Browsing a .dll file. Pin
Ylno6-Jun-07 12:44
Ylno6-Jun-07 12:44 
GeneralRe: Browsing a .dll file. Pin
Christian Graus6-Jun-07 13:43
protectorChristian Graus6-Jun-07 13:43 

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.