Calling a .Net dll from Visual basic
by ford_desperado » Thu, 18 Nov 2004 08:45:17 GMT
Hi,
I've created a .Net dll, and wrapped it in CCW:
...
using System.Runtime.InteropServices;
namespace XMLUpload
{
[ClassInterface(ClassInterfaceType.AutoDual)]
public class XMLUploadBase
...
then I built the dll and registered it no problem:
regasm "full path / dll name"
regasm said that "types registered successfully"
Then I vcreated a VB project in MS VIsual Basic 6.0 (sp5) and tried to
add the dll to References. The dll was not listed, so I browsed to the
dll, but instead of registering I got 'Can't add a reference to the
specified file'
what am I missing?
TIA
RE: Calling a .Net dll from Visual basic
by S2F1c3Rhdg » Thu, 18 Nov 2004 16:55:02 GMT
Hi,
add the following attribute to the public class
[GuidAttribute("634056EC-D460-4250-B96A-4F75459538DC")]
You can generate a GUID from VS.NET IDE -> Tools -> Create GUID
Also register your project for COM Interop from Project properties.
HTH.
Kaustav.
Re: Calling a .Net dll from Visual basic
by ford_desperado » Sat, 20 Nov 2004 07:50:11 GMT
thank you Kaustav, that worked
Similar Threads:
1.Visual C++ calling Visual Basic DLL
2.Problem calling dll function with Visual Basic
I'm using Access Visual Basic.
When trying to call this function within its class module:
Declare Function DAZOptions Lib "emdaz32.dll" (ByVal lngHandle As Long)
As Long
I receive the following error:
Run time error '53':
File not found: emdaz32.dll
My code and this function worked perfectly with Windows XP but now fails
after upgrading to Windows Vista 64-bit.
The file emdaz32.dll IS contained in the folder C:\Windows\System32\.
Even if I declare the function using the full path to the dll file as shown
below:
Declare Function DAZOptions Lib " C:\Windows\System32\emdaz32.dll"
(ByVal lngHandle As Long) As Long
I still receive the same error message just showing the full path:
Run time error '53':
File not found: C:\Windows\System32\emdaz32.dll
I don't understand why "File not found" error is returned when the file is
there.
Is there something different I have to do to call a 32-bit dll when using
Windows Vista 64-bit version? My other 32-bit applications are working
properly.
I will GREATLY appreciate any assistance anyone can offer. This has me
really stumped and frustrated.
3.Trying to use GetProcAddress to call a function in a DLL using Visual Basic
I am trying to get my VB code to work on 32 bit Windows and 64 bit
Windows.
I am trying to call a pointer to function that resides in a DLL using
the GetProcAddress and then call the function through the pointer.
See Below Code:
Attribute VB_Name = "IsWin64"
Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA"
(ByVal lpLibFileName As String) As Long Declare Function FreeLibrary
Lib "kernel32" (ByVal hLibModule As Long) As Long Declare Function
GetProcAddress Lib "kernel32" (ByVal hModule As Long, ByVal lpProcName
As String) As Long
Function Is64BitWindows() As Boolean
Dim r2 As Long
Dim hLib As Long
Dim fpFunction As Long
' Load up Kernel32.Dll
hLib = LoadLibrary(Environ("WINDIR") + "\system32\kernel32.dll")
' If we were able to load it up
If hLib Then
' Try to load up a pointer to the routine
fpFunction = GetProcAddress(hLib, "IsWow64Process")
' How do I call fpFunction() ?
FreeLibrary Lib
End If
End Function
Sub Main()
bRet = Is64BitWindows()
End Sub
4.C/C++ calling via COM ActiveX Visual Basic DLL
I created an ActiveX DLL written in Visual Basic.
I have no problem linking to dll from VB test driver.
I have no problem linking from C/C++ test driver.
I am having problems connecting to it from an NT Service.
The NT service also monitors an Exchange Mailbox so it is
linking to the MAPI functions.
When The program calls CoInitialize or CoInitializeEx,
the same result occurs. When it attempts to link to the
DLL, it is returning an error. The error is 80004003
(invalid pointer).
Any information will be appreciated.
5.Calling visual basic dll from excel vba
6. DLL called from Visual Basic
7. Calling a DLL from Visual Basic 6.0
8. calling LV DLL or EXE from Visual Basic with return values