473,662 Members | 2,352 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calling VB.Net classes from VB6

I am trying to test out the ability of VB6 (VBA access) to instanciate a
VB.net Object and call its methods. I came accross the following article in
my vs2005 help search:
ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.NETDEV.v10.e n/dndotnet/html/callnetfrcom.ht m
Problem is it doesn't work!
Can someone point me a "How-to" for exposing .net classes to com (VS2005)
that actually works?

--
Terry
Jun 2 '06 #1
9 2750
Hi Terry,

Thank you posting!

This is a quick note to let you know that I am performing research on this
issue and will get back to you as soon as possible. I appreciate your
patience.

Regards,
Walter Wang
Microsoft Online Community Support

=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 2 '06 #2
Have you seen this article:

http://msdn.microsoft.com/msdnmag/is...p/default.aspx

Tony

"Walter Wang [MSFT]" wrote:
Hi Terry,

Thank you posting!

This is a quick note to let you know that I am performing research on this
issue and will get back to you as soon as possible. I appreciate your
patience.

Regards,
Walter Wang
Microsoft Online Community Support

=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 2 '06 #3
Hi Walter,
It appears that the problem is that the article was written for an
earlier version of .Net. Is there an equivalent 'how to' for VS 2005? I
want the .Net class that I am creating to be usable by both VB6/VBA and .Net.
--
Terry
"Walter Wang [MSFT]" wrote:
Hi Terry,

Thank you posting!

This is a quick note to let you know that I am performing research on this
issue and will get back to you as soon as possible. I appreciate your
patience.

Regards,
Walter Wang
Microsoft Online Community Support

=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 2 '06 #4
Hi Tony,
Thanks! One question though. If I go this approach, will the object be
callable from .Net as a '.Net class', or will I then have to treat it as a
'real' com object and wrap it again?
--
Terry
"tlkerns" wrote:
Have you seen this article:

http://msdn.microsoft.com/msdnmag/is...p/default.aspx

Tony

"Walter Wang [MSFT]" wrote:
Hi Terry,

Thank you posting!

This is a quick note to let you know that I am performing research on this
issue and will get back to you as soon as possible. I appreciate your
patience.

Regards,
Walter Wang
Microsoft Online Community Support

=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 2 '06 #5
Although the article tells you how to create a COM Callable Wrapper, it fails
to mention what exactly is going on.

When you build your .NET dll, the compiler is actually creating two files.
The first file is your .NET *.dll file and the other is a Type Library *.tlb
for your .NET dll. If your dll is named "MyLibrary.dll" , the compiler will
create a file called "MyLibrary.tlb" .

Your VB6 program will reference MyLibrary.tlb (which is a COM wrapper for
MyLibrary.dll). VB6 will execute MyLibrary.dll through MyLibrary.tlb.

If you have other .NET clients that need to call MyLibrary.dll, just
reference that directly.

So to answer your question, the same class can be called as a .NET class as
well.

"Terry" wrote:
Hi Tony,
Thanks! One question though. If I go this approach, will the object be
callable from .Net as a '.Net class', or will I then have to treat it as a
'real' com object and wrap it again?
--
Terry
"tlkerns" wrote:
Have you seen this article:

http://msdn.microsoft.com/msdnmag/is...p/default.aspx

Tony

"Walter Wang [MSFT]" wrote:
Hi Terry,

Thank you posting!

This is a quick note to let you know that I am performing research on this
issue and will get back to you as soon as possible. I appreciate your
patience.

Regards,
Walter Wang
Microsoft Online Community Support

=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 4 '06 #6
Hi,
Thanks for the explanation. I am still haveing a problem though. I
posted another question on 6-2, about exposing a .Net assembly to both VB6
and .Net. The gist of that posting is that after adding it to the GAC, it
does not appear on the .Net tab of referencable assemblies. Which seems to
imply that you have to have a local copy. Any ideas?
--
Terry
"rmacias" wrote:
Although the article tells you how to create a COM Callable Wrapper, it fails
to mention what exactly is going on.

When you build your .NET dll, the compiler is actually creating two files.
The first file is your .NET *.dll file and the other is a Type Library *.tlb
for your .NET dll. If your dll is named "MyLibrary.dll" , the compiler will
create a file called "MyLibrary.tlb" .

