Solved

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

Posted on 2013-11-07
3
247 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

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.   …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

739 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