473,790 Members | 2,380 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calling a VB DLL Methods external to .NET

I am a CA-OpenROAD programmer, but I attempting to build some VB.NET DLLs
and access them through OpenROAD as an external Windows TypeLib.

I have managed to build a simple DLL (code follows) but the only method
that I can see exposed is "DisplayNum ber" which is a sub declared in a
public interface definition rather than "DisplayNumbers " which is the name
of the public sub based on the interface definition.

My problem is when I attempt to call the "displaynum ber" method I get an
error saying that this method does not exist for the class "myinterfac e".

What I would like to know is this a common problem for calling methods in a
VB.NET DLL external to .NET apps? Ultimately I want to call the
"displaynumbers " method.

FYI after I built the DLL I the performed the following commands in the bin
dir of the project (ClassLibrary4) :

regasm.exe /tlb:ClassLibrar y4.tlb ClassLibrary4.d ll
gacutil.exe /i ClassLibrary4.d ll
And here is the code:

--------------------------------------------------------------

Public Interface MyInterface
Sub DisplayNumber()

End Interface

Public Class Class1
Implements MyInterface
Public Sub DisplayNumbers( ) Implements MyInterface.Dis playNumber

' This method does nothing. I am hoping to just see it.
MsgBox("This is from a VB.NET DLL")

End Sub

End Class

-----------------------------------------------------------------------

Any help would be much appreciated.
Dominic
Nov 21 '05 #1
1 2701
well here is a copy paste example of what you need

<ComClass(ComCl sMP.ClassId, ComClsMP.Interf aceId, ComClsMP.Events Id)> _

Public Class ComClsMP

#Region "COM GUIDs"

' These GUIDs provide the COM identity for this class

' and its COM interfaces. If you change them, existing

' clients will no longer be able to access the class.

' make sure that the below values are unique for every new project

Public Const ClassId As String = "7BAC16DC-0103-4BA3-9A89-53253372D711"

Public Const InterfaceId As String = "3CE4FCAF-CEEA-4849-9743-0E8E38D313AE"

Public Const EventsId As String = "7E90CE2E-8A8C-45A2-870A-3461A9DF28B7"

#End Region

Public Sub Helloworld()

MsgBox("This is a helloworld EXAMPLE from a VB.NET DLL exposed to COM")

End Sub

' A creatable COM class must have a Public Sub New()

' with no parameters, otherwise, the class will not be

' registered in the COM registry and cannot be created

' via CreateObject.

Public Sub New()

MyBase.New()

End Sub

End Class

If you want to use this assembly on a pc on wich it wasn`t compiled then
register it with RegAsm.exe or use a installer ( the standard installer
in VS.Net is fine for this task )

late binded VB6 example how to call the dll ( no reference or anything is
necessary in this case )

Dim Objenc As Object
Set Objenc = CreateObject("a ssemblyname.cla ssname")

Objenc.Hellowor ld
Well i hope to have given you some ideas :-)

Happy coding

M. Posseth [MCP Developer]
"Dominic via DotNetMonster.c om" <fo***@nospam.D otNetMonster.co m> wrote in
message news:ee******** *************** *******@DotNetM onster.com...
I am a CA-OpenROAD programmer, but I attempting to build some VB.NET DLLs
and access them through OpenROAD as an external Windows TypeLib.

I have managed to build a simple DLL (code follows) but the only method
that I can see exposed is "DisplayNum ber" which is a sub declared in a
public interface definition rather than "DisplayNumbers " which is the name
of the public sub based on the interface definition.

My problem is when I attempt to call the "displaynum ber" method I get an
error saying that this method does not exist for the class "myinterfac e".

What I would like to know is this a common problem for calling methods in a VB.NET DLL external to .NET apps? Ultimately I want to call the
"displaynumbers " method.

FYI after I built the DLL I the performed the following commands in the bin dir of the project (ClassLibrary4) :

regasm.exe /tlb:ClassLibrar y4.tlb ClassLibrary4.d ll
gacutil.exe /i ClassLibrary4.d ll
And here is the code:

--------------------------------------------------------------

Public Interface MyInterface
Sub DisplayNumber()

End Interface

Public Class Class1
Implements MyInterface
Public Sub DisplayNumbers( ) Implements MyInterface.Dis playNumber

' This method does nothing. I am hoping to just see it.
MsgBox("This is from a VB.NET DLL")

End Sub

End Class

-----------------------------------------------------------------------

Any help would be much appreciated.
Dominic

Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1902
by: Grandma Wilkerson | last post by:
Hi, I have a class whose constructor accepts a Socket as an argument. The constructor then makes a call to Socket.BeginReceive(). The callback delegate passed to BeginReceive() is a method of my class. There is a slight chance that the callback delegate will be called from the I/O thread pool BEFORE my constructor completes. Is calling this delegate before the constructor finishes a problem? In C++, this type of arrangement was a...
9
2819
by: Angel | last post by:
Hi again, I'm trying to call functions from a proprietary DLL but it's turned out to be more difficult than I thought. I have this W32.DLL which was written in C by USPS. They don't provide the code so I only have the documentation. I'm trying to call a function called z4date that, according to the docs, returns the date as "an 8-byte character string in the "YYYYMMDD" format". When I run it with this code I've written , I get "Can not...
5
1774
by: Chua Wen Ching | last post by:
I had use fxcop to check my code. I had 1 confusion here. I would normally call a method by this way in my IAnimal: Example: public void CallFuncA(ushort port); But fxcop says i need to write like a property rather than method to this:
6
1709
by: Amjad | last post by:
Hi, I want to make a project that calls and executes a function (VB code) made in a seperate file in the Application Folder. I know I can create the function in my project and call it internally, but I want to put the function's code in an external file, so that future updates to the function will require a replacing the function file instead of re-installing the whole project. Can you give me ideas on how I can make small updates to my...
6
1919
by: Rob Cowie | last post by:
Hi all, Is there a simple way to call every method of an object from its __init__()? For example, given the following class, what would I replace the comment line in __init__() with to result in both methods being called? I understand that I could just call each method by name but I'm looking for a mechanism to avoid this.
6
3368
by: guxu | last post by:
I have a managed C++ code which calls some methods in unmanaged C++ DLL. In my unmanaged DLL, I have a PROTECTED virutal function in a base class and derived class has a PRIVATE function which overrides the virutal one in the base. In my managed class, I have the following private: CUnmanaged __nogc* m_pUnManaged
4
1860
by: Mythran | last post by:
I once read an article somewhere describing why we should not override the OnXXX methods of classes when you want to extend the functionality of a class. It stated that you should handle the event instead (inside the derived class). Does anyone know of this article or an article that discusses this or the opposite (should override OnXXX instead of handling the event)? Thanks, Mythran
2
1037
by: spohle | last post by:
hi, i created an instance of a my own class which has methods and all. now i get an outside function called, which is unfortunatly not aware of the instace at all (i don't control how this outside function is called). but i would like to get access back to my instance and it's methods. is there any clean way of doing this ?
9
2093
by: flopbucket | last post by:
Hi, Say I have a baseclass B that has many derived classes, let's say C..Z, for example: class B { }; class C : public B {};
0
9512
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10413
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10200
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9021
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7530
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5422
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4094
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.