Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to use regsvr32 to register a .NET dll

346 views
Skip to first unread message

min

unread,
Dec 2, 2002, 4:49:32 PM12/2/02
to
Hi, all,

I know .NET dll developed in c# can be registered by regasm. But what
I need to do is to add another entry in regedit, then anotehr program
can find that dll.

I make a sample run using VB. After compile that dll, use regsvr32
register it. Then add an entry in regedit manually, the key is
whatever I like, the value is the ProgID. In vb, it is the
Project.modulename.

But I can't make it in .NET using C#. Even I register the dll using
regasm, then I add a new entry, value set to the namespace.dllName.
But the loading application complains about not being able to find the
factory.

I am new in C#, any help or clue is highly appreciated!

min

Lion Shi

unread,
Dec 3, 2002, 10:31:19 PM12/3/02
to
Hello Min,

You may apply the ProgIdAttribute to your class to specify a ProgId for
your class. This is a sample code:

[ClassInterface(ClassInterfaceType.AutoDispatch)]
[ProgId("InteropSample.MyClass")]
public class MyClass
{
public MyClass() {}
}

You may refer to the link below to get more detailed information about this
attribute:

http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemRuntimeInterop
ServicesProgIdAttributeClassTopic.asp

I hope this helps you.

Best regards,

Lion Shi [MS]
MCSE, MCSD
Microsoft Support Engineer

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. 2001 Microsoft Corporation. All rights
reserved.
--------------------
From: m_wa...@yahoo.com (min)
Newsgroups: microsoft.public.dotnet.languages.csharp
Subject: how to use regsvr32 to register a .NET dll
Date: 2 Dec 2002 13:49:32 -0800
Organization: http://groups.google.com/
Lines: 19
Message-ID: <a254a124.02120...@posting.google.com>
NNTP-Posting-Host: 65.112.82.2
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: posting.google.com 1038865772 4485 127.0.0.1 (2 Dec 2002
21:49:32 GMT)
X-Complaints-To: groups...@google.com
NNTP-Posting-Date: 2 Dec 2002 21:49:32 GMT
Path:
cpmsftngxa08!cppssbbsa01.microsoft.com!news-out.cwix.com!newsfeed.cwix.com!n
ews.maxwell.syr.edu!sn-xit-03!sn-xit-01!sn-xit-04!supernews.com!postnews1.go
ogle.com!not-for-mail
Xref: cpmsftngxa08 microsoft.public.dotnet.languages.csharp:112644
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp

min

unread,
Dec 4, 2002, 2:38:19 PM12/4/02
to
Yes. I have tried that way. But after registering using regasm, the
client application still can't find it.

I checked the registry, find the dll registered by regasm and the dll
registered by regsvr32 is different. Seems regasm wraps the dll to
make it compactiable with svr32.

Is there any way I can register the c# dll using regsvr32?

Thank you again and again for your replying!

min

lio...@online.microsoft.com (Lion Shi) wrote in message news:<QegbpW0mCHA.2384@cpmsftngxa08>...

Lion Shi

unread,
Dec 4, 2002, 8:48:38 PM12/4/02
to
Hello Min,

A .NET assembly can not be registered by regsvr32 directly, since it is not
a COM dll. You have to generate a COM wrapper (which is generated by
regasm.exe automatically) for it via tlbexp.exe utility, and register the
wrapper dll with regsvr32.

By the way, have you exposed any interface of your C# class? If you only
expose some methods and properties, the COM client can not find the object.
You may try applying the ClassInterfaceAttribute to your class to generate
a interface for all public methods and properties:

[ClassInterfaceAttribute(ClassInterfaceType.AutoDual)]
public class MyClass

I hope this helps.

Best regards,

Lion Shi [MS]
MCSE, MCSD
Microsoft Support Engineer

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. 2001 Microsoft Corporation. All rights
reserved.
--------------------
From: m_wa...@yahoo.com (min)
Newsgroups: microsoft.public.dotnet.languages.csharp

Subject: Re: how to use regsvr32 to register a .NET dll
Date: 4 Dec 2002 11:38:19 -0800
Organization: http://groups.google.com/
Lines: 84
Message-ID: <a254a124.02120...@posting.google.com>
References: <a254a124.02120...@posting.google.com>
<QegbpW0mCHA.2384@cpmsftngxa08>


NNTP-Posting-Host: 65.112.82.2
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit

X-Trace: posting.google.com 1039030700 30282 127.0.0.1 (4 Dec 2002
19:38:20 GMT)
X-Complaints-To: groups...@google.com
NNTP-Posting-Date: 4 Dec 2002 19:38:20 GMT
Path:
cpmsftngxa06!tkmsftngp01!newsfeed00.sul.t-online.de!t-online.de!news-spur1.m
axwell.syr.edu!news.maxwell.syr.edu!sn-xit-03!sn-xit-01!sn-xit-04!supernews.
com!postnews1.google.com!not-for-mail
Xref: cpmsftngxa06 microsoft.public.dotnet.languages.csharp:113777
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp

min

unread,
Dec 5, 2002, 3:53:47 PM12/5/02
to
Thank you sooo much for your replying! But I still can't make it work.

Is the wrapper dll named as *.tlb? I use the tlbexp to output to a
model.dll. Then use regsvr32 to register that dll, but get error
message:

"model.dll" is not an executable file and no registration helper is
registered for this file type.

I use [ClassInterface(ClassInterfaceType.AutoDispatch)] before. After
reading your posting, I tried this way:
[ProgId("MyModel.Model1")]
[ClassInterfaceAttribute(ClassInterfaceType.AutoDual)]
public class MyModel:MHModelPlugin.IMHModelPlugin

Then regasm the dll, add an entry in registry, but the COM client
still complains about loading the factory.

Any suggestion? Anything is highly appreciated!

min

lio...@online.microsoft.com (Lion Shi) wrote in message news:<KHwb9BAnCHA.2652@cpmsftngxa06>...

Lion Shi

unread,
Dec 5, 2002, 11:00:51 PM12/5/02
to
Hello Min,

Then you may need to register the library manually. To do this, please
genereate the registry file first with the follwing line (it doesn't update
the registry):

regasm myTest.dll /regfile:myTest.reg

And then edit the file based on your requirement before import it to the
registry.

Hope it helps.

Best regards,

Lion Shi [MSFT]


MCSE, MCSD
Microsoft Support Engineer

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. 2001 Microsoft Corporation. All rights
reserved.
--------------------
From: m_wa...@yahoo.com (min)
Newsgroups: microsoft.public.dotnet.languages.csharp
Subject: Re: how to use regsvr32 to register a .NET dll

Date: 5 Dec 2002 12:53:47 -0800
Organization: http://groups.google.com/
Lines: 170


Message-ID: <a254a124.02120...@posting.google.com>
References: <a254a124.02120...@posting.google.com>
<QegbpW0mCHA.2384@cpmsftngxa08>

<a254a124.02120...@posting.google.com>
<KHwb9BAnCHA.2652@cpmsftngxa06>


NNTP-Posting-Host: 65.112.82.2
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit

X-Trace: posting.google.com 1039121627 18550 127.0.0.1 (5 Dec 2002
20:53:47 GMT)
X-Complaints-To: groups...@google.com
NNTP-Posting-Date: 5 Dec 2002 20:53:47 GMT
Path:
cpmsftngxa06!tkmsftngp01!newsfeed00.sul.t-online.de!t-online.de!news-spur1.m
axwell.syr.edu!news.maxwell.syr.edu!sn-xit-03!sn-xit-06!sn-xit-08!supernews.
com!postnews1.google.com!not-for-mail
Xref: cpmsftngxa06 microsoft.public.dotnet.languages.csharp:114142
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp

min

unread,
Dec 6, 2002, 10:43:24 AM12/6/02
to
Hi, Lion,

Thank you so much for your help! I even don't know how to express my
appreciate!
The problem is that I didn't place the dll in the same folder as the
COM consumer, or I didn't use GACUTIL to bring it to the global cach
either.

Thank you again for your valuable help!

min

lio...@online.microsoft.com (Lion Shi) wrote in message news:<U3I6VwNnCHA.2652@cpmsftngxa06>...

0 new messages