all groups > vj# > april 2004 >
You're in the

vj#

group:

Create vj# dll


Create vj# dll Wayne
4/28/2004 8:06:08 PM
vj#:
Hi, is there a way to create a com dll with vj#? I search through the new project option and did not find a com dll project option

Actually, I have a java source file which i would like to make it a com object, so that my vb6.0 can call it
Re: Create vj# dll Lars-Inge Tønnessen
4/29/2004 3:14:32 PM
Yes no problem. It's called a "CCW". Com Callable Wrapper (or something like
that).

Here is one example:

1. Open Visual Studio.
2. Make a new J# Class Library project.
3. Add an interface to your classes:

package JCOMTest;

public interface ITest
{
/** @property */
public void set_Value( int number );

/** @property */
public int get_Value( );
}

public class Class1 implements ITest
{
private int number;
public Class1()
{
}

/** @property */
public void set_Value( int number )
{
this.number = number;
}

/** @property */
public int get_Value( )
{
return this.number;
}
}


4. Make a string name using the "sn" utility.
c:\....the project folder\> sn -k yourkey.snk

5. Add the filename to the "AssemblyInfo.jsl" file.
/** @assembly AssemblyKeyFile("yourkey.snk") */

6. Ctrl + Shift + B (Build solution)

7. In the bin\debug folder:
8. Create a type library and register it in the registry.
c:\....the project folder\bin\debug> regasm JCOMTest.dll
/tlb:JCOMTest.tlb

9. You should now either copy the dll to the clinet folder, or put it in the
Global Assembly Cache.
c:\....the project folder\bin\debug> gacutil /i JCOMTest.dll

10. Ok, It should now be ready.

11. Open Tools + Ole/COM Object Viewer in Visual Studio.
12. Click on "All Object"
13. Find "JCOMTest.Class1"
14. You should now find the "ITest" interface, double click it and click on
"View Type Info".
(Remember to "release instance", right click "JCOMTest.Class1").

15. If you want to unregister it:
16. c:\....the project folder\bin\debug> gacutil /u JCOMTest.dll
17. c:\....the project folder\bin\debug> regasm JCOMTest.dll /unregister



Regards,
Lars-Inge Tønnessen
www.larsinge.com

Re: Create vj# dll Wayne
4/30/2004 11:46:02 PM
Re: Create vj# dll Bruno Jouhier [MVP]
5/1/2004 3:54:23 PM
Any class that you create in .NET can be exposed to COM (with the bit of
extra work that Lars-Inge described).

Actually .NET (J#, C#) is probably the easiest way to create COM components
today (if you accept the fact that your COM components require the .NET
runtime, of course).

Bruno.

"Wayne" <anonymous@discussions.microsoft.com> a écrit dans le message de
news:024DBAC2-B92A-40B6-82C8-77C69670DE96@microsoft.com...
[quoted text, click to view]

AddThis Social Bookmark Button