Strong name assemblies

P

Patrick Kowalzick

Dear NG,

I am trying to build a strong named library with Visual C++.

-Therefore I am generating a key pair using
sn -k strong_name.snk

-Create a new Project in the Visual Studio: Visual C++ Projects -> .NET ->
Class Library (.NET)
in the main file I add the lines at the beginning of the file

#using <mscorlib.dll>
[assembly:System::Reflection::AssemblyVersion("1.0.0.0")];
[assembly:System::Reflection::AssemblyKeyFileAttribute("strong_name.snk")];

and put the strong_name.snk in the Project Dir (and a copy in the
Debug/Release for testing).

-after compiling I test with
sn -v strong_name.dll

which returns:
"strong_name.dll does not represent a strongly named assembly"

-compiling in the command line using

cl /LD shtrong_name.cpp /clr

and testing again with
sn -v strong_name.dll

returns:
"Assembly 'strong_name.dll' is valid"


So I searched in the compiler and linker options, but I do not really get
the clue, which part of the options prevents my dll to be strong named :-(.

Any ideas?

Thank you very much,
Patrick
 
P

Patrick Kowalzick

I solved this Problem now by reading an articel about pre-compiled headers.
I moved the #include<stdafx.h> to the very top and it compiles and could be
verified as a strong named dll.

But here is my next Problem:
Including e.g. <algorithm> , which truly is a subset of ANSI C++ prohibits
to compile a dll with strong names. Are there any hints how I could achieve
this or what am I doing wrong?

Thank you,
Patrick
 
R

Ronald Laeremans [MSFT]

Can you explain how it "prevents"the signing?

Ronald Laeremans
Visual C++ team

Patrick Kowalzick said:
I solved this Problem now by reading an articel about pre-compiled headers.
I moved the #include<stdafx.h> to the very top and it compiles and could be
verified as a strong named dll.

But here is my next Problem:
Including e.g. <algorithm> , which truly is a subset of ANSI C++ prohibits
to compile a dll with strong names. Are there any hints how I could achieve
this or what am I doing wrong?

Thank you,
Patrick

Patrick Kowalzick said:
Dear NG,

I am trying to build a strong named library with Visual C++.

-Therefore I am generating a key pair using
sn -k strong_name.snk

-Create a new Project in the Visual Studio: Visual C++ Projects -> ..NET ->
Class Library (.NET)
in the main file I add the lines at the beginning of the file

#using <mscorlib.dll>
[assembly:System::Reflection::AssemblyVersion("1.0.0.0")];
[assembly:System::Reflection::AssemblyKeyFileAttribute("strong_name.snk")];
and put the strong_name.snk in the Project Dir (and a copy in the
Debug/Release for testing).

-after compiling I test with
sn -v strong_name.dll

which returns:
"strong_name.dll does not represent a strongly named assembly"

-compiling in the command line using

cl /LD shtrong_name.cpp /clr

and testing again with
sn -v strong_name.dll

returns:
"Assembly 'strong_name.dll' is valid"


So I searched in the compiler and linker options, but I do not really get
the clue, which part of the options prevents my dll to be strong named :-(.

Any ideas?

Thank you very much,
Patrick
 
P

Patrick Kowalzick

Hello Ronald,
Can you explain how it "prevents"the signing?

I will try to explain, but I am neither sure expressing me "really" correct
nor have I solid knowledge of the .NET concepts. But there are a few things
I am wondering about, but itmay be off-topic whilst it is not related
directly to the language.

-when <algorithm> is included the "test" sn -v strong_name.dll always
returns that the dll is not a strong named lib.
just commenting out the line with the include results in a strong named dll
(again just sn -k ...).

-when algorithm is included and I change the filename in the line
[assembly:System::Reflection::AssemblyKeyFileAttribute("strong_name.snk")];
in a key name what does not exist the program still compiles fine without
any warning.
Without the include the compilers stops with an error message.

I hope my installation of the framework ist correct and I will try to search
today a lit further.
Help -> About shows:
Microsoft Development Envronment 2003 Version 7.1.3088
Microsoft .NET Framework 1.1 Version 1.1.4322

Thx,
Patrick


Ronald Laeremans said:
Ronald Laeremans
Visual C++ team

Patrick Kowalzick said:
I solved this Problem now by reading an articel about pre-compiled headers.
I moved the #include<stdafx.h> to the very top and it compiles and could be
verified as a strong named dll.

But here is my next Problem:
Including e.g. <algorithm> , which truly is a subset of ANSI C++ prohibits
to compile a dll with strong names. Are there any hints how I could achieve
this or what am I doing wrong?

Thank you,
Patrick

Patrick Kowalzick said:
Dear NG,

I am trying to build a strong named library with Visual C++.

-Therefore I am generating a key pair using
sn -k strong_name.snk

-Create a new Project in the Visual Studio: Visual C++ Projects -> .NET ->
Class Library (.NET)
in the main file I add the lines at the beginning of the file

#using <mscorlib.dll>
[assembly:System::Reflection::AssemblyVersion("1.0.0.0")];
[assembly:System::Reflection::AssemblyKeyFileAttribute("strong_name.snk")];
 

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