This is a migrated thread and some comments may be shown as answers.

Enhancing signed assembly fails

8 Answers 153 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Vincent
Top achievements
Rank 1
Vincent asked on 04 Jun 2009, 11:09 AM
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

 

 

 

 

 

8 Answers, 1 is accepted

Sort by
0
Thomas
Telerik team
answered on 04 Jun 2009, 03:07 PM
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.
0
Vincent
Top achievements
Rank 1
answered on 04 Jun 2009, 03:14 PM
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.
0
James Denning
Top achievements
Rank 1
answered on 05 Jun 2009, 02:03 PM
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.
0
Alexander
Telerik team
answered on 08 Jun 2009, 05:58 AM
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.
0
James Denning
Top achievements
Rank 1
answered on 18 Jun 2009, 02:05 PM
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
0
Alexander
Telerik team
answered on 19 Jun 2009, 05:31 AM
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.
0
James Denning
Top achievements
Rank 1
answered on 19 Jun 2009, 08:14 AM
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?
0
Alexander
Telerik team
answered on 19 Jun 2009, 04:34 PM
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.
Tags
General Discussions
Asked by
Vincent
Top achievements
Rank 1
Answers by
Thomas
Telerik team
Vincent
Top achievements
Rank 1
James Denning
Top achievements
Rank 1
Alexander
Telerik team
Share this question
or