Click here to Skip to main content
16,006,594 members
Home / Discussions / C#
   

C#

 
GeneralRe: Plsssssssss read the first message in the forum Pin
BadKarma14-Feb-08 9:29
BadKarma14-Feb-08 9:29 
GeneralRe: Plsssssssss read the first message in the forum Pin
Guffa14-Feb-08 11:19
Guffa14-Feb-08 11:19 
GeneralSliding Form Pin
padz14-Feb-08 8:05
padz14-Feb-08 8:05 
GeneralRe: Sliding Form Pin
led mike14-Feb-08 9:08
led mike14-Feb-08 9:08 
GeneralRe: Sliding Form [modified] Pin
padz14-Feb-08 12:41
padz14-Feb-08 12:41 
GeneralRe: Sliding Form Pin
Expert Coming14-Feb-08 15:43
Expert Coming14-Feb-08 15:43 
GeneralRe: Sliding Form Pin
padz14-Feb-08 15:55
padz14-Feb-08 15:55 
Questionproblem with interoperability Pin
jm2514-Feb-08 7:30
jm2514-Feb-08 7:30 
Hi, I'm relatively new to C# (C++/C/Java background) and I'm having a difficult time getting through an interop issue. I'm attempting to call a function located in a native C++ dll, but the following exception is thrown:

"Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

I suspect I am handling the byte * wrong. I have tried several things including marshaling, but all yield the same result. Any help would be greatly appreciated. Here is the relevant information.

C++ declaration (within a dll):

int foo(const BYTE *a, int b)

My C# declaration:

[DllImport("bar.dll", EntryPoint = "foo", CharSet = CharSet.Auto)]
public static extern unsafe int foo(byte* a, int b);

The relevant code:

// taken from a function declared unsafe

int ret;
byte[] buffer;
buff = new byte[20];

// ... fill the buffer with stuff ...

fixed (byte* bPtr = buff)
{
// the following line causes the exception
ret = foo(bPtr, buff.Length);
}

Thanks again,

-J
GeneralRe: problem with interoperability Pin
Skippums14-Feb-08 12:22
Skippums14-Feb-08 12:22 
QuestionWM_CONTEXTMENU ? Pin
god4k14-Feb-08 7:24
god4k14-Feb-08 7:24 
AnswerRe: WM_CONTEXTMENU ? Pin
new2pgrmg14-Feb-08 23:36
new2pgrmg14-Feb-08 23:36 
QuestionThread-safetiness of XmlSerializer Pin
Le centriste14-Feb-08 4:43
Le centriste14-Feb-08 4:43 
GeneralRe: Thread-safetiness of XmlSerializer Pin
Martin#14-Feb-08 5:18
Martin#14-Feb-08 5:18 
GeneralRe: Thread-safetiness of XmlSerializer Pin
led mike14-Feb-08 5:50
led mike14-Feb-08 5:50 
GeneralRe: Thread-safetiness of XmlSerializer Pin
Le centriste14-Feb-08 6:02
Le centriste14-Feb-08 6:02 
GeneralRe: Thread-safetiness of XmlSerializer Pin
led mike14-Feb-08 8:34
led mike14-Feb-08 8:34 
GeneralRe: Thread-safetiness of XmlSerializer Pin
Le centriste14-Feb-08 8:40
Le centriste14-Feb-08 8:40 
GeneralRe: Thread-safetiness of XmlSerializer Pin
led mike14-Feb-08 9:03
led mike14-Feb-08 9:03 
GeneralRe: Thread-safetiness of XmlSerializer Pin
Le centriste14-Feb-08 9:11
Le centriste14-Feb-08 9:11 
GeneralRe: Thread-safetiness of XmlSerializer Pin
led mike14-Feb-08 9:21
led mike14-Feb-08 9:21 
GeneralRe: Thread-safetiness of XmlSerializer Pin
Le centriste14-Feb-08 9:25
Le centriste14-Feb-08 9:25 
GeneralGraph excel with C# Pin
JeremH14-Feb-08 4:34
JeremH14-Feb-08 4:34 
GeneralRe: Graph excel with C# Pin
Cwenee23-Sep-09 5:17
Cwenee23-Sep-09 5:17 
GeneralLoadProperties Pin
s3rro14-Feb-08 4:04
s3rro14-Feb-08 4:04 
GeneralRe: LoadProperties Pin
s3rro14-Feb-08 4:09
s3rro14-Feb-08 4:09 

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.