473,666 Members | 1,977 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 11933
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
21332
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
3165
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
21970
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
4178
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
1703
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
4004
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
20715
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
4486
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
6928
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
8445
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
8356
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8551
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
8640
tracyyun
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6198
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
5664
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2771
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
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1776
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.