Multiple Type Definition Causes Resource Failure

F

Floppy Jellopy

Hello,

I was recently asked to look at someones code to see if i could determine
why a particular form was failing to load and instead generating an error
about a lack of available resources for that locale. The form inherited from
a base form and was defined with an inline namespace rather than defaulting
to the project option dialog namespace. Prior to the class/form definition,
an enum was defined within the namespace scope as below ( i haven't included
the actual definitions)

Namespace Company.Solutions.ProductName.UI.WinForms

Public Enum MyEnum
.......
End Enum

Public Class frmCredentials
Inherits ApplicationBaseForm
....
End Class

End Namespace

So i fired up Ildasm and had a look at the manifest and found that this
particular class had a resource entry like

..mresource public frmCredentials.resources
{
}

whereas all other classes/forms had a full namespace definitions as in

..mresource public Company.Solutions.Product.UI.WinForms.frmXYZ.resources
{
}

So i tried taking out the Enum definition and placing it in a separate .vb
file. This worked. The manifest now had a full namespace entry for the
resources file as below :

..mresource public
Company.Solutions.Product.UI.WinForms.frmCredentials.resources
{
}

And the form now loads and runs without error.

My question is what difference does this make? Why did this work? Whilst it
is not my preference to include multiple type defintions in the same file, I
wasn't aware that this would cause any problems with respect to compilation
and execution? Although the issue has been resolved, I dont know why what i
did worked?

Does anyone have any ideas? Note if i put the Enum back into the file. It
fails as above.


Thanks
Floppy J.
 
A

Atara

I read somewhere that you must always declare the form class before any
other non-designable declerations. otherwise the Designer does not read
the form properly.

This might relate to your case also:
Try to declare the enum after the form decleration, and see what happens
to the namespace entry.

Atara
 
F

Floppy Jellopy

Yes this works. There was no problem in the designer however. The problem
was/is in the assembly manifest. So its more of a compilier issue. I dont
suppose you have the link to the info you were talking about? Ive tried
Googling the problem but given the keywords im using i get nothing but
noise.

FJ
 
A

Atara

<url:http://groups-beta.google.com/group/microsoft.public.dotnet.framewo
rk.windowsforms/browse_thread/thread/97b90bda835ce6a9/d97ceb96927bfcd0?l
nk=st&q=dotnet+designer+%22two+forms%22&rnum=1&hl=en#d97ceb96927bfcd0>

"...The final thing that I know of that could cause this is that the
designer
will not open if the first class is not the designable class. So, if you
put
an enum or other class at the top of the file, the designer will try to
parse that class instead of the form, and it will fail."
 
F

Floppy Jellopy

O.k thanks Atara,

Ive had a look at that link but it is for a different problem. My question
is about a problem that doesn;t affect the designer but the manifest.
Mine is about a compliation/runtime issue not a designer issue. Thanks
anyway.

fj
 

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