Compiler won't include resources for all forms

L

Lucvdv

In an app that was working, all I did was specify an icon for the main
form (through the form designer) and recompile it.

Result: MissingManifestResourceException

After digging around, I found that the compiler generates .resource
files in the debug build of the application, for all forms except the
main one (form1).

The .resx file (with the icon in it) exists in the source directory,
and in the project file it's specified as for "embedded resource" type
compilation, but the compiler still seems to ignore it.

Does anyone have an idea what might cause this?


Cut & paste from the .vbproj file:

<File
RelPath = "Form1.vb"
SubType = "Form"
BuildAction = "Compile"
/>
<File
RelPath = "Form1.resx"
DependentUpon = "Form1.vb"
BuildAction = "EmbeddedResource"
/>

There's no difference between this and similar sections for other
three forms.

Files in the ./obj/debug directory after a full recompile:

App.exe
App.Form2.resources
App.Form3.resources
App.Form4.resources
App.pdb
<DIR> temp
<DIR> TempPE


In the InitializeComponent function, this line fails (single line in
the source):

Me.Icon = CType(resources.GetObject("$this.Icon"),
System.Drawing.Icon)

Resources are opened at the start of that function as (single line):

Dim resources As System.Resources.ResourceManager
= New System.Resources.ResourceManager(GetType(Form1))

The icon is present in form1.resx, named $this.Icon and culture
neutral.
 
L

Lucvdv

In an app that was working, all I did was specify an icon for the main
form (through the form designer) and recompile it.

Result: MissingManifestResourceException

Sorry, for asking, and here's the solution (I found previous questions
about the same problem, so maybe I'm helping someone):

I had included a small auxiliary class by just inserting the 7 (seven)
lines that define it at the start of Form1.vb.

That was it: all I had to do was move it to a separate source file.
Now Form1.resources is created at compile time, and the application no
longer crashes at startup.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top