Register a .NET DLL???

J

John\\

I created a simple DLL called: MyDLL

I have been trying to register it so I can see it in the COM References;

Regsvr32 does not work for .NET DLL

RegAsm - seems to work, but I can not select the DLL from the Add COM
References.

I can not choose Browse as this is not an option in the application I am
trying to use it...

VB6 DLL's are no problem, so I would have thought that a .NET DLL would be
just as easy...


Thanks in advance for any help you can give me,


J.
 
P

pvdg42

John\ said:
I created a simple DLL called: MyDLL

I have been trying to register it so I can see it in the COM References;

Regsvr32 does not work for .NET DLL

RegAsm - seems to work, but I can not select the DLL from the Add COM
References.

I can not choose Browse as this is not an option in the application I am
trying to use it...

VB6 DLL's are no problem, so I would have thought that a .NET DLL would be
just as easy...


Thanks in advance for any help you can give me,


J.
If you select Project->Add Reference, then click the .NET tab in the Add
Reference dialog, do you then see your DLL?
 
J

John\\

No, I do not see it... In either the .NET, or COM. I really want to see it
in the COM tab...
 
C

Clive Dixon

If I understand you right, why are you trying to use a .NET assembly as a
COM component in a client .NET application? Why are you not using it
directly as a .NET component?

Visual Studio will not allow you to import a .NET DLL into a .NET project as
a COM component. What's the point?
 
J

John\\

I am trying to create a .NET DLL to use in NAVISION. I am using .NET
Executable as an example as not many people know Navision.
We have created VB6 DLL's in the past, but I would like to see if .NET would
be easier as the deployment would be much simpler.

When we create a VB6 DLL, we would just REGSVR32 it and that is it. We can
select it as a reference within Navision, but with .NET I am not able to do
this.

Thanks,
 
C

Clive Dixon

Like I said, VS does not let you do it, neither does tlbimp.exe allow you to
generate an interop assembly from a tlb which was generated from an
assembly. Why have a middleman when you can use it directly?

You could try using the TypeLibConverter class to see if that would do it,
but I wouldn't bank on it. If that doesn't work I'm not sure what you can do
apart from writing your own interop assembly, but what would be the point of
that? Maybe you could tinker with the tlb in some way to fool tlbimp.exe,
but I wouldn't know how to do that if it's even possible. It all seems like
a whole lot of tedious and unnecessary work when you could just use your
..NET assembly directly.
 
N

NuTcAsE

You need to create a COM callable wrapper for your .net assembly to
make it appear in COM References in Navision. Here are the steps:

1. Add the following attributes to your classes

[Guid("use GUIDGen.exe to create GUID for urself")]
[ClassInterface(ClassInterfaceType.None)]
[ProgId("MyApp.MyClass")]

Each class should have a unique GUID, and ProdID

2. Make your classes implmenent interfaces. (Not strictly required but
is good practice to make sure that COM callable wrappers work without
hitches). Example below:

[Guid(...)]
[InterfaceType.ComInterfaceType.InterfaceIsIDispatch)]
public interface MyInterface
{
//Method definitions go here...
}

[Guid(...)]
[ClassInterface(ClassInterfaceType.None)]
[ProgId("MyApplication.MyClass")]
public class MyClass : MyInterface
{
//Interface implementation goes here...
}

3. If you are using VS.Net then do the following or goto step 4:
In project properties set the properties Register for Com Interop
to true. Now when you build the project, a COM Wrapper will be created
and registered. It should show up in COM References tab

4. Use regasm to register the ccw (com callable wrapper) of the
assembly. Optionally use the /tlb: switch to generate a type library
for the .net assembly.

After these steps you should be good to go... For more information
check the following links:

http://msdn.microsoft.com/library/d...n-us/cpguide/html/cpconcomcallablewrapper.asp
- CCW MSDN Docs
http://weblogs.asp.net/psteele/archive/2004/06/16/157767.aspx - RegAsm
and COM

Hope this helps...
- NuTcAsE
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top