views:

11

answers:

1

I have a very simple XAML form, that has one namespace definition. For some reason, when Visual Studio processes that XAML file in to it's component .g.cs, it's sticking a bunch of namespace definitions at the top that I have not asked for in the XAML, or the code behind, and they are namespaces that no longer exist in my project. Thus the project is failing to compile.

Why is Visual Studio sticking arbitrary namespace 'using' statements in my generated XAML .g.cs files? It's caused my entire project to break. Not one time did this .xaml file ever reference the namespaces in question, so it's doubly annoying.

+1  A: 

I had this happen to me before. A few times, actually.

What I kept forgetting was that, buried deep down within my project, I had a little file called XmlnsDefs.cs.

Inside that file I had all these nice neat xmlns definitions:

[assembly: XmlnsDefinition("http://www.HurrDurr.com/2010/Foo", "Foo.Bar")]
[assembly: XmlnsDefinition("http://www.HurrDurr.com/2010/Foo", "Foo.Bar.Baz")]

And each one ended up as a using within the .g.cs files of my xaml forms. This worked great, except that I had refactored some of those namespaces away. And it broke the fudge out of my skeet. But, once I fixed my defs to match my current namespaces, all was well. All was well.

Will