Solved

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

Posted on 2013-11-07
3
242 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
Comment Utility
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
Comment Utility
Here is a good and simple guideline:

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

Author Closing Comment

by:GouthamAnand
Comment Utility
Thanks a lot.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

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.   …
Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

772 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

11 Experts available now in Live!

Get 1:1 Help Now