Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Old namespace still in .g.cs file when changing namespace of a referenced class

Tags:

wpf

I have renamed the namespace of a referenced class and WPF compiler doesn't want to take it into account: it keeps prefixing MyOldNameSpace in .g.cs file:

[System.CodeDom.Compiler.GeneratedCodeAttribute
     ("PresentationBuildTasks", "4.0.0.0")]
public partial class MyClass: 
    MyOldNameSpace.MyReferencedClass, 
    System.Windows.Markup.IComponentConnector {

Why ? How to fix this ? What's this obscure .g.cs file ?

like image 374
user310291 Avatar asked Jan 26 '11 11:01

user310291


3 Answers

Looks like you didn't change your MyClass.xaml file. There should be something like this on top of it

<MyClass x:Class="MyOldNameSpace.MyReferencedClass"

but should be "MyNewNameSpace.MyReferencedClass"

like image 78
alpha-mouse Avatar answered Sep 20 '22 09:09

alpha-mouse


Close the .g.cs file. You can even delete it.

The g stands for generated, VS generates the wireing up between the code and the Xaml in this partial class.

Clean the solution and rebuild. That should fix it.

like image 7
Emond Avatar answered Sep 19 '22 09:09

Emond


Don't forget to change your Generic.xaml file too,

<ResourceDictionary 
                   xmlns:local="clr-namespace:MyOldNameSpace">
</ResourceDictionary>
like image 2
Guillermo Hernandez Avatar answered Sep 20 '22 09:09

Guillermo Hernandez