By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,828 Members | 1,068 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,828 IT Pros & Developers. It's quick & easy.

Multiple Type Definition Causes Resource Failure

P: n/a
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.resou rces
{
}

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.frmCredentia ls.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.

Nov 21 '05 #1
Share this Question
Share on Google+
4 Replies

P: n/a
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

*** Sent via Developersdex http://www.developersdex.com ***
Nov 21 '05 #2

P: n/a
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

"Atara" <At***@DD.com> wrote in message
news:ev**************@tk2msftngp13.phx.gbl...
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

*** Sent via Developersdex http://www.developersdex.com ***

Nov 21 '05 #3

P: n/a

<url:http://groups-beta.google.com/group/...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."


*** Sent via Developersdex http://www.developersdex.com ***
Nov 21 '05 #4

P: n/a
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

"Atara" <At***@DD.com> wrote in message
news:eo**************@TK2MSFTNGP12.phx.gbl...

<url:http://groups-beta.google.com/group/...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."


*** Sent via Developersdex http://www.developersdex.com ***

Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.