-
Notifications
You must be signed in to change notification settings - Fork 389
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
Retrieving file from new resource file format throws System.MissingMethodException: 'Constructor on type 'System.Byte[]' not found.' #9526
Comments
Tagging subscribers to this area: @dotnet/area-system-resources |
Callstack:
So it's being treated as a Activator type resource. Here's the relevant code in MSBuild: MSbuild is registering as activator resource: That's wrong, it should be treating as byte[], but MSBuild is only treating this as a byte array if it has both Here's what I see in the latest resx: <data name="ProgramSource" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Program.cs;System.Byte[]</value>
</data> Repro: conRes.zip So I can workaround this by adding <data name="ProgramSource" type="System.Resources.ResXFileRef, System.Windows.Forms">
- <value>Program.cs;System.Byte[]</value>
+ <value>Program.cs;System.Byte[],mscorlib</value>
</data> Maybe MSBuild could broaden that check to consider this specific case of no core assembly name. @rainersigwald Did the designer change here? @drewnoakes |
Hi, thank you for using the new Resource Explorer and for reporting this issue. The problem is related to creating a resource of type File, where the assembly information isn't being saved in the resource file. The good news is that the latest Visual Studio version includes a fix for this issue! You can download it from https://visualstudio.microsoft.com/vs/preview/. Let us know if you encounter other issues or have feedback on the new experience. |
When can we expect this fix to be in a release? |
Would like to know this as well. Having the same issue. |
@cmierowsky, @maot01, the fix is available in Visual Studio 17.11.1. |
Im still getting : Constructor on type 'System.Byte[]' not found. when trying to access a File saved in Resource Like such : var test = Resource.MyFile; |
Thanks for the clarification, @maot01. I can see the error now; I'll investigate this further and keep this thread updated. |
A fix for this issue has been internally implemented and is being prepared for release, where we treat text files as |
Has the fix to this issue been released yet? Now it seems with the current version of VS community (17.11.5) I cannot even attach .exe files in the new resource manager. Funny thing, it works perfectly to import them using the legacy solution (and then I can actually read the file). This seems a bit embarrassing at this point... 😅 |
I also have the same problem with adding fonts. Will we soon have a new version of visual studio (17.11.6) with the essential fixes of the resource explorer? |
Still having this problem in 17.12.1 with adding image files to a new resx file. Adding ,mscorlib fixes this as @ericstj suggested |
Description
When adding a resource file after upgrading Visual Studio to 17.11.0 and adding a file resource, the new Resource Explorer is used.
Then when trying to retrieve the resource using the ResourceFileName.ObjectName syntax, a
MissingMethodException
is thrownConstructor on type 'System.Byte[]' not found.
Reproduction Steps
MSB3822 Non-string resources require the System.Resources.Extensions assembly at runtime, but it was not found in this project's references.
Add the NuGet package "System.Resources.Extensions" Version="8.0.0" to resolve the error.var fileBytes = ResourceFileName.ObjectName
System.MissingMethodException: 'Constructor on type 'System.Byte[]' not found.'
Expected behavior
When accessing the resource file it should be returned as a byte[].
Actual behavior
An exception is thrown:
System.MissingMethodException: 'Constructor on type 'System.Byte[]' not found.'
Regression?
This worked before the latest resource file / explorer changes
Known Workarounds
No response
Configuration
No response
Other information
No response
The text was updated successfully, but these errors were encountered: