Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StrongNameKeyBlob method not found using .NET 4.7.2 #52

Open
bgavrilMS opened this issue Oct 27, 2020 · 3 comments
Open

StrongNameKeyBlob method not found using .NET 4.7.2 #52

bgavrilMS opened this issue Oct 27, 2020 · 3 comments

Comments

@bgavrilMS
Copy link

  1. Create a project that targets both netcoreapp3.1 and net472, for example a test project that you want to run on both .net core and .net classic. Example here.
  2. Add StrongNamer and a reference to an assembly that is not strong named (e.g. Selenium)
  3. Build from VS 2019 or via msbuild.

Actual:
2>C:\Users\bogavril.nuget\packages\strongnamer\0.2.5\build\StrongNamer.targets(30,5): error MSB4018: The "StrongNamer.AddStrongName" task failed unexpectedly.
2>C:\Users\bogavril.nuget\packages\strongnamer\0.2.5\build\StrongNamer.targets(30,5): error MSB4018: System.MissingMethodException: Method not found: 'Void Mono.Cecil.WriterParameters.set_StrongNameKeyBlob(Byte[])'.
2>C:\Users\bogavril.nuget\packages\strongnamer\0.2.5\build\StrongNamer.targets(30,5): error MSB4018: at StrongNamer.AddStrongName.ProcessAssembly(ITaskItem assemblyItem, Byte[] keyBytes, StrongNamerAssemblyResolver resolver)
2>C:\Users\bogavril.nuget\packages\strongnamer\0.2.5\build\StrongNamer.targets(30,5): error MSB4018: at StrongNamer.AddStrongName.Execute()
2>C:\Users\bogavril.nuget\packages\strongnamer\0.2.5\build\StrongNamer.targets(30,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
2>C:\Users\bogavril.nuget\packages\strongnamer\0.2.5\build\StrongNamer.targets(30,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext()

Note: if I target just NetCore or NetFx it all works fine.

@AndrewRybka
Copy link

AndrewRybka commented Nov 3, 2020

One of our developers experiences the same error with StrongNamer 0.2.5 and projects that target net472 only.

@rboy1
Copy link

rboy1 commented Feb 11, 2023

I'm seeing the same issue with .net 4.8 @AndrewRybka @bgavrilMS
It looks like StrongNamer doesn't work with anything after .net 4.6.1

Anyone know how to fix this or a workaround because I still need a strong name for my files but I also need to target .net 4.8
Open to ideas

@bgavrilMS
Copy link
Author

bgavrilMS commented Feb 13, 2023

Well, the meta solution is for all dependencies to be strong named. Microsoft's guidance suggests this, even for open source projects. For example in MSAL we keep the full sn key in the public repo https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/blob/main/build/MSAL.snk ; Strong Naming is not a security feature, so this is doable.

So my suggestion is to identify those dependencies which are not strong named (including those that use that partial strong-naming stuff, which can be considered obsolete).

  • if internal, strong name it
  • if external, find a replacement or ask the maintainer to strong name

All that being said, some external dependencies are still not signed (e.g. WebDriver.dll) and replacing them is not easy. We don't seem to have this problem on our test projects - running on NET6 and on .NET 4.8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants