Solved

Converting C# dll to COM component to access from VB6 application

Posted on 2013-11-07
3
243 Views
Last Modified: 2013-11-08
Below is my simple C# class and interface. I want to conver this into COM component which is accessble in VB6 application.

Can you please guide me clearly how I can achieve this.


namespace InteractorHint
{
    interface TestInterface
    {
        [DispId(1)]
        void WriteHints(string hint);
    }
}



namespace InteractorHint
{
    public class Test : TestInterface
    {
        public Test()
        {
        }

        public void WriteHints(string strHint)
        {
            Console.WriteLine(strHint);
        }
    }
}
0
Comment
Question by:GouthamAnand
3 Comments
 
LVL 5

Accepted Solution

by:
advfinance earned 500 total points
ID: 39630945
This should get you started.

using System.Runtime.InteropServices;

namespace InteractorHint
{
    interface TestInterface
    {
        void WriteHints(string hint);
    }
}


namespace InteractorHint
{
    [ComVisible(true)]
    [Guid("TODO:SET-YOUR-GUID")]
    interface ITestCom
    {
        [DispId(1)]
        void WriteHints(string hint);
    }
}


namespace InteractorHint
{
    [ComVisible(true)]
    [ClassInterface(ClassInterfaceType.None)]
    [ComDefaultInterface(typeof(ITestCom))]
    [Guid("TODO:SET-YOUR-GUID")]
    public class Test : TestInterface, ITestCom
    {
        public Test()
        {
        }

        public void WriteHints(string strHint)
        {
            Console.WriteLine(strHint);
        }
    }
} 

Open in new window


--
Chris
0
 
LVL 15

Expert Comment

by:unknown_routine
ID: 39630977
Here is a good and simple guideline:

http://zbz5.net/consuming-net-assemblies-vb6
0
 

Author Closing Comment

by:GouthamAnand
ID: 39633472
Thanks a lot.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now