I ran into this same problem with many of my controls. What it boils
down to is that enums declared inside a class are very problematic
when serializing through the designer. Move your enums outside the
class into the namespace instead. This fixed it for me and I was
having exactly the same problem you are having.
-Allen
http://www.glacialcomponents.com http://allenanderson.blogspot.com [quoted text, click to view] On 22 Aug 2005 11:31:14 -0700, gwatts@phys.washington.edu wrote:
>Hi,
> I've been getting the " The variable 'MSDataType' is either
>undeclared or was never assigned." error. Searching usnet it seems I'm
>not the only one. The only difficulty is that no one ever replies. ;-)
>
> A bit of background.
>
>1) My solution has three projects in it. One contains user controls.
>One of the user controls contains a public, designer, property that is
>an enum type. That enum is also declared as a public property.
>
>2) I've placed that control from project #1 on a form in project #2. I
>then set and configure it in the designer. Including setting the enum
>variable. It works just as you would expect.
>
>2) The project builds just fine. And once built, runs just fine. In
>short, I don't think I've forgotten to include references or not
>labeled some enum as public.
>
>3) Sometimes, after a rebuild, I'll get the above error. The
>"MSDataType" is the enum type. The build environment then resets the
>variable to the enum value that is represented by 0 (i.e. resets it to
>the default).
>
>4) Usually only the enum looses its configuration. But sometimes, if I
>have a bad build error and the control library fails to build, and the
>windows form is still open then I will looose all the settings (I have
>about 30 components and controls on this form).
>
>As you might imagine, this is a huge pain in the but -- the user
>control is constantly loosing its configuration.
>
>I am doing my best to determine a short sequence of actions that causes
>this to happen, but haven't been able to come up with it. It always
>takes me be (nasty) surprise.
>
>Any help apprecitaed, and I can post the project as well (right now I
>have to recover the 100+settings I lost when I was trying to reproduce
>the error and accidentally erased everything -- even the positions of
>my controls were lost!).
>
>Cheers,
> Gordon.
>
>P.S. If you search for this error on msdn you'll end up with two KB
>articles. Neither seems to apply to me. I've never built in release
>mode and I've also don't have my app data directory redirected to
>another zone.