473,507 Members | 11,134 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.en/dndotnet/html/callnetfrcom.htm
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 2738
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
ComClassAttribute to simply the process of exposing COM components from
Visual Basic 2005. COM objects are very different from .NET framework
assemblies; without the ComClassAttribute, you need to follow a number of
steps to generate a COM object from Visual Basic 2005. For classes marked
with ComClassAttribute, the compiler performs many of these steps
automatically.

#ComClassAttribute 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
ComClassAttribute to simply the process of exposing COM components from
Visual Basic 2005. COM objects are very different from .NET framework
assemblies; without the ComClassAttribute, you need to follow a number of
steps to generate a COM object from Visual Basic 2005. For classes marked
with ComClassAttribute, the compiler performs many of these steps
automatically.

#ComClassAttribute 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
5121
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. ...
9
3747
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...
8
1569
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. ...
3
3919
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...
7
1366
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
1064
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) ...
3
9051
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. ...
7
1648
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...
1
6508
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...
10
13278
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>";...
1
7030
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...
0
7482
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...
0
5623
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,...
1
5041
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...
0
3191
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...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1540
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 ...
1
758
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
411
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...

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.