Help: Call the C # winforms dll from the VB6 project?

I have a VB6 project (Windows application), and I have to redo the module in an existing VB6 project in C # .net.

The module that I am developing in C # .net must be a dll and must contain some forms of windows. I was able to successfully call the C # dll of appliciton application from my vb6 project, but I have problems when I try to call the C # class library with winforms from my VB6 project.

This is what I did for my Proof Of Concept - this is the class file in my C # .net class library project.

namespace TestDll
{
    public interface IClass1
    {
        void DisplayMessage();
    }


    public class Class1:IClass1
    {              
        void IClass1.DisplayMessage()
        { 
            MessageBox.Show ("Displyaing message");
        }

    }
}

I have a form in the same space, and I plan to create an instance Class1and use its object in the page_load event for C # winform.

VB6 , #.net dll. -

Private Declare Sub DislayMessage Lib "TestDll.dll" ()

Private Sub Command1_Click() //On button click event of the VB6 windows form
DislayMessage
End Sub

" DLL DisplayMessage TestDll.dll"

, . , CLE.NET DLL, winforms, Windows VB6.0.

Class1 VB6? ? ? ?

.

+2
3

COM-Visible. :

namespace TestDll
{
    [Guid("FB8AB9B9-6986-4130-BD74-4439776D1A3D")]
    [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
    [ComVisible(true)]
    public interface IClass1
    {
        [DispId(50)]
        void DisplayMessage();
    }


   [Guid("74201338-6927-421d-A095-3BE4FD1EF0B4")]
   [ClassInterface(ClassInterfaceType.None)]
   [ComVisible(true)]
   [ProgId("TestDll.Class1")]
    public class Class1:IClass1
    {              
        void IClass1.DisplayMessage()
        { 
            MessageBox.Show ("Displyaing message");
        }

    }
}

[DispId(50)]. , , COM. , , . , .

, COM- #. .

:

V# COM ...

* The class must be public
* Properties, methods, and events must be public.
* Properties and methods must be declared on the class interface.
* Events must be declared in the event interface.

GUID . Guid, guidgen.exe .

+3

- # COM- ( CCW-COM Callable Wrapper) COM- VB6.

:

http://www.bing.com/search?q=C%23+CCW&go=&form=QBRE&qs=n

+2
0
source

All Articles