472,368 Members | 2,541 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,368 software developers and data experts.

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 TwTsxParSetMaxTermLid 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(btsxpar(0), UBound(btsxpar) + 1)
<== msg popup PIvokeStackbalance was detected
vtek.lRv = TwTsxParSetMaxTermLid(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 11849
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.googlegr oups.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 TwTsxParSetMaxTermLid 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(btsxpar(0), UBound(btsxpar) + 1)
<== msg popup PIvokeStackbalance was detected
vtek.lRv = TwTsxParSetMaxTermLid(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 TwTsxParSetMaxTermLid 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 TwTsxParSetMaxTermLid 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 TwTsxParSetMaxTermLid 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 TwTsxParSetMaxTermLid 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
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...
1
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...
2
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...
2
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...
1
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...
1
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...
2
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,...
6
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...
3
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...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.

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.