[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 255
  • Last Modified:

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

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
GouthamAnand
Asked:
GouthamAnand
1 Solution
 
advfinanceCommented:
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
 
unknown_routineCommented:
Here is a good and simple guideline:

http://zbz5.net/consuming-net-assemblies-vb6
0
 
GouthamAnandAuthor Commented:
Thanks a lot.
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now