473,743 Members | 2,243 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Attempted to read or write protected memory. dll vs vb 2005

XJ
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 Lib "TSDKVC.DLL " _
(ByRef tsxparptr As Byte, ByVal asize As Long) As Long
Declare Function TwTsxParSetMaxT ermLid Lib "TSDKVC.DLL " _
(ByRef tsxparptr As Byte, ByVal maxtermlid As Long) As Long

public sub run()
dim btsxpar(1024) As Byte
dim lnTerm as long

vtek.lRv = TwTsxInitPar(bt sxpar(0), UBound(btsxpar) + 1)
<== msg popup PIvokeStackbala nce was detected
vtek.lRv = TwTsxParSetMaxT ermLid(btsxpar( 0), lnTerm) <==
give same msg
............
end sub

after run the program ( console ) give
"Attempted to read or write protected memory.This is often an
indication that other memory is corrupt"

pls give advise, bcos i really have no any idea( vb6 can work )
many thanks

Jun 3 '06 #1
3 11940
XJ,

Are you sure it should be Long. A VB6 Long is a VBNet Int32.

To be real, I think that it is your problem.

I hope this helps,

Cor

"XJ" <ia*****@gmail. com> schreef in bericht
news:11******** **************@ h76g2000cwa.goo glegroups.com.. .
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 Lib "TSDKVC.DLL " _
(ByRef tsxparptr As Byte, ByVal asize As Long) As Long
Declare Function TwTsxParSetMaxT ermLid Lib "TSDKVC.DLL " _
(ByRef tsxparptr As Byte, ByVal maxtermlid As Long) As Long

public sub run()
dim btsxpar(1024) As Byte
dim lnTerm as long

vtek.lRv = TwTsxInitPar(bt sxpar(0), UBound(btsxpar) + 1)
<== msg popup PIvokeStackbala nce was detected
vtek.lRv = TwTsxParSetMaxT ermLid(btsxpar( 0), lnTerm) <==
give same msg
............
end sub

after run the program ( console ) give
"Attempted to read or write protected memory.This is often an
indication that other memory is corrupt"

pls give advise, bcos i really have no any idea( vb6 can work )
many thanks

Jun 3 '06 #2
"XJ" <ia*****@gmail. com> schrieb:
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 Lib "TSDKVC.DLL " _
(ByRef tsxparptr As Byte, ByVal asize As Long) As Long
Declare Function TwTsxParSetMaxT ermLid Lib "TSDKVC.DLL " _
(ByRef tsxparptr As Byte, ByVal maxtermlid As Long) As Long
Try these declarations:

\\\
Private Declare Function TwTsxInitPar Lib "TSDKVC.DLL " ( _
ByRef tsxparptr As Byte, _
ByVal asize As Int32 _
) As Int32

Private Declare Function TwTsxParSetMaxT ermLid Lib "TSDKVC.DLL " ( _
ByRef tsxparptr As Byte, _
ByVal maxtermlid As Int32 _
) As Int32
///
dim btsxpar(1024) As Byte
Note that this will create an array with 1025 elements with indices 0
through 1024.
dim lnTerm as long


=> 'As Int32' or 'As Integer'.

If this doesn't solve the problem, I suggest to post the C/C++ function
prototypes.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jun 3 '06 #3
XJ
thanks advise ! appreciate

Herfried K. Wagner [MVP] wrote:
"XJ" <ia*****@gmail. com> schrieb:
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 Lib "TSDKVC.DLL " _
(ByRef tsxparptr As Byte, ByVal asize As Long) As Long
Declare Function TwTsxParSetMaxT ermLid Lib "TSDKVC.DLL " _
(ByRef tsxparptr As Byte, ByVal maxtermlid As Long) As Long


Try these declarations:

\\\
Private Declare Function TwTsxInitPar Lib "TSDKVC.DLL " ( _
ByRef tsxparptr As Byte, _
ByVal asize As Int32 _
) As Int32

Private Declare Function TwTsxParSetMaxT ermLid Lib "TSDKVC.DLL " ( _
ByRef tsxparptr As Byte, _
ByVal maxtermlid As Int32 _
) As Int32
///
dim btsxpar(1024) As Byte


Note that this will create an array with 1025 elements with indices 0
through 1024.
dim lnTerm as long


=> 'As Int32' or 'As Integer'.

If this doesn't solve the problem, I suggest to post the C/C++ function
prototypes.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>


Jun 5 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
21349
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);
1
3172
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
2
21977
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 is often an indication that other memory is corrupt." The progran ends on a windows form designer...
2
4185
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 point to anyting special. I don't get a clue... It's a Windows Forms VB.NET 2005 application. I roll...
1
1707
by: =?Utf-8?B?QmFkaXM=?= | last post by:
Hi, I'm using automation to produce word documents, and it's working fine in my machine that have vs.net 2005 and office xp in it. BUT when I move my application to another machine that have vs.net 2005 express edition with office 97 I'm getting this error: "Attempted to read or write protected memory. This is often an indication that other memory is corrupt." when it comes to the second line of this code :
1
4010
by: =?Utf-8?B?QmFkaXM=?= | last post by:
Hi, I'm using automation to produce word documents, and it's working fine in my machine that have vs.net 2005 and office xp in it. BUT when I move my application to another machine that have vs.net 2005 express edition with office 97 I'm getting this error: "Attempted to read or write protected memory. This is often an indication that other memory is corrupt." when it comes to the second line of this code :
2
20733
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 indication that other memory is corrupt" I am passing two integer pointer variables as the...
6
4499
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 is: "Attempted to read or write protected memory. This is often an
3
6946
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 (VB.NET) and ASP.NET 2.0.
0
8970
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9486
Oralloy
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9344
jinu1996
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9277
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8218
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6763
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4572
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3286
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2195
bsmnconsultancy
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.