[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.interop

AccessViolationException Occurred

Mehul Gurjar

6/14/2007 12:28:00 PM

Hello,

I am trying to call an API Function (API is written in C Language). On a
particular function I am getting an exception

"AccessViolationException was unhandled by user... Attempted to read or
write protected memory. This is often an indication that other memory is
corrupt."

Can anyone please help me to resolve this problem ?


With regards,

Mehul Gurjar

4 Answers

(Mattias Sjögren)

6/14/2007 8:32:00 PM

0


>Can anyone please help me to resolve this problem ?

Only if you post relevant parts of your code.


Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.n... | http://www.dotneti...
Please reply only to the newsgroup.

Mehul Gurjar

6/15/2007 12:59:00 PM

0

Hi Marttis,

Pls check the code as follows. I am getting the error when I am passing
parameters to the native API Function

public int MyFunction(int vi1, int vi2, string vs3, ref int ri4, ref int
rl5) {
return nativeAPIFunction(vi1, vi2, vs3, ref ri4, ref rl5);
}

With regards,



"Mattias Sjögren" <mattias.dont.want.spam@mvps.org> wrote in message
news:OLwncMsrHHA.1476@TK2MSFTNGP06.phx.gbl...
>
>>Can anyone please help me to resolve this problem ?
>
> Only if you post relevant parts of your code.
>
>
> Mattias
>
> --
> Mattias Sjögren [C# MVP] mattias @ mvps.org
> http://www.msjogren.n... | http://www.dotneti...
> Please reply only to the newsgroup.

Ben Voigt [C++ MVP]

6/15/2007 8:29:00 PM

0


"Mehul Gurjar" <mehul.gurjar@hotmail.com> wrote in message
news:880DEDC4-EB2B-42E9-9EDA-70CD6BE5BF72@microsoft.com...
> Hello,
>
> I am trying to call an API Function (API is written in C Language). On a
> particular function I am getting an exception
>
> "AccessViolationException was unhandled by user... Attempted to read or
> write protected memory. This is often an indication that other memory is
> corrupt."

The API has a bug, or you sent a bad pointer.

>
> Can anyone please help me to resolve this problem ?
>
>
> With regards,
>
> Mehul Gurjar

(Mattias Sjögren)

6/16/2007 11:42:00 AM

0

>public int MyFunction(int vi1, int vi2, string vs3, ref int ri4, ref int
>rl5) {
> return nativeAPIFunction(vi1, vi2, vs3, ref ri4, ref rl5);
> }


We really need to see the C side too. At least the function signature.
If you have the implementation or working calling code in some other
language that may help as well.


Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.n... | http://www.dotneti...
Please reply only to the newsgroup.