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("spec ial.dll", CallingConventi on = CallingConventi on.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 3 17194
"Dick van der Sar" <d.******@hccne t.nl> wrote in message
news:fe******** *************** ***@posting.goo gle.com... 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("spec ial.dll", CallingConventi on = CallingConventi on.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.
Ok:
private void opendb()
{
ConnectServerAn dOpenDatabase(" NDBCN", "NAVISIONSERVER ", "tcp", "" ,
8000, true, false, "dick", "");
}
[DllImport("cfro nt.dll", CallingConventi on = CallingConventi on.Cdecl)]
private static extern void DBL_ConnectServ erAndOpenDataba se(string
NDBCDriverName, string ServerName, string NetType,
string DatabaseName, int CacheSize, bool UseCommitCache, bool
UseNTAuthentica tion, string UserID, string PassWord);
public void ConnectServerAn dOpenDatabase(s tring NDBCDriverName, string
ServerName, string NetType,
string DatabaseName, int CacheSize, bool UseCommitCache, bool
UseNTAuthentica tion, string UserID, string PassWord)
{
DBL_ConnectServ erAndOpenDataba se(NDBCDriverNa me, ServerName, NetType,
DatabaseName, CacheSize, UseCommitCache, UseNTAuthentica tion, 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 van der sar" <d.******@hccne t.nl> wrote in message
news:ef******** ******@TK2MSFTN GP09.phx.gbl... Ok:
private void opendb() { ConnectServerAn dOpenDatabase(" NDBCN", "NAVISIONSERVER ", "tcp", "" , 8000, true, false, "dick", ""); }
[DllImport("cfro nt.dll", CallingConventi on = CallingConventi on.Cdecl)] private static extern void DBL_ConnectServ erAndOpenDataba se(string NDBCDriverName, string ServerName, string NetType, string DatabaseName, int CacheSize, bool UseCommitCache, bool UseNTAuthentica tion, string UserID, string PassWord);
public void ConnectServerAn dOpenDatabase(s tring NDBCDriverName, string ServerName, string NetType, string DatabaseName, int CacheSize, bool UseCommitCache, bool UseNTAuthentica tion, string UserID, string PassWord) { DBL_ConnectServ erAndOpenDataba se(NDBCDriverNa me, ServerName, NetType, DatabaseName, CacheSize, UseCommitCache, UseNTAuthentica tion, 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 ... ConnectServerAn dOpenDatabase 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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: hiralparikh |
last post by:
Hi,
I am using .NET 2.0 and trying to use a function from a native DLL
file.
Here is the syntax that I am using:
definition:
public static extern String getPwd(String strServerName, String
strUserId);
|
by: XJ |
last post by:
Hi experts,
i try to use vb.net 2005 call dll, then give me "Attempted to
read or write protected memory.This is often an indication that other
memory is corrupt". i have chk some message others people posted, but
since still cannot, pls give me some commnet.(this dll run smoothly at
vb 6 )
module:
' example
Declare Function TwTsxInitPar...
|
by: ianyian |
last post by:
Hi experts,
i try to use vb.net 2005 call C++ dll, then give me "Attempted
to
read or write protected memory.This is often an indication that other
memory is corrupt". i have chk some message others people posted, but
since still cannot, pls give me some commnet.(this dll run smoothly at
vb 6 )
module:
' example
|
by: Ilkka |
last post by:
I have created an C++ application with Windows Forms, ADO and SQL server
2005. Now I need to change something and started debugging the code. Then
suddenly I receive an error.
"An unhandled exception of type 'System.AccessViolationException' occurred
in mscorlib.dll
Additional information: Attempted to read or write protected memory. This...
|
by: Pieter |
last post by:
Hi,
Since 10 days (the first time was the 10th of november) I have some weird
exception happening in an application here:
All (except 1 of the total of 5) users had this error now 1 of 2 times
during the last 10 days. It happens mostly during startup or closing of the
application, but sometimes just in the middle of nowhere. It doesn't...
| |
by: adypoly |
last post by:
Hi guys...
I am having a typical problem in using one of the native dll in C#
I'll explain what am trying to do, I've a dll written in C language which i am trying to include in my C# project, the solutions builds fine but once i try to run the program it gives an exception as "Attempted to read or write protected memory. This is often an...
|
by: Sugandh Jain |
last post by:
Hi,
I am getting the error message
Attempted to read or write protected memory. This is often an indication
that other memory is corrupt.
It was not coming until yet, for around 2 months. Now, may be the records
have increased and so i am getting this.
anyone has any idea why and when do we get this.
Its a windows based application with...
|
by: ssk |
last post by:
I am accessing a Fortran dll in .NET 2.0 (C#). The dll has 2 methods with the same signature. The call to method1 is successful but the call to method2 throws the following exception:
"Attempted to read or write protected memory. This is often an indication that other memory has been corrupted."
Any idea?
|
by: Scott Gravenhorst |
last post by:
Windows XP SP3
My application is set to open a SaveFile dialog when an exit is
requested. When I click the app's close button, the save dialog
opens, but when I click to change the folder, the exception occurs
pointing to FileSaveDialog1.ShowDialog(). The exception also
indicates some problem with system.drawing.dll.
The exception text...
|
by: sriram347 |
last post by:
Hi
I am a newbie to ASP.NET. I developed a web page (project type is web application) and I keep getting this error.
B]Error message :
"System.AccessViolation Exception attempted to read or write protected memory. this is often an indication that other memory is corrupt.... "
These are all the platform info :
Visual Studio 2005...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |