wpf CS0426 - 类型名称 { } 不存在于类型 { }
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/40632034/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
CS0426 - The type name { } does not exist in the type { }
提问by Roman Doskoch
Today I worked at my project and suddenly the following error ris:
今天我在我的项目中工作,突然出现以下错误:
CS0426 The type name 'CustomerView' does not exist in the type 'PetrolStation'
CS0426 类型名称“ CustomerView”在类型“ PetrolStation”中不存在
I have no clue what is going on here:
我不知道这里发生了什么:
I think that image shown above is pretty self explaining. You may notice that the same error happens also a code-block further down with the error:
我认为上面显示的图像很自我解释。您可能会注意到,同样的错误也会发生在错误的代码块下方:
CS0426 The type name 'Views' does not exist in the type 'PetrolStation'
CS0426 类型名称“视图”在类型“ PetrolStation” 中不存在
And the same error here again:
再次出现同样的错误:
Which raises the following error:
这引发了以下错误:
CS0426 The type name 'App' does not exist in the type 'PetrolStation'
CS0426 类型名称“ App”在类型“ PetrolStation” 中不存在
Does anyone know what is going on here?
有谁知道这里发生了什么?
Thanks
谢谢
回答by Roman Doskoch
If your class is defined in PetrolStationnamespace you shouldn't specify this namespace if you try to access to this class. Delete PetrolStationnamespaces before class names:
如果您的类是在PetrolStation命名空间中定义的,那么如果您尝试访问此类,则不应指定此命名空间。删除PetrolStation类名之前的命名空间:
App app = new App(); //and in other places without PetrolStation
OR
或者
If you've created class with the same name as namespace you should specify full name:
如果您创建了与命名空间同名的类,则应指定全名:
PetrolStation.PetrolStation.App app = new PetrolStation.PetrolStation.App(); //and in other places with one more PetrolStation
It seems to be the first case in your code.
这似乎是您代码中的第一种情况。


