[英]VS2010 C# WPF App: New WPF Project Cannot Call Static Class Method from Another 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
,並且可以編譯。
您可以在此處找到完整的源代碼。 如果您需要更多信息,請隨時請求特定的摘要。
編輯:我已經通過ReSharper和典型的Visual Studio方式向DependencyRegistrar添加了程序集引用。 兩種情況都不能解決問題。 換句話來說:當我添加對Core靜態類(IoC)的引用時,XAML保持不變,但可以正常編譯。
提格倫的評論弄清楚了這個謎。 在UI項目中,我將Target framework
從“ .NET Framework 4客戶端配置文件”更改為“ .NET Framework 4”,並且它們都可以正常工作。
我唯一想到的是為什么這是DependencyResolution而不是Core的問題,原因是前者引用了與Client Profile有關的第三方實用程序(即Ninject),但我只是在這里猜測。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.