Your VB6 program will reference MyLibrary.tlb (which is a COM wrapper for
MyLibrary.dll). VB6 will execute MyLibrary.dll through MyLibrary.tlb.

If you have other .NET clients that need to call MyLibrary.dll, just
reference that directly.

So to answer your question, the same class can be called as a .NET class as
well.

"Terry" wrote:
Hi Tony,
Thanks! One question though. If I go this approach, will the object be
callable from .Net as a '.Net class', or will I then have to treat it as a
'real' com object and wrap it again?
--
Terry
"tlkerns" wrote:
Have you seen this article:

http://msdn.microsoft.com/msdnmag/is...p/default.aspx

Tony

"Walter Wang [MSFT]" wrote:

> Hi Terry,
>
> Thank you posting!
>
> This is a quick note to let you know that I am performing research on this
> issue and will get back to you as soon as possible. I appreciate your
> patience.
>
> Regards,
> Walter Wang
> Microsoft Online Community Support
>
> =============== =============== =============== =====
> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> =============== =============== =============== =====
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>

Jun 4 '06 #7

Thanks you rmacias for your contribution.

Hi Terry,

Yes, the article you're refering to in the first post is now obsolete for
Visual Studio 2005. We can now use a more simpler way to do this. We use
ComClassAttribu te to simply the process of exposing COM components from
Visual Basic 2005. COM objects are very different from .NET framework
assemblies; without the ComClassAttribu te, you need to follow a number of
steps to generate a COM object from Visual Basic 2005. For classes marked
with ComClassAttribu te, the compiler performs many of these steps
automatically.

#ComClassAttrib ute Class
http://msdn2.microsoft.com/en-us/lib....comclassattri
bute.aspx
Although you can also expose a class created with Visual Basic as a COM
object for unmanaged code to use, it is not a true COM object. When a COM
client calls a .NET object, the common language runtime creates the managed
object and a COM Callable Wrapper (CCW) for the object. Unable to reference
a .NET object directly, COM clients use the CCW as a proxy for the managed
object. COM callable wrappers are invisible to other classes running within
the .NET Framework.
#COM Callable Wrapper
http://msdn2.microsoft.com/en-us/library/f07c8z1c.aspx

From above article, you will see that other .NET objects will still using
the same way to call the .NET object which is exposed as COM component.

You may also take a look at following resource center about VB Fusion:

#Visual Basic 6.0 Resource Center: VB Fusion
http://msdn.microsoft.com/vbrun/vbfusion/

As for your last post about that not seeing the assembly in Visual Studio
IDE, I will reply in the separate thread you just posted.

Hope this helps. If anything is unclear, please feel free to post here.
Regards,
Walter Wang
Microsoft Online Community Support

=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 5 '06 #8
Hi and thanks for the help.
Ok, I think I am getting the picture. Unlike VB6, when I register a dll
and it is placed on the 'list of available references' to another VB6
project, running the gactil to 'register' the .Net assembly with the GAC does
NOT put it on the list of .Net assemblies available for reference. The fact
that I 'browse' to it at 'development' time, has nothing to do with how the
CLR finds it after 'deployment'.
If I want the assembly to appear on the .Net tab, I can either put it in
the public assemblies folder or add an entry to registry to add the path.
At deployment time, I will run both the gactil and regasm for each of the
com callable assemblies.
Thanks for the help!
--
Terry
"Walter Wang [MSFT]" wrote:

Thanks you rmacias for your contribution.

Hi Terry,

Yes, the article you're refering to in the first post is now obsolete for
Visual Studio 2005. We can now use a more simpler way to do this. We use
ComClassAttribu te to simply the process of exposing COM components from
Visual Basic 2005. COM objects are very different from .NET framework
assemblies; without the ComClassAttribu te, you need to follow a number of
steps to generate a COM object from Visual Basic 2005. For classes marked
with ComClassAttribu te, the compiler performs many of these steps
automatically.

#ComClassAttrib ute Class
http://msdn2.microsoft.com/en-us/lib....comclassattri
bute.aspx
Although you can also expose a class created with Visual Basic as a COM
object for unmanaged code to use, it is not a true COM object. When a COM
client calls a .NET object, the common language runtime creates the managed
object and a COM Callable Wrapper (CCW) for the object. Unable to reference
a .NET object directly, COM clients use the CCW as a proxy for the managed
object. COM callable wrappers are invisible to other classes running within
the .NET Framework.
#COM Callable Wrapper
http://msdn2.microsoft.com/en-us/library/f07c8z1c.aspx

