Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / August 2006

Tip: Looking for answers? Try searching our database.

.NET DLL use in VB6

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mike Sharpe - 30 Aug 2006 23:20 GMT
We have many old COM classes that are still in use.  They were written in
VB6.  We are now starting to do some things in C# however we cannot just
throw away everything from COM and start over.  Our migration to C# will be
multi-phase and right now we just need proof of concept.  Here's our
situation:

1.  We need to create a DLL/TLB in C# that works in VB6
2.  C# class needs to implement a VB6 class interface
3.  C# class needs to be exported to COM TLB for use in VB6

Here is my basic code:

using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace UserBV
{  
   [ComVisible(true)]
   public class UserBVInput: AlfaBVIO.BVInput
   {
     
       [ComVisible(true)]
       void AlfaBVIO._BVInput.Initialize(ref DSDataObjects.DSDataType
iSettings)
       {
         
       }

       [ComVisible(true)]
       void AlfaBVIO._BVInput.GetScenarios(string iFileName, ref
System.Array oScenarios)
       {
       
       }

       
       public BVInput()
       {

       }
       
       ~BVInput()
       {

       }
   }

   [ComVisible(true)]
   public class BVOutput : AlfaBVIO.BVOutput
   {
       
       public BVOutput()
       {
           
       }
       
       ~BVOutput()
       {

       }

       [ComVisible(true)]
       void AlfaBVIO._BVOutput.Initialize(ref DSDataObjects.DSDataType
iSettings)
       {

       }

       [ComVisible(true)]
       void AlfaBVIO._BVOutput.Add(ref DSDataObjects.DSDataType
iFileHeader, ref DSDataObjects.DSDataType iBVSeries)
       {

       }

       [ComVisible(true)]
       void AlfaBVIO._BVOutput.Save()
       {

       }        
   }
}

I have the project file set according to "Register for COM interop" as well
as "Make assembly COM visible".  I am able to reference the built TLB file in
a VB6 project but there are no public methods.  The VB6 interface that I must
implement from is called AlfaBVIO.BVInput

Can someone please help me?  I'm sure to anyone that has experienced this
before it is a no-brainer.  This is just the first time I've ever had to do
something as odd as this.
sloan - 30 Aug 2006 23:32 GMT
Try this:
http://msdn.microsoft.com/vbrun/vbfusion/usingnet/default.aspx

> We have many old COM classes that are still in use.  They were written in
> VB6.  We are now starting to do some things in C# however we cannot just
[quoted text clipped - 88 lines]
> before it is a no-brainer.  This is just the first time I've ever had to do
> something as odd as this.
Mike Sharpe - 31 Aug 2006 14:46 GMT
This does not help me.  I am not looking at using one of the existing .NET
classes.  I need to create my own C# class that inherits a VB6 COM interface
from a VB6 DLL and then use this C# DLL that I export to a TLB file in VB6.  
The problem is that when I reference the TLB file in VB6, none of the C#
interface is visible.  The class is but none of its methods or properties.  

My problem is that I cannot specify the inherited interface properties as
public in my C# DLL without the compiler throwing an error.

> Try this:
> http://msdn.microsoft.com/vbrun/vbfusion/usingnet/default.aspx
[quoted text clipped - 96 lines]
> do
> > something as odd as this.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.