VB.NET DLL not work with EXTERN


DaleCarr

Recommended Posts

I am want to use Ingear which works well with AB PLC to bring information into Daqfactory for shripcharting.

so I wrote a quick dll using vb.net to test the possible solution and I can not get it to work, I have tried short, long ushort and strings but the function call fails in  DAQFactory.

I have 2 Call statements one for int and the other for string;   Also I tested the dll by loading back into VB.NETand the call statements work.

extern("C:\ClassLibrary2.dll","long Call1","Call","stdcall")
extern("C:\ClassLibrary2.dll","string Call2","strCall","stdcall")

this portion seems to work.

in other sequence I call 

x=Call1() or strx = Call2()

and I get C1000 Channel or function not found

so I am sure the problem lays with the compiling from VB.NET or the extern format I must not be understanding.

thanks for any help;

or if there is another method of using Ingear inside of DAQfactory.

 

simple dll written in VS2010 VB. NET

I complied it for x86 Release

Public Class Class1

Public Function Call1() As Int32

Dim result As Int32

result = 25

Return result

End Function

Public Function Call2() As String

Dim strRESULT As String

strRESULT = "Hello Dale"

Return strRESULT

End Function

End Class

 

Link to comment
Share on other sites

The problem is that you are calling the wrong function in DAQFactory.  Extern's parameters go: :dll location, prototype, function name in daqfactory, call type.  So, in your case, the functions you imported into DAQFactory came in as call() and strCall().  What the function is called in your VB script only matters for the prototype.  I don't recomomend using call() or strCall().  Maybe change that 3rd parameter to "Call1" and "Call2".

Note, we do this because often DLL functions have the same name as functions in DAQFactory, or you need to import from multiple DLL's with overlapping function names.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.