Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

COMCallsJava_NET Sample (Expose Managed Components to COM Using .NET Framework Interop) 

Visual Studio 2005

Download sample

This sample demonstrates how managed components written in Visual J# can be exposed to COM using the .NET Framework COM-interop semantics. Using .NET Framework semantics is the recommended way for COM inter-op for newly written Visual J# components. In this sample, the managed component written in Visual J# is compiled to a DLL. The DLL is then registered as a COM component using the RegAsm tool, which then allows it to be accessed from clients such as Visual Basic 6.0.

For more information on COM inter-op using .NET Framework semantics please refer to Interoperating with Unmanaged Code.

Security noteSecurity Note

This sample code is provided to illustrate a concept and should not be used in applications or Web sites, as it may not illustrate the safest coding practices. Microsoft assumes no liability for incidental or consequential damages should the sample code be used for purposes other than as intended.

Building and Running the Sample

To open the sample file in Solution Explorer

  1. Click Download Sample.

    The File Download message box appears.

  2. Click Open, and on the left column of the zip folder window, click Extract all files.

    The Extraction Wizard opens.

  3. Click Next. You can change the directory that the files will be extracted to, and then click Next again.

    Make sure that the Show extracted files check box is selected, and click Finish.

  4. Double-click the sample's .sln file.

    The sample solution is displayed in Solution Explorer. You might get a security warning that says the solution location is not trusted. Click OK to continue.

To build this sample

To run this sample

  1. Open the VB6Project.vbp file in Visual Basic 6.0.

  2. From the Project menu, choose References. Then, browse and add a reference to the MyForm.tlb file present in your sample directory, or in the .\bin\debug subdirectory of the project root when building from the IDE.

  3. Press F5.

  4. Once running, click the Visual Basic form's button to create a managed form. Adjust the properties on the Visual Basic form and watch the changes occur on the managed form. The Visual Basic form also allows you to create a button on the managed form and adjust some of its properties. This is all done from unmanaged Visual Basic code.

See Also

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft