Enhancing signed assembly fails

9 posts, 0 answers
  1. Vincent
    Vincent avatar
    2 posts
    Member since:
    Oct 2012

    Posted 04 Jun 2009 Link to this post

    Hi, I'm trying to enhance a signed assembly with a MSBuild script using the "OpenAccessEnhancer" using the following statement

     <OpenAccessEnhancer  

     

    Assembly="<path>\obj\Release\MyModel.dll"  

     

    KeyFile="<path>\MyKey.snk" >

    <

     

    Output TaskParameter="Version" PropertyName="OpenAccessEnhancerVersion" />

     

     

     </

     

    OpenAccessEnhancer>

    When I run this I can see in the log that it enhances the class, but then it stops with the error "OpenAccess Enhancer error 0: Generated method is null. Usually this indicates, that assembly signing is used with an external key store. Please use an AssemblyKeyFileAttribute instead."

    Because I keep getting te error message  I tried the same thing using the commandline utility "venhance.exe". But this gives the same error message.

    Using the "AssemblyKeyFileAttribute" I'm able to enhance the project. But I don't want to use a AssemblyKeyFileAttribute because that's relative to my file system and not the system on which the automated build will run.

    My Visual Studio is able to build and enhance the assembly without this attribute. Therefore I've cut and past the command, used by Visual Studio (build output window), in a command prompt expecting a successfull enhancement. But even this give the same error as before.

    Why is Visual Studio able to Enhance the project and is it not possible from the command line (or MSBuild script)? What am I doing wrong?

    I'm using Visual Studio 2008 and 'Telerik OpenAccess Enhancer, Version 2009.1.311.1'

    With regards,

    Vincent

     

     

     

     

     

  2. Thomas
    Admin
    Thomas avatar
    590 posts

    Posted 04 Jun 2009 Link to this post

    Hi Vincent,

    please have a look at the OpenAccess.targets file from the Telerik\OpenAccess ORM\sdk folder.
    There you will see the full invocation of the enhancer:
     <OpenAccessEnhancer 
                VerboseMode="$(EnhancementOutputLevel)" 
                Assembly="@(IntermediateAssembly->'%(FullPath)')" 
                SignAssembly="$(SignAssembly)" 
                KeyFile="$(AssemblyOriginatorKeyFile)" 
                KeyContainer="$(KeyContainerName)" 
                References="@(ReferencePath)" 
                ProjectReferences="@(ProjectReference)"
                <Output TaskParameter="Version" PropertyName="OpenAccessEnhancerVersion" /> 
            </OpenAccessEnhancer> 
     


    I guess that the SignAssembly setting needs to be given in addition.

    Greetings,
    Thomas
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. DevCraft banner
  4. Vincent
    Vincent avatar
    2 posts
    Member since:
    Oct 2012

    Posted 04 Jun 2009 Link to this post

    I've tried to specify all properties. But that doesn't matter. It still gives me the same error.

    Visula Studio only specifies the assembly and keyfile properties when calling the venhance.exe. But when I execute the same command in a command prompt I get the same error as when using MSBuild.
  5. James Denning
    James Denning avatar
    24 posts
    Member since:
    Apr 2009

    Posted 05 Jun 2009 Link to this post

    Just to add to this but for using the enhancer within the Visual Studio add-in/VSIP,  not MSBuild - my enhanced assemblies need signing now and i want to use a relative path to a single keyfile for all my assemblies eg AssemblyKeyFileName("..\\\..\\MyKeyFile,pfx") - this doesn;t work with openaccess - I get the same error as the OP, then i try the "keyfile:..\..\mykeyfile" switch on the compiler (within VS this is set in the VS project properties "Conditional compilation symbols" field) but this doesn't sign the assembly at all. It seems this is a major problem as AssemblyKeyFileAttribute seems to be deprecated or soemthing as the compiler or VS don't like it - but then you the openaccess enhancer complains that it can;t find the key file with a relative path -   this is seriously limiting as the keyfile will ahve to be in the sam eplace in all build environments, as the KeyFile attribute is hardcoded (it could be added in MSBuild in an autogenerated file at build time but this would need a custom project/msbuild script). I wonder if an environment variable could be used.

    Also for the KeyFileNameAttribute the key file needs to be a .SNK file generated by sn.exe NOT the snk.pfx generated within Visual Studio.
  6. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 08 Jun 2009 Link to this post

    Hello Vincent,

    I am afraid you will have to use the AssemblyKeyFileAttribute anyways. Sorry for the inconvenience but we are unable to provide you with a workaround for this. In fact, what you see in the output is not the exact command that is executed by Visual Studio, it has a different way to call the enhancer.

    Best wishes,
    Alexander
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  7. James Denning
    James Denning avatar
    24 posts
    Member since:
    Apr 2009

    Posted 18 Jun 2009 Link to this post

    Is there any chance of making Telerik allow the assembly key file attribute value to be a relative path instead of absolute as this is causing problems for me?

    James
  8. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 19 Jun 2009 Link to this post

    Hi James Denning,

    Yes, the path is relative to the project's path. So if the key file is in the project directory, you can just specify its name:
    [assembly: AssemblyKeyFileAttribute("key.snk")] 


    Greetings,
    Alexander
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  9. James Denning
    James Denning avatar
    24 posts
    Member since:
    Apr 2009

    Posted 19 Jun 2009 Link to this post

    Ok this is within VS2008 using the OPenAccess VSIP/Add-in, not MSBuild targets.  It seems to be looking in 'C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE' for the keyfile if I specify it as just the file name in the AssemblyKeyFile Attribute  - I have to use an absolute path, here's the error message:

    Error 10 OpenAccess Error: Enhancer: Could not open the key file 'MyKeyFile.snk'.
    You should use an absolute file name.
    Reason: Could not find file 'C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\Pinpoint.snk'. MyAssembly.dll 

    I want to keep one keyfile for all assemblies in one place and that place should be relative to the project folders, regardless of where they are on the file system. Any chance this could be looked at?
  10. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 19 Jun 2009 Link to this post

    Hello James,

    Are you sure you have specified the correct relative path in the attribute? I have just tested moving the .snk file around and it worked fine. And I got the same exception when intentionally set a wrong file name.

    Greetings,
    Alexander
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top
DevCraft banner