Solved

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

Posted on 2013-11-07
3
244 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

Suggested Solutions

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
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 …

777 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