Sunday, April 17, 2011

Form Designer Generated Code namespaces have to be corrected every form change

Hi,

I have several forms with this strange behaviour.

For instance I have this form generated code.

namespace Sogyo.InHolland.SeriousGameFactory.GameCreator
{
    partial class FormAvatarResourceSetEditor
{
this.bindingSourceAvatarResourceSets.DataSource = typeof(SeriousGameFactory.Framework.ImageResource);
}
}

In this case when i press build the compiler complains that it does not recognize "SeriousGameFactory.Framework.ImageResource". (Intellisense does not seem to be able to find the Framework namespace within the SeriousGameFactory Namespace)

I then change this manually to the following code

using SeriousGameFactory.Framework;
namespace Sogyo.InHolland.SeriousGameFactory.GameCreator
{
    partial class FormAvatarResourceSetEditor
{
this.bindingSourceAvatarResourceSets.DataSource = typeof(ImageResource);
}
}

Now the project builds. (strange !??) However when i open the form and work with it, visual studio autogenerates the following code.

using SeriousGameFactory.Framework;
namespace Sogyo.InHolland.SeriousGameFactory.GameCreator
{
    partial class FormAvatarResourceSetEditor
{
this.bindingSourceAvatarResourceSets.DataSource = typeof(SeriousGameFactory.Framework.ImageResource);
}
}

And again it does not compile. (Intellisense does not seem to be able to find the Framework namespace within the SeriousGameFactory Namespace)

Does anybody has any thoughts on what could cause this.

From stackoverflow
  • Have you got a conflicting type/property/method/control called SeriousGameFactory at some level? That would do it...

    Marc Gravell : That makes sense - it is finding the default namespace first. It sounds like you're going to have to rename one of the namespaces to get it to behave itself. You could use `extern alias`, but that is a royal pain to do...
    Marc Gravell : Ah - we were typing at the same time ;-p Glad it is sorted.

0 comments:

Post a Comment