项目中所有系统名称空间均未定义 [英] All System namespaces are undefined in project

查看:95
本文介绍了项目中所有系统名称空间均未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题是应用程序引用了名称空间中带有'System'的解决方案项目.命名空间类似于'SolutionNamespace.WhatItIs.System'.因此,当我构建WPF应用程序时,其MainWindow.g.vb和Application.g.vb会产生如下错误:

The problem is the application refrences a solution project whose namespace has a 'System' in it. The namespace goes something like 'SolutionNamespace.WhatItIs.System'. So when I build the WPF application, its MainWindow.g.vb and Application.g.vb would give off errors like the following:

  • 类型'System.Windows.Window未定义.
  • 键入"System.Windows.Markup.IComponentConnector

我知道'* .g.vb'源代码是自动生成的.但是,是否有一种方法可以配置生成器,以便可以为每个'System'名称空间添加'Global'?还是有办法解决这个问题?我不能真正更改WPF应用程序引用的其他库的名称空间,因为我不拥有它.任何帮助将不胜感激.

I understand that '*.g.vb' source codes are auto-generated. But is there a way to configure the generator so it could add a 'Global' to every 'System' namespaces? Or is there a way to resolve this problem? I can't really change the namespace of the other library the WPF application references since I don't own it. Any help would be appreciated.

我尝试将SolutionNamespace.WhatItIs.System更改为SolutionNamespace.WhatItIs.Systems来查看我的假设是否正确……我错了. System命名空间仍未定义,仍然要求我将其更改为Global.System.

I tried changing the SolutionNamespace.WhatItIs.System to SolutionNamespace.WhatItIs.Systems to see whether my assumptions are correct... I was wrong. System namespaces are still undefined and still asking me to change them into Global.System.

编辑II: 看来我的假设毕竟是正确的.第一次尝试将SolutionNamespace.WhatItIs.System更改为SolutionNamespace.WhatItIs.Systems时,我没有修改其程序集名称和根名称属性.当我更改它们并重建时,错误消失了.现在的问题是SolutionNamespace.WhatItIs.System的所有者是否允许我更改命名空间,因为其他项目正在使用它.

Edit II: It appears that my assumptions were correct after all. The first time I tried changing SolutionNamespace.WhatItIs.System to SolutionNamespace.WhatItIs.Systems, I did not modify its Assembly name and Root name properties. When I changed them and rebuilt, the errors were gone. Problem now is if the owner of SolutionNamespace.WhatItIs.System would allow me to change the namespace since other projects use it.

推荐答案

添加using声明时,您可以尝试使用别名:

You could either try to use an alias when you add your using declarations:

using CustomSystem = SolutionNamespace.WhatItIs.System;

然后像这样指代那些成员:

And then refer to those members like this:

CustomSystem.SomeClass = new CustomSystem.SomeClass();

或者只是不将其添加到using声明中并完全限定每次使用:

Or just not add it to the using declarations and fully qualify each use:

SolutionNamespace.WhatItIs.System.SomeClass = 
    new SolutionNamespace.WhatItIs.System.SomeClass();


更新>>>


UPDATE >>>

如果这没有帮助,您可以看看名称空间冲突C#命名空间别名限定符(::)与Dereferencing Operator(.)此处发布在StackOverflow上,它有很好的答案.我认为@Zache在提及您可能需要使用全局命名空间别名.

If that doesn't help, you could take a look at the Namespace collisions and C# Namespace Alias qualifier (::) vs Dereferencing Operator (.) posts here on StackOverflow, which have good answers. I think that @Zache could be correct in mentioning that you might need to use the Global Namespace Alias.

这篇关于项目中所有系统名称空间均未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