From above article, you will see that other .NET objects will still using
the same way to call the .NET object which is exposed as COM component.

You may also take a look at following resource center about VB Fusion:

#Visual Basic 6.0 Resource Center: VB Fusion
http://msdn.microsoft.com/vbrun/vbfusion/

As for your last post about that not seeing the assembly in Visual Studio
IDE, I will reply in the separate thread you just posted.

Hope this helps. If anything is unclear, please feel free to post here.
Regards,
Walter Wang
Microsoft Online Community Support

=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 6 '06 #9
Hi Terry,

Thank you for your update. Please feel free to post here if anything is
unclear.

Have a nice day!

Regards,
Walter Wang
Microsoft Online Community Support

=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 7 '06 #10

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

Similar topics

4
5150
by: Martin Maney | last post by:
I've been to the cookbook (both forms, since they're sometimes usefully different), but that gave rise to more questions than answers. Heck, let me pull some of them up while I'm at it. Martelli gives the recipie (5.3 on paper) "Calling a Superclass __init__ Method if it Exists" where he seems to say that this: class NewStyleOnly(A, B, C): def __init__(self): super(NewStyleOnly, self).__init__()
9
3761
by: F. GEIGER | last post by:
I've dev'ed a Python prototype of an app, that besides the internals making it up has a gui. While test-driven dev'ing the app's internals in Python is fun as usual, dev'ing the GUI is not so funny, at least for me. I guess dev'ing a GUI in a test-driven way is not possible, or is it? I'm using wxPython, so if anyone has an idea... For now most of the time I extend and change the gui things, then run it, do the clicks to go thru the...
8
1584
by: Greg Bacchus | last post by:
I have a base class with a method that is to be called in the constructor of the inheritting classes. Is there any way of determining, say, the Type of the class that is calling it. e.g. class A { public A() {
3
3928
by: acg | last post by:
If you have a class with a public method, and another class which will want to call this method, is there a way to determine the type of the calling class within the method being called? For I want to gaurantee only certain other classes/object types can call a specific method in given class. Any advice would be appreciated and if there is anything that can be done to use the frameworks inherent permissioning. Regards, acg
7
1375
by: John | last post by:
Hi I have two distinct classes A & B. I am using class B from within Class A as follows; Public Class clsClassA Friend ClassB As new ClassB Public Sub New()
3
1069
by: Ray Cassick \(Home\) | last post by:
I have several classes that has a public interface (nothing really different there :) ). 1) I would like to ensure that some classes can only be instantiated by a specific class type. 2) I would like to restrict some public methods from being called only from another certain class type. I was trying to figure out a way that I could do this with attributes but I
3
9078
by: Mike | last post by:
Timeout Calling Web Service I am calling a .NET 1.1 web service from an aspx page. The web service can take several minutes to complete its tasks before returning a message to the aspx page. If the web service is taking a long time to complete, the aspx page returns a ‘The operation has timed-out.’ Message to the web browser after 100 seconds. I’ve added: <httpRuntime executionTimeout="300" /> to the web.config files
7
1652
by: Jeremy Chaney | last post by:
I have an application written in C# that uses objects written in a managed C++ DLL. When I exit my app, my C# classes have their destructors called, but the MC++ objects that those classes hold references to do not get invoked (I can observe this from both breakpoints in the code, and trace output to the console). I was under the impression that when my C# object goes out of scope, it would automatically dispose of all of the references...
1
6525
by: =?Utf-8?B?cmFuZHkxMjAw?= | last post by:
The code below is pretty simple. Calling Talker() in the parent returns "Parent", and calling Talker() in the child returns "Child". I'm wondering how I can modify the code so that a call to the Talker() in Parent will call the Talker() method in every child class. The kicker is that I have many different Child classes, and not all Child classes will be loaded when Talker() in the Parent is called. Thanks, Randy
10
13290
by: Finger.Octopus | last post by:
Hello, I have been trying to call the super constructor from my derived class but its not working as expected. See the code: class HTMLMain: def __init__(self): self.text = "<HTML><BODY>"; print(self.text); def __del__(self): self.text = "</BODY></HTML>"; print(self.text);
0
8432
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8343
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
8762
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...
1
8545
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8633
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6185
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
4179
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
4347
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1747
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.