System.Resources.MissingManifestResourceException when DependentUpon not specified and .resx path not match with Control/Form namespace
See original GitHub issueVisual Studio Version: 16.3.0
Summary: .Net Core 3.0 Microsoft.NET.Sdk.WindowsDesktop UseWindowsForms = true System.Resources.MissingManifestResourceException when DependentUpon not specified and .resx path not match with Control/Form namespace.
Steps to Reproduce:
- Create new WindowsForms project (sdk style, net472).
- Add local resource to Form1 (e.g. BackgroundImage).
- Change Form1 namespace or move it to another folder in project.
- Build and run application.
Expected Behavior: Application starts and Form1 shown with set background image.
Actual Behavior:
System.Resources.MissingManifestResourceException
thrown when this.BackgroundImage = (System.Drawing.Image)resources.GetObject("$this.BackgroundImage")))
called.
Content of csproj file:
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net472</TargetFramework>
<UseWindowsForms>True</UseWindowsForms>
</PropertyGroup>
</Project>
Workaround: Add next item in csproj file:
<ItemGroup>
<!-- "NewFolder" is project subfolder where form has been moved. -->
<EmbeddedResource Update="NewFolder/Form1.resx" DependentUpon="Form1.cs" />
</ItemGroup>
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
What does MissingManifestResourceException mean and ...
All I needed to do to fix this problem was to right-click the Resources.resx file in the Solution Explorer and click Run Custom...
Read more >MissingManifestResourceExcepti...
The exception that is thrown if the main assembly does not contain the resources for the neutral culture, and an appropriate satellite assembly...
Read more >How I can fix this error in windows form
This problem occurs when the default name space of your project mismatch with your Resources.Designer.cs namespace. In order to resolve this ...
Read more >The "System.Resources.MissingManifestResourceException
MissingManifestResourceException : Could not find any resources appropriate for the specified culture or the neutral culture." error occurs under ...
Read more >Problems with localization in c# using satellite Dll's, it ...
Find answers to Problems with localization in c# using satellite Dll's, it keeps giving me Err: System.Resources.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’ve been researching this too, lately. Try adding this property to your CSProj.
Which I found via: /dotnet/sdk/pull/3533
Remove your workaround
<EmbeddedResource Update="..."
after adding the above property and you should be good to go.Note that this flag is set to true for .Net Core 3.0+ and .Net Standard 2.1+, but needs to be opted in like this for other TFMs. This flag has worked for me on my projects using
Sdk="Microsoft.NET.Sdk.WindowsDesktop"
WinForms projects targetingnet48
where the namespace of the form did not match the folder it was in.Yes, it works now. Thanks.