I am trying to make a .NET class (.NET 2.0/C#) to be used in VB6.
I created Class Library Project with the following Class(below). After
build, I am able to reference the Class. See the TestClass in Object
Browser. But I can see the DoTest() method. I wasted hours and still
can't figure it out.
-----
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace ComDllTest
{
[Guid("701F1709-3B9F-4b2e-AF81-686D2C08F015")]
public class TestClass
{
public TestClass()
{
}
public void DoTest()
{
return;
}
}
}
I found the answer from this group:
Christian Fröschlin
View profile
More options Feb 2 2004, 11:05 am
Newsgroups: microsoft.public.dotnet.framework.interop
From: Christian Fröschlin <froesch...@mvtec.com>
Date: Mon, 02 Feb 2004 17:05:46 +0100
Local: Mon, Feb 2 2004 11:05 am
Subject: Re: Public .Net method not visible in COM app
Reply to author | Forward | Print | Individual message | Show original
| Report this message | Find messages by this author
Sun Murthy wrote:
> I followed MSDN examples to create a .Net component library and a
CCW
> for it. I then proceed to use the CCW in a VB6 app. I see the .Net
> library listed as a reference in the VB 6 project, I can include
that
> reference and instantiate that object. However, none of the public
> methods in the .Net component are visible to the VB app. What am I
> missing?
Have you tried calling the methods or did you just look at
IntelliSense?
By default, only an IDispatch interface for late binding is exposed,
and
the members cannot be listed by VB. Use the ClassInterfaceType
attribute
(e.g. AutoDual), or even better define explicit interfaces.
Have a look at
http://www.dotnetinterop.com/faq/?q=ClassInterface