|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Calling VB.Net classes from VB6I 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 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. Have you seen this article:
http://msdn.microsoft.com/msdnmag/issues/06/05/WrapItUp/default.aspx Tony Show quoteHide quote "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. > > 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? -- Show quoteHide quoteTerry "tlkerns" wrote: > Have you seen this article: > > http://msdn.microsoft.com/msdnmag/issues/06/05/WrapItUp/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. > > > > 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. Show quoteHide quote "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/issues/06/05/WrapItUp/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. > > > > > > 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? -- Show quoteHide quoteTerry "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/issues/06/05/WrapItUp/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. > > > > > > > > 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/library/microsoft.visualbasic.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. 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! -- Show quoteHide quoteTerry "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/library/microsoft.visualbasic.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. > > 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. 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. -- Show quoteHide quoteTerry "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. > >
VB.NET Screen Stops Refreshing After Losing Focus??
Why choose SQL Express over Access? Offset lines appearing over form after delay (NVIDIA Chipset) Soap Formatter namespace not found UI to enter values into a structure Crypto removing white spaces from byte array Restart, but after a delay Update database field WTSEnumerateProcesses My object/class/whatever |
|||||||||||||||||||||||