A blog on Tally Integration, to import and export data from Tally.ERP programmatically using VB6, VB.NET,C#,ASP.NET etc

Saturday, May 19, 2007

Using RTSLINK DLL in VB.NET

PInvoke is the mechanism by which .NET languages can call unmanaged functions in DLLs. This is especially useful for calling Windows API functions that aren’t encapsulated by the .NET Framework classes, as well as for other third-party functions provided in DLLs.

Using PInvoke in VB.NET to call RTSLINK DLL functions

There are mainly two ways in which you can use PInvoke in VB
1) Using the Declare Statement
2) Using DllImport

Using the Declare Statement
Declare Auto Function RTSOpen Lib "RTSLINK.DLL" Alias "Open" () As Long
Declare Auto Function Send Lib "RTSLINK.DLL" (ByVal strRequestXML As String) As Long
Declare Auto Function GetLastErrorMessage Lib "RTSLINK.DLL" () As String

Remarks:-
For more information on using PInvoke in VB.NET, please refer the article at CodeProject

2 comments:

Kapil said...

I am trying to link my VB.NET application with Tally. But I get this error while calling RTSOpen() function:
" Attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang. "

Please help
-Kapil

Shweta Softwares said...

1. Go to Debug/Exceptions
2. Open up the Managed Debugging Assistants node on the tree and scroll down till you find LoaderLock and uncheck it.

After this recompile the project.