7

I'm using Visual Studio 2022, v17.0.4. I want to create new key for my assembly to strongly name it. According to documentation: "In the Choose a strong name key file box, choose Browse, and then navigate to the key file. To create a new key file, choose New and enter its name in the Create Strong Name Key dialog box".Docs

Can't find NEW button. here is an image 1

In old Visual studio it was quite easy but in new VS2022 can't find NEW button. here is an image 2

Please help!

jessehouwing
  • 106,458
  • 22
  • 256
  • 341
Developer Mister
  • 572
  • 3
  • 11
  • From https://learn.microsoft.com/en-gb/dotnet/standard/assembly/strong-named: "For .NET Core and .NET 5+, strong-named assemblies do not provide material benefits. The runtime never validates the strong-name signature, nor does it use the strong-name for assembly binding." VS2022 still has the 'New' option for signing a .NET Framework assembly, so evidently you are attempting to use strong naming with a. NET Core/.NET 5+ project. Is there a reason why? What benefits are you hoping to get from it? – Luke Woodward Dec 27 '21 at 22:08
  • So please show me the "NEW" option, I can't find it. strong name is needed to test internal and protected classes – Developer Mister Dec 28 '21 at 08:47
  • 1
    Can you use the `sn.exe` tool with the `-k` option to generate a new keypair (https://learn.microsoft.com/en-us/dotnet/framework/tools/sn-exe-strong-name-tool)? You'll need to run this from an elevated VS2022 Developer Command Prompt or PowerShell window. – Luke Woodward Dec 28 '21 at 12:27
  • @LukeWoodward Thanks but I Know about it... you did not reed my question and did not see images – Developer Mister Dec 28 '21 at 17:47
  • 1
    If you know about `sn.exe`, then your question only concerns why the option to create a new signing key for a .NET Core/.NET 5+ assembly has been removed from Visual Studio 2022. I've seen your images, and I have run VS2022 myself and seen that the option you are looking for is indeed not there. Why it is not there is a question for the Visual Studio team, so you might like to try asking it at https://developercommunity.visualstudio.com/report?entry=suggestion&space=8 instead. – Luke Woodward Dec 28 '21 at 21:50
  • 1
    Ok, I asked (for you) see: https://github.com/dotnet/docs/issues/27695 – Luuk Jan 01 '22 at 14:48
  • @Luuk can you please ask this question also ( https://stackoverflow.com/questions/70549446/visual-studio-2022-brace-matching-is-not-working-correctly ). I've already asked here ( https://developercommunity2.visualstudio.com/t/Matching-a-closing-brace-in-Visual-Studi/1626691 ) but reaction on your question is faster :) – Developer Mister Jan 04 '22 at 16:31
  • 1
    Reaction was faster because of 2 things. 1) this question will be solved (probably) by changing some docs. 2) Your 'other' problem is way more difficult, and seems to be an existing problem in older versions tooo..... (so, more work to fix) – Luuk Jan 04 '22 at 17:15

2 Answers2

-1

Here is the MSFT documentation on creating new key files. Kind of annoying they removed this being one-click from within the UI, but I think the idea is to have people understand they are creating a self-signed certificate, and hopefully have them start to use certificates that are actually within a traceable certification authority. https://learn.microsoft.com/en-us/dotnet/standard/assembly/sign-strong-name

Michael Blackburn
  • 3,161
  • 1
  • 25
  • 18
-2
  1. Create new key "mykey.pfx" with password from choose a strong name key file as above

  2. add strong name to your key file using developer command prompt:

sn /k "D:\Projects\mykey.pfx"

  1. build the solution. If you got an error "Cannot import the keyfile.. VS_KEY_xxxx container", install the strong name certificate to the CSP manually:

sn -i "D:\Projects\mykey.pfx" VS_KEY_xxxx

where "VS_KEY_xxxx" same as container you got in the error

blue
  • 1