tags:

views:

135

answers:

3
+1  A: 

If the IntPtr result parameter is to receive the value from within the function, it must be marked ref.

I don't see ptrs[1] being assigned any value before passing.

Try changing the definition to:

[DllImport("Padeg.dll", EntryPoint = "GetNominativePadeg")]
private static extern Int32 decGetNominativePadeg(IntPtr surnameNamePatronimic,
    **ref** IntPtr result, ref Int32 resultLength);

The reason probably is that it's trying to write to "result" which is marked as input-only.

MasterGaurav
It is assigned by StringsToIntPtrArray function
StuffHappens
But decGet... method is called before that!
MasterGaurav
A: 

Hello, you have probably turned off debugging of unmanaged code.

"Enable unmanaged code debugging option" must be check in project properties under the Debug section. After this, the exception is shown in the debugging process.

Wodzu
It's turned on.
StuffHappens
A: 

Problem solved. I found out that when using 4-th framework I have this problem, when using 3.5 - I don't.

StuffHappens
You mean you've found a solution, not that you've solved the problem... Do you know what the root problem was?
Ian
No I don't. I used this external unmanaged dll for a long period of time with no problem. Then I decided to add some Parallels fitures into my project, built it under .Net 4.0 framework and after that I started to get this error. Reraly actually, not always. Now I'm under 3.5 framework again and everything is fine.
StuffHappens