【发布时间】:2011-07-24 13:23:55
【问题描述】:
在我当前的personal project 中,我有一个Core 项目、一个DependencyResolution 项目和一个UI 项目(WPF 应用程序)。在 UI 项目中,我尝试在 MainWindow.xaml.cs 和 App.xaml.cs 中调用 DependencyResolution 中的 DependencyRegistrar 类。引用 DependencyResolution 项目的 UI 项目似乎存在问题,因为总是出现此编译器错误:
The type or namespace name 'DependencyResolution' does not exist in the namespace
'DMTools.InitiativeTracker' (are you missing an assembly reference?)
D:\Dev\InitiativeTracker\src\UI\App.xaml.cs 2 33 UI
在 UI 中的任何位置都包含 using 语句会产生该错误。
using System.Windows;
using DMTools.InitiativeTracker.DependencyResolution;
namespace DMTools.InitiativeTracker.UI
{
public partial class App : Application
{ }
}
我可以引用 Core 项目 (using DMTools.InitiativeTracker.Core) 并且一切都可以编译。此外,我可以在IntegrationTests 项目(另一个类库)中引用DependencyRegistrar,它可以编译。
您可以找到完整的源代码here。如果您需要更多信息,请随时请求特定的 sn-ps。
编辑: 我已经通过 ReSharper 和典型的 Visual Studio 方式添加了对 DependencyRegistrar 的程序集引用。两种情况都没有解决问题。另一条评论:当我添加对核心静态类 (IoC) 的引用时,XAML 保持不变,但可以正常编译。
【问题讨论】:
-
您是否将程序集添加为对项目的引用?
-
检查冲突的两个项目的 .NET 版本...
标签: c# wpf .net-4.0 compiler-errors