locked
How to strong name sign a WinMD file? RRS feed

  • Question

  • Hi Experts,

        I'm writing a windows runtime component in a WinMD file for metro apps.  Because I have to distribute the WinMD file to others to use,  I have to sign the WinMD file with strong name.  When I check the signing option in project property page in VS2012RC, the output winMD file is not strong name signed, I don't know why. 

    Second question, I use "csc.exe /debug- ......" to compile the winmdObj(this means not to generate the debug information),

    and use winmdExp.exe to export to a Winmd file,

    then use  "Sn -Ra ...." command to sign the output winMd file.  

    The winmd file seem to be signed successfully,  but, when I create a new C# project which references to the winmd file and uses the component from the winmd file, then Press F5 key to run the C# project from VS2012RC,  and Exception will be thrown, which says the constructor is not implemented,  How can it be possible!!!!,  while I Press Ctrl+F5 to run the project directly, it works fine, no exception is there.    Why the exception was there when I debug the project???    I think this might be a bug of the visual studio debugger, because when I create a JavaScript project to use the winmd file, and press F5 to debug the project, it works fine.  Am I right?

    So, In a word,  my question is:

    1) Can a winmd file be strong name signed? And how to sign if it is true.  Why visual studio did not sign the output winmd file automaticlly even if I checked the signing option for the project ?

    2) After a I signed the winmd file manually, why the exception is there when I debug the C# project?  and why not when debug the javascript project?

    Thanks very much.




    • Edited by Neil Pang Thursday, July 5, 2012 7:57 AM spell error
    Thursday, July 5, 2012 7:54 AM

All replies

  • Does anyone know?

    Neil

    Friday, July 6, 2012 5:58 AM
  • Hello,

     

    Thanks for your feedback, I will involve more experts to investigate it.

     

    Best regards,

    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, July 12, 2012 12:14 PM
  • Thanks, I am still waiting here.

    Neil

    Friday, July 13, 2012 1:09 AM
  • Hello,

     

    Thanks for your feedback, I will involve more experts to investigate it.

     

    Best regards,

    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    Thanks. I am still waiting here.

    Neil

    Friday, July 13, 2012 1:13 AM
  • I'm looking for answer to this as well. If there is a topic on MSDN that covers what it means to use the strong name utility (sn.exe) and .snk files on WinRT components in general that would be extremely helpful. On WinRT .exe files with sn -vf reports "valid", but on my .winmd file it says: "ModuleNameHere.winmd is a delay-signed or test-signed assembly". If this makes no sense I would expect the build to fail.

    For the record, I hand edited the .csproj file to include:

        <DelaySign>false</DelaySign>
        <SignAssembly>true</SignAssembly>
        <AssemblyOriginatorKeyFile>TheKeyFile.snk</AssemblyOriginatorKeyFile>

    Thanks,

    Mark


    Sunday, August 26, 2012 7:58 PM
  • Are there any updates on this? I am unable to sign my .winmd file via Visual Studio as well. Is there a recommended way to do this?
    Friday, March 22, 2013 5:36 PM
  • I tried and I can strong name windows runtime component (winmd). See snapshot. 

    What kind of error you are getting when you are trying to strong name the winmd file(Project Settings -> Signing -> Check Sign the assembly -> snk Key file)?


    Thanks, Sachin


    • Edited by Sachin S Friday, March 22, 2013 6:41 PM
    Friday, March 22, 2013 6:38 PM
  • Thanks Sachin, I am able to do this as well and don't get any errors but when I verify the strong name signed winmd file via:

    sn -vf xyz.winmd

    I get:

    "xyz.winmd is a delay-signed or test-signed assembly"

    But... I just found out that if I sign from the command line, post build:

    sn.exe -R xyz.winmd xyz.snk

    Then it says:

    Assembly 'xyz.winmd' is valid

    So, it appears that VS strong name signing isn't working with winmd files -- or I am just misunderstanding something. Note: VS does work correctly on .exe flies, just not winmd.

    Friday, March 22, 2013 7:09 PM
  • Yes you are right, VS signs the assembly but verification say it is test or delay signed. Something is definitely wrong with VS signing thing.

    Thanks, Sachin


    • Edited by Sachin S Friday, March 22, 2013 7:34 PM
    Friday, March 22, 2013 7:33 PM