Comments (9)
@rboy1 Works just fine here.
- Created a new VS 2022 console app targeting .NET 4.8.
- Added NuGet package for OSVersionExt
- Added sample code and ran to test output successfully.
- Enable strong name signing:
- Rebuilt to verify the reference error:
- Added Brutal.Dev.StrongNameSigner NuGet package (version 3.3.3).
- Rebuild the solution:
Rebuild started...
1>------ Rebuild All started: Project: ConsoleApp1, Configuration: Debug Any CPU ------
1> -- Starting Brutal Developer .NET Assembly Strong-Name Signer Task --
1> Adding 'C:\Dev\ConsoleApp1\packages\OSVersionExt.2.0.0\lib\net462\OSVersionExt.dll' for processing.
1> 1. Loading assemblies...
1> 2. Checking assembly references...
1> Checking assembly references in 'C:\Dev\ConsoleApp1\packages\OSVersionExt.2.0.0\lib\net462\OSVersionExt.dll'.
1> 3. Strong-name unsigned assemblies...
1> Signing assembly 'C:\Dev\ConsoleApp1\packages\OSVersionExt.2.0.0\lib\net462\OSVersionExt.dll'.
1> 4. Fix InternalVisibleToAttribute references...
1> 5. Fix CustomAttributes with Type references...
1> 6. Fix BAML references...
1> 7. Save assembly changes...
1> Saving changes to assembly 'C:\Dev\ConsoleApp1\packages\OSVersionExt.2.0.0\lib\net462\OSVersionExt.dll'.
1> 8. Cleanup...
1> -- Finished Brutal Developer .NET Assembly Strong-Name Signer Task in 00:00:00.6701494 --
1>C:\Dev\ConsoleApp1\Program.cs(27,50,27,96): warning CS0618: 'MajorVersion10Properties.ReleaseId' is obsolete: 'Works until Windows 10 version 2009/20H2 (build 19042) only. Use DisplayVersion instead.'
1> ConsoleApp1 -> C:\Dev\ConsoleApp1\bin\Debug\ConsoleApp1.exe
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
========== Elapsed 00:01.548 ==========
- Run application to verify functionality and it works perfectly with no warnings.
Sample project to verify this yourself if you want: Issue94.zip
You need to post the output for the signer if there are any errors trying to sign your file.
from strongnamesigner.
Thanks for looking into this. It's still running into an error and I believe it's related to elevated permissions when running VS 2022 with Admin rights.
I tried running your attached solution and I got an error. (actually two, the first was that the AssemblyInfo.cs was missing which I took care of deleting the missing file from the solution), after compilation I got this:
System.IO.FileLoadException
HResult=0x80131044
Message=Could not load file or assembly 'OSVersionExt, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT: 0x80131044)
Source=<Cannot evaluate the exception source>
StackTrace:
<Cannot evaluate the exception stack trace>
The one point to note is that I'm starting VS 2022 with Admin rights (right click VS 2022 and Run as Administrator
).
Debug output:
'ConsoleApp1.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ConsoleApp1.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Users\xxx\OneDrive\Desktop\Issue94\bin\Debug\ConsoleApp1.exe'. Symbols loaded.
An unhandled exception of type 'System.IO.FileLoadException' occurred in Unknown Module.
Could not load file or assembly 'OSVersionExt, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT: 0x80131044)
The program '[2252] ConsoleApp1.exe' has exited with code 4294967295 (0xffffffff).
Build output
Build started...
------ Build started: Project: ConsoleApp1, Configuration: Debug Any CPU ------
-- Starting Brutal Developer .NET Assembly Strong-Name Signer Task --
Adding 'C:\Users\xxx\OneDrive\Desktop\Issue94\packages\OSVersionExt.2.0.0\lib\net462\OSVersionExt.dll' for processing.
1. Loading assemblies...
2. Checking assembly references...
Checking assembly references in 'C:\Users\xxx\OneDrive\Desktop\Issue94\packages\OSVersionExt.2.0.0\lib\net462\OSVersionExt.dll'.
3. Strong-name unsigned assemblies...
Signing assembly 'C:\Users\xxx\OneDrive\Desktop\Issue94\packages\OSVersionExt.2.0.0\lib\net462\OSVersionExt.dll'.
4. Fix InternalVisibleToAttribute references...
5. Fix CustomAttributes with Type references...
6. Fix BAML references...
7. Save assembly changes...
Saving changes to assembly 'C:\Users\xxx\OneDrive\Desktop\Issue94\packages\OSVersionExt.2.0.0\lib\net462\OSVersionExt.dll'.
Failed to save assembly 'C:\Users\xxx\OneDrive\Desktop\Issue94\packages\OSVersionExt.2.0.0\lib\net462\OSVersionExt.dll': Method not found: 'Void Mono.Cecil.WriterParameters.set_StrongNameKeyBlob(Byte[])'.
8. Cleanup...
-- Finished Brutal Developer .NET Assembly Strong-Name Signer Task in 00:00:00.0271211 --
C:\Users\xxx\OneDrive\Desktop\Issue94\Program.cs(27,50,27,96): warning CS0618: 'MajorVersion10Properties.ReleaseId' is obsolete: 'Works until Windows 10 version 2009/20H2 (build 19042) only. Use DisplayVersion instead.'
CSC : warning CS8002: Referenced assembly 'OSVersionExt, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' does not have a strong name.
ConsoleApp1 -> C:\Users\xxx\OneDrive\Desktop\Issue94\bin\Debug\ConsoleApp1.exe
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Elapsed 00:01.058 ==========
If I start VS without admin rights it seems to work fine, however I need Admin rights for my project to work/debug.
Oddly enough it works with VS 2017 started with Admin rights (targeting .NET 4.6.1)
from strongnamesigner.
Also when trying to replicate the issue in Admin mode, after having signed it in non admin mode, I would recommend deleting the nuget package and restoring it again and then trying to build it in admin mode.
from strongnamesigner.
@rboy1 Deleted bin/obj/packages and opened the sample solution with elevated VS 2022 and there are no errors so I'm not going to investigate this any further. If I was to guess, it's because you are building in your OneDrive directory and files are probably being synched incorrectly.
from strongnamesigner.
Actually, I managed to replicate the same error even in non Admin mode. I deleted and restore the nuget package and tried to rebuild it in non admin mode (see attached screenshot, the Admin symbol on the right corner is missing) and it gave me the error.
Can't explain it, the first time after an Admin mode build failure it built it in non Admin mode. The second time even with Non admin mode it failed.
Build started...
------ Build started: Project: ConsoleApp1, Configuration: Debug Any CPU ------
-- Starting Brutal Developer .NET Assembly Strong-Name Signer Task --
Adding 'C:\Users\xxx\OneDrive\Desktop\Issue94\bin\Debug\OSVersionExt.dll' for processing.
1. Loading assemblies...
2. Checking assembly references...
Checking assembly references in 'C:\Users\xxx\OneDrive\Desktop\Issue94\bin\Debug\OSVersionExt.dll'.
3. Strong-name unsigned assemblies...
Signing assembly 'C:\Users\xxx\OneDrive\Desktop\Issue94\bin\Debug\OSVersionExt.dll'.
4. Fix InternalVisibleToAttribute references...
5. Fix CustomAttributes with Type references...
6. Fix BAML references...
7. Save assembly changes...
Saving changes to assembly 'C:\Users\xxx\OneDrive\Desktop\Issue94\bin\Debug\OSVersionExt.dll'.
Failed to save assembly 'C:\Users\xxx\OneDrive\Desktop\Issue94\bin\Debug\OSVersionExt.dll': Method not found: 'Void Mono.Cecil.WriterParameters.set_StrongNameKeyBlob(Byte[])'.
8. Cleanup...
-- Finished Brutal Developer .NET Assembly Strong-Name Signer Task in 00:00:01.5656551 --
C:\Users\xxx\OneDrive\Desktop\Issue94\Program.cs(27,50,27,96): warning CS0618: 'MajorVersion10Properties.ReleaseId' is obsolete: 'Works until Windows 10 version 2009/20H2 (build 19042) only. Use DisplayVersion instead.'
CSC : warning CS8002: Referenced assembly 'OSVersionExt, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' does not have a strong name.
ConsoleApp1 -> C:\Users\xxx\OneDrive\Desktop\Issue94\bin\Debug\ConsoleApp1.exe
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Elapsed 00:03.129 ==========
from strongnamesigner.
@rboy1 Deleted bin/obj/packages and opened the sample solution with elevated VS 2022 and there are no errors so I'm not going to investigate this any further. If I was to guess, it's because you are building in your OneDrive directory and files are probably being synched incorrectly.
Not using OneDrive (it's disabled) but to test it out anyways I moved the solution to another folder and tried to rebuild it and it failed again with the same error. This isn't unique to me. I've seen this error reported by other users using a different package signer and it appears to be rooted in the Mono.Cecil error. Here's the reference
I'm able to replicate this issue easily here in Admin mode of VS 2022.
EDIT: Logs
Build started...
------ Build started: Project: ConsoleApp1, Configuration: Debug Any CPU ------
-- Starting Brutal Developer .NET Assembly Strong-Name Signer Task --
Adding 'C:\Users\xxx\source\repos\Issue94\bin\Debug\OSVersionExt.dll' for processing.
1. Loading assemblies...
2. Checking assembly references...
Checking assembly references in 'C:\Users\xxx\source\repos\Issue94\bin\Debug\OSVersionExt.dll'.
3. Strong-name unsigned assemblies...
Signing assembly 'C:\Users\xxx\source\repos\Issue94\bin\Debug\OSVersionExt.dll'.
4. Fix InternalVisibleToAttribute references...
5. Fix CustomAttributes with Type references...
6. Fix BAML references...
7. Save assembly changes...
Saving changes to assembly 'C:\Users\xxx\source\repos\Issue94\bin\Debug\OSVersionExt.dll'.
Failed to save assembly 'C:\Users\xxx\source\repos\Issue94\bin\Debug\OSVersionExt.dll': Method not found: 'Void Mono.Cecil.WriterParameters.set_StrongNameKeyBlob(Byte[])'.
8. Cleanup...
-- Finished Brutal Developer .NET Assembly Strong-Name Signer Task in 00:00:00.8026522 --
C:\Users\xxx\source\repos\Issue94\Program.cs(27,50,27,96): warning CS0618: 'MajorVersion10Properties.ReleaseId' is obsolete: 'Works until Windows 10 version 2009/20H2 (build 19042) only. Use DisplayVersion instead.'
CSC : warning CS8002: Referenced assembly 'OSVersionExt, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' does not have a strong name.
ConsoleApp1 -> C:\Users\xxx\source\repos\Issue94\bin\Debug\ConsoleApp1.exe
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Elapsed 00:02.442 ==========
from strongnamesigner.
For reference you will encounter this error on a fresh install of Windows 11 / VS 2022 with ONLY .net 4.8 installed. If you've installed .net 4.6.1 you won't encounter this error. It appears to have something related to MSBuildRuntimeType
defaulting to net461 if you're building with a target that's not 4.6.1
from strongnamesigner.
FYR: dsplaisted/strongnamer#47
I don't know if this is something that needs to detect at runtime by Stron-Name Signer to see which libraries are being loaded at runtime which may be causing the issue.
from strongnamesigner.
@brutaldev do you think it might be an issue with binding redirect? At runtime Strong-Name Signer isn't able to access the Mono-Cecil dll because it's being redirected to a different version of the assembly that doesn't exist. I'm asking because after updating to .NET 4.8 I'm seeing binding direct issues which never existed with .net 4.6.1
from strongnamesigner.
Related Issues (20)
- Writing mixed-mode assemblies is not supported HOT 3
- Transitive dependencies from PackageReferences are not investigated/signed HOT 3
- Use NuGet package, but no automatic signing of assemblies HOT 2
- Use NuGet package, but no automatic signing of assemblies HOT 2
- Virus Detected on Chrome when downloading StrongNameSigner_Setup.exe HOT 1
- SDK style probjects supported? HOT 4
- Failed to resolve assembly: 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' HOT 12
- Fixing unsigned references in signed assemblies when signing unsigned assemblies - unhandled case? HOT 5
- [Bug]: When the GUI comes across a "Unsupported PDB deleted bitset is not empty" it stops processing HOT 1
- [Feature Request]: convert the "Unsupported PDB deleted bitset is not empty" Error to a warning, so that the commandline app does not report errors HOT 2
- [Feature Request]: Can the Gui state what file has been used to sign a binary HOT 1
- [Bug]: If strongnamer is already processing a file, then do not throw an error when it tries to open it again due to parallel builds
- [Change Request]: Please change the column named `Signed` to be `StrongNamed` HOT 1
- [Feature Request]: Have a column called `DigCert` to show if this binary also has been digitally signed HOT 2
- [Bug]: Getting `Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'mscorlib, Version=4.0.0.0` for x86 project HOT 13
- Keyset does not exist error when using custom SNK generated from PFX file HOT 3
- Can not get it to work with .NET Standard 2.0 Project and Nuget Packages Scrypt.NET and CSVTextFieldParser HOT 2
- Fails to ignore package dlls if %NUGET_PACKAGES% is set to a different format of path. HOT 2
- Failed to resolve System.IO.FileAccess HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from strongnamesigner.