Interop component with strong name

K

Kimmo Laine

Hi,

we are using COM server through interop, and would like to sign our assembly
with strong name. But when building, we get the following error: "Assembly
generation failed -- Referenced assembly 'Interop.MyComServer' does not have
a strong name."

How can is sign my COM server with strong name?


thx

Kimmo Laine
 
P

Peter Rilling

1) Use the sn.exe program that is included with the SDK to generate a
public/private key file.
2) Reference the key file in the AssemblyInfo file with the AssemblyKeyFile
attribute.

That should do it.
 
M

Mohamoss

Hi Kimmo
May be I didn't get you right but I think you have and old com that you are
calling form a .net assembly which the VS should do for you?? . any way ,
you have an assembly that you want to sign with a strong name . what you
should do is
Generate a key file using the utility sn.exe with the argument -k and a
name of a file .snk like sn k- myfile.snk
Then open you assemblyinfo file and add the location of the key to the tag
[assembly: AssemblyKeyFile("the uri of you file")] then recompile.

Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC
 
K

Kimmo Laine

Hi Peter,

i did it, but the compiler can´t use it because the referenced COM server is
not signed with strong name. Is there a way to sign the server (not .NET
code) with strong name.

Kimmo Laine
 
K

Kimmo Laine

Hi Mohamed,

you get me right! I did generate the key file, but compiler cannot use it
because the old COM server is not signed. Is there a way to sign this old
server somehow or to tell the compiler to ignore it.

Kimmo Laine
 
N

Nicholas Paldino [.NET/C# MVP]

Kimmo,

As indicated in other posts, you need to create a strong name using the
SN.EXE utility. However, you can not sign the COM assembly. The compiler
error is being raised because the interop assembly itself is not signed.
Instead of setting a reference to the COM component in your project through
VS.NET, you will have to run TLBIMP.EXE on the DLL that you want to use in
your program. When you run it, you can sign it using the /keyfile switch
(pointing to the output of SN.EXE). Once you have done that, set a
reference to that in your project in VS, and then compile. It should
compile fine.

Hope this helps.
 
P

Peter Rilling

If that is the problem, then Kimmo could also set the "Wrapper Assembly Key
File" property in the property dialog for the project to sign those interop
assemblies, right?

Nicholas Paldino said:
Kimmo,

As indicated in other posts, you need to create a strong name using the
SN.EXE utility. However, you can not sign the COM assembly. The compiler
error is being raised because the interop assembly itself is not signed.
Instead of setting a reference to the COM component in your project through
VS.NET, you will have to run TLBIMP.EXE on the DLL that you want to use in
your program. When you run it, you can sign it using the /keyfile switch
(pointing to the output of SN.EXE). Once you have done that, set a
reference to that in your project in VS, and then compile. It should
compile fine.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Kimmo Laine said:
Hi,

we are using COM server through interop, and would like to sign our assembly
with strong name. But when building, we get the following error: "Assembly
generation failed -- Referenced assembly 'Interop.MyComServer' does not have
a strong name."

How can is sign my COM server with strong name?


thx

Kimmo Laine
 

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

Top