PC Review


Reply
Thread Tools Rate Thread

Attempted to read or write protected memory. This is often an indication that other memory has been corrupted.

 
 
Dick van der Sar
Guest
Posts: n/a
 
      2nd May 2005
I access a dll via dllimport (see below). It workes fine at framework
version 1.1 but now I try to run it in the Beta 1 of VS 2005 and I get
this error message. I have only this problem if a use this function in
a web project.
If I make a standard windows program: no problem.

[DllImport("special.dll", CallingConvention = CallingConvention.Cdecl
)]
private static extern void specialfunction(string name, ....);

Remark:

If I use it in a web project I have to access it via a thread, strange
but it workes.


Has someone an idea?

Dick van der Sar
 
Reply With Quote
 
 
 
 
Willy Denoyette [MVP]
Guest
Posts: n/a
 
      2nd May 2005

"Dick van der Sar" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I access a dll via dllimport (see below). It workes fine at framework
> version 1.1 but now I try to run it in the Beta 1 of VS 2005 and I get
> this error message. I have only this problem if a use this function in
> a web project.
> If I make a standard windows program: no problem.
>
> [DllImport("special.dll", CallingConvention = CallingConvention.Cdecl
> )]
> private static extern void specialfunction(string name, ....);
>
> Remark:
>
> If I use it in a web project I have to access it via a thread, strange
> but it workes.
>
>
> Has someone an idea?
>
> Dick van der Sar



Please post the whole DllImport function declaration and the C function
export declaration.
Make sure the calling convention is cdecl. Point is that you are passing a
wrong pointer or that are messing with the stack, what would explain why it
works from a separate thread.

Willy.



 
Reply With Quote
 
dick van der sar
Guest
Posts: n/a
 
      3rd May 2005

Ok:

private void opendb()
{
ConnectServerAndOpenDatabase("NDBCN", "NAVISIONSERVER", "tcp", "" ,
8000, true, false, "dick", "");
}

[DllImport("cfront.dll", CallingConvention = CallingConvention.Cdecl)]
private static extern void DBL_ConnectServerAndOpenDatabase(string
NDBCDriverName, string ServerName, string NetType,
string DatabaseName, int CacheSize, bool UseCommitCache, bool
UseNTAuthentication, string UserID, string PassWord);

public void ConnectServerAndOpenDatabase(string NDBCDriverName, string
ServerName, string NetType,
string DatabaseName, int CacheSize, bool UseCommitCache, bool
UseNTAuthentication, string UserID, string PassWord)
{
DBL_ConnectServerAndOpenDatabase(NDBCDriverName, ServerName, NetType,
DatabaseName, CacheSize, UseCommitCache, UseNTAuthentication, UserID,
PassWord);
}


Willy: Can you also explain that you understand "what would explain why
it works from a separate thread."?

Dick


*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
Willy Denoyette [MVP]
Guest
Posts: n/a
 
      3rd May 2005

"dick van der sar" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> Ok:
>
> private void opendb()
> {
> ConnectServerAndOpenDatabase("NDBCN", "NAVISIONSERVER", "tcp", "" ,
> 8000, true, false, "dick", "");
> }
>
> [DllImport("cfront.dll", CallingConvention = CallingConvention.Cdecl)]
> private static extern void DBL_ConnectServerAndOpenDatabase(string
> NDBCDriverName, string ServerName, string NetType,
> string DatabaseName, int CacheSize, bool UseCommitCache, bool
> UseNTAuthentication, string UserID, string PassWord);
>
> public void ConnectServerAndOpenDatabase(string NDBCDriverName, string
> ServerName, string NetType,
> string DatabaseName, int CacheSize, bool UseCommitCache, bool
> UseNTAuthentication, string UserID, string PassWord)
> {
> DBL_ConnectServerAndOpenDatabase(NDBCDriverName, ServerName, NetType,
> DatabaseName, CacheSize, UseCommitCache, UseNTAuthentication, UserID,
> PassWord);
> }
>
>
> Willy: Can you also explain that you understand "what would explain why
> it works from a separate thread."?
>
> Dick
>
>
> *** Sent via Developersdex http://www.developersdex.com ***


Dick,

This is good but not yet enough, we need the C function declaration too,
preferably from the header file or from the documentation. Most notably we
need to know what is expected as string and bool.

When you run just this ... ConnectServerAndOpenDatabase on a separate
thread, it might work even if you corrupt the stack, each thread has his own
stack, so when the thread proc returns it's stack is removed anyway.

Willy.



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Attempted to read or write protected memory. This is often an indication that other memory is corrupt www.gusse.net Microsoft Dot NET Framework 10 7th Sep 2009 07:06 PM
Attempted to read or write protected memory. This is often an indication that other memory is corrup Lee Mellinger Microsoft Dot NET Framework Forms 0 20th Dec 2007 06:09 PM
Attempted to read or write protected memory. This is often an indication that other memory is corrupt Sugandh Jain Microsoft C# .NET 6 10th Dec 2007 08:47 PM
Attempted to read or write protected memory. This is often an indication that other memory is corrup Sanjeev Rane Microsoft VB .NET 0 12th Dec 2006 10:06 AM
Attempted to read or write protected memory. This is often an indication that other memory is corrupt. Dhruba Bandopadhyay Microsoft ASP .NET 0 12th May 2006 02:24 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:33 PM.