Strong name assemblies

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Patrick Kowalzick

    Strong name assemblies

    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::A ssemblyVersion( "1.0.0.0")];
    [assembly:System ::Reflection::A ssemblyKeyFileA ttribute("stron g_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.dl l does not represent a strongly named assembly"

    -compiling in the command line using

    cl /LD shtrong_name.cp p /clr

    and testing again with
    sn -v strong_name.dll

    returns:
    "Assembly 'strong_name.dl l' 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


  • Patrick Kowalzick

    #2
    Re: Strong name assemblies

    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" <Patrick.Kowalz ick@cern.ch> wrote in message
    news:eNWf7w%23w DHA.1764@TK2MSF TNGP10.phx.gbl. ..[color=blue]
    > 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::A ssemblyVersion( "1.0.0.0")];
    >[/color]
    [assembly:System ::Reflection::A ssemblyKeyFileA ttribute("stron g_name.snk")];[color=blue]
    >
    > 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.dl l does not represent a strongly named assembly"
    >
    > -compiling in the command line using
    >
    > cl /LD shtrong_name.cp p /clr
    >
    > and testing again with
    > sn -v strong_name.dll
    >
    > returns:
    > "Assembly 'strong_name.dl l' 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[/color]
    :-(.[color=blue]
    >
    > Any ideas?
    >
    > Thank you very much,
    > Patrick
    >
    >[/color]


    Comment

    • Ronald Laeremans [MSFT]

      #3
      Re: Strong name assemblies

      Can you explain how it "prevents"t he signing?

      Ronald Laeremans
      Visual C++ team

      "Patrick Kowalzick" <Patrick.Kowalz ick@cern.ch> wrote in message
      news:OdzbqOAxDH A.2156@TK2MSFTN GP09.phx.gbl...[color=blue]
      > I solved this Problem now by reading an articel about pre-compiled[/color]
      headers.[color=blue]
      > I moved the #include<stdafx .h> to the very top and it compiles and could[/color]
      be[color=blue]
      > 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[/color]
      achieve[color=blue]
      > this or what am I doing wrong?
      >
      > Thank you,
      > Patrick
      >
      > "Patrick Kowalzick" <Patrick.Kowalz ick@cern.ch> wrote in message
      > news:eNWf7w%23w DHA.1764@TK2MSF TNGP10.phx.gbl. ..[color=green]
      > > 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 ->[/color][/color]
      ..NET ->[color=blue][color=green]
      > > Class Library (.NET)
      > > in the main file I add the lines at the beginning of the file
      > >
      > > #using <mscorlib.dll >
      > > [assembly:System ::Reflection::A ssemblyVersion( "1.0.0.0")];
      > >[/color]
      >[/color]
      [assembly:System ::Reflection::A ssemblyKeyFileA ttribute("stron g_name.snk")];[color=blue][color=green]
      > >
      > > 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.dl l does not represent a strongly named assembly"
      > >
      > > -compiling in the command line using
      > >
      > > cl /LD shtrong_name.cp p /clr
      > >
      > > and testing again with
      > > sn -v strong_name.dll
      > >
      > > returns:
      > > "Assembly 'strong_name.dl l' is valid"
      > >
      > >
      > > So I searched in the compiler and linker options, but I do not really[/color][/color]
      get[color=blue][color=green]
      > > the clue, which part of the options prevents my dll to be strong named[/color]
      > :-(.[color=green]
      > >
      > > Any ideas?
      > >
      > > Thank you very much,
      > > Patrick
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • Patrick Kowalzick

        #4
        Re: Strong name assemblies

        Hello Ronald,
        [color=blue]
        > Can you explain how it "prevents"t he signing?[/color]

        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::A ssemblyKeyFileA ttribute("stron g_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 [MSFT]" <ronaldl@online .microsoft.com> wrote in message
        news:%23bIXB8Bx DHA.1576@TK2MSF TNGP11.phx.gbl. ..[color=blue]
        >
        > Ronald Laeremans
        > Visual C++ team
        >
        > "Patrick Kowalzick" <Patrick.Kowalz ick@cern.ch> wrote in message
        > news:OdzbqOAxDH A.2156@TK2MSFTN GP09.phx.gbl...[color=green]
        > > I solved this Problem now by reading an articel about pre-compiled[/color]
        > headers.[color=green]
        > > I moved the #include<stdafx .h> to the very top and it compiles and could[/color]
        > be[color=green]
        > > verified as a strong named dll.
        > >
        > > But here is my next Problem:
        > > Including e.g. <algorithm> , which truly is a subset of ANSI C++[/color][/color]
        prohibits[color=blue][color=green]
        > > to compile a dll with strong names. Are there any hints how I could[/color]
        > achieve[color=green]
        > > this or what am I doing wrong?
        > >
        > > Thank you,
        > > Patrick
        > >
        > > "Patrick Kowalzick" <Patrick.Kowalz ick@cern.ch> wrote in message
        > > news:eNWf7w%23w DHA.1764@TK2MSF TNGP10.phx.gbl. ..[color=darkred]
        > > > 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 ->[/color][/color]
        > .NET ->[color=green][color=darkred]
        > > > Class Library (.NET)
        > > > in the main file I add the lines at the beginning of the file
        > > >
        > > > #using <mscorlib.dll >
        > > > [assembly:System ::Reflection::A ssemblyVersion( "1.0.0.0")];
        > > >[/color]
        > >[/color]
        >[/color]
        [assembly:System ::Reflection::A ssemblyKeyFileA ttribute("stron g_name.snk")];[color=blue][color=green][color=darkred]
        > > >
        > > > 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.dl l does not represent a strongly named assembly"
        > > >
        > > > -compiling in the command line using
        > > >
        > > > cl /LD shtrong_name.cp p /clr
        > > >
        > > > and testing again with
        > > > sn -v strong_name.dll
        > > >
        > > > returns:
        > > > "Assembly 'strong_name.dl l' is valid"
        > > >
        > > >
        > > > So I searched in the compiler and linker options, but I do not really[/color][/color]
        > get[color=green][color=darkred]
        > > > the clue, which part of the options prevents my dll to be strong named[/color]
        > > :-(.[color=darkred]
        > > >
        > > > Any ideas?
        > > >
        > > > Thank you very much,
        > > > Patrick
        > > >
        > > >[/color]
        > >
        > >[/color]
        >
        >[/color]


        Comment

        Working...