Re: vb 6.0 naar vb.net 2005

Tech-Archive recommends: Fix windows errors by optimizing your registry



Hallo,

I'm trying to open a program which is originally written in vb6.0, in
vb.net 2005.
When i try to run the program an error occurs. My guess is that the
problem lies in the fact that the type of adressing the memory is
changed. Therefor the translation to vb.net of the declaration of the
variables isn't correct.

perhaps its best that I will explain my program a liltle bit.

I am supposed to write a vb.net 2005 application that allows
communication between a PC (master) and a plc (slave) true the modbus
protocol with a rs232 cable.

The PC has to be able to read- write data to the plc and show it in the
program. Since the read and write error are the same I will explain the
read error.

So the basic idea is: From my main form ( where i can enter the mode
(read or write), the starting adres, number of registers i want to
read) a module is being called up (i send the mode, number of register,
starting register and such also to the module).

In this module a DLL is being called up (and again the mode, number of
register, starting register and such is send to the dll aswell) the dll
is in the system32 directory. The dll will then use the data from the
starting register, number of register to form a good modbus protocol
message.

code to enter the module with the appropriat declarations:

Private Sub ReadShort_Click(ByVal eventSender As System.Object, ByVal
eventArgs As System.EventArgs) Handles ReadShort.Click
Dim BusState As Integer ' Een aantal shorts van de HPC lezen
Dim handle, j As Integer
Dim Ready As Boolean
Dim Address As TBusAddress
Dim Data As TShortData

MBRead( handle, j, 1,
mbShort,CShort(Startadress.Text),Short(numberofRegisters.Text) )

This will call up the module and go to the function MBread

Declare Function MBRead Lib "Modbus" Alias "VBMBReadRequest" (ByRef
handle As Integer, ByVal UserData As Integer, ByVal NodeNr As Short,
ByVal VarType As Short, ByVal StartAddress As Short, ByVal Count As
Short) As Short

This function forms the request that is send to the PLC, so far so
good.

Now the plc send a message back (which he actually sends, so that aint
the problem) which I will catch with the function

Ready = MBGetShorts(handle, j, BusState, Address, Data) <= is in the
main form

Again the module is being called up.

Declare Function MBGetShorts Lib "Modbus" Alias "VBMBGetShortResults"
(ByVal MBHandle As Long, ByRef UserData As Long, ByRef BusState As
Integer, ByRef Address As TBusAddress, ByRef Data As TShortData) As
Boolean

The function MBgetShorts catches the response from the plc and puts the
register data in the DATA aray. But from here it goes bad.

At the line "Ready = MBGetShorts(handle, j, BusState, Address, Data)"
the program stops and shows the error.

FATALEXECUTIONERROR:
error may be a bug in the CLR or in the unsafe or non-verifiable
portions of user code. Common sources of this bug include user
marshaling errors for COM-interop or PInvoke, which may corrupt the
stack.

The program works correct in VB6.0, you fill in the correct registers,
starting adres and mode and then the module and DLL form the request
which is send to the PLC, the plc sends a message back and the DLL and
module collect the DATA from the registers and shows it on the computer
screen.


Someone told me that it might get fixed if i used internal pointers.
Anyone knows if this will solve my problem or any other ideas???

Thx
Klenne


ps: if you dont understand me cause of my bad english phrases please
ask and ill try to reform the phrase.

.



Relevant Pages

  • Re: Check for DLL
    ... If it fails how do I register the dll if I know the location of the dll ... > Dim sCOMAs String ... > Set oTest = CreateObject) ...
    (microsoft.public.vb.general.discussion)
  • RE: Registering a custom DLL after deployment - advice?
    ... Register property to vsdraCOM - and leave the output as content ... I added the dll and the tlb and set the build action to ... publishing and invoke the .bat file. ... The custom dll is for the Access ADP. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Self registering a COM dll in a VS2003 Windows setup project...
    ... Most of the Register settings extract the settings at build time and put the ... at install time. ... code in that DLL is doing something that isn't being put into the MSI file. ... I have not been able to make a customized Redemption dll ...
    (microsoft.public.dotnet.framework.setup)
  • Re: IMailRuleClient wont work!!!
    ... Does your DLL properly export DllRegisterServer and DllGetClassObject? ... > So i have tested manually register the COM. ...
    (microsoft.public.pocketpc.developer)
  • RE: COM Addin dll and HKEY_LOCAL_MACHINE
    ... registry for HKEY_LOCAL_MACHINE (HKLM). ... associate the designer objects with HKLM and compile the DLL so that it would ... Outlook ] ... > designer to register in HKEY_CURRENT_USER. ...
    (microsoft.public.vb.com)