我在从继承自UserControl的ViewBase类继承的项目中拥有所有视图。在我的XAML中,我这样引用它:
<f:ViewBase x:Class="Forte.UI.Modules.Configure.Views.AddNewEmployeeView"
xmlns:f="clr-namespace:Forte.UI.Modules.Configure.Views"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
工作正常。
现在我已经将ViewBase移动到另一个项目(所以我可以从多个项目中引用它)所以我引用它如:
<f:ViewBase x:Class="Forte.UI.Modules.Configure.Views.AddNewEmployeeView"
xmlns:f="clr-namespace:Forte.UI.Modules.Common.Views;assembly=Forte.UI.Modules.Common"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
当我从IDE运行时,这工作正常,但是当我从MSBuild运行相同的sln时,它会发出警告:
“H:\ dev \ ExternalCopy \ Code \ UI \ Modules \ Configure \ Forte.UI.Modules.Configure.csproj”(默认目标) (10:12) - &gt; (ValidateXaml target) - &gt; H:\ dev \ ExternalCopy \ Code \ UI \ Modules \ Configure \ Views \ AddNewEmployee \ AddNewEmployeeView.xaml(1,2,1,2):warning:XML命名空间'clr-namespace中不存在标签'ViewBase': Forte.UI.Modules.Common.Views;装配= Forte.UI.Modules.Common”
。
然后失败了:
“H:\ dev \ ExternalCopy \ Code \ UI \ Modules \ Configure \ Forte.UI.Modules.Configure.csproj”(默认目标) (10:12) - &gt; (ValidateXaml target) - &gt; C:\ Program Files \ MSBuild \ Microsoft \ Silverlight \ v3.0 \ Microsoft.Silverlight.Common.targets(210,9): 错误MSB4018:“ValidateXaml”任务意外失败。\ r C:\ Program Files \ MSBuild \ Microsoft \ Silverlight \ v3.0 \ Microsoft.Silverlight.Common.targets(210,9):er ror MSB4018:System.NullReferenceException:未将对象引用设置为对象的实例。\ r C:\ Program Files \ MSBuild \ Microsoft \ Silverlight \ v3.0 \ Microsoft.Silverlight.Common.targets(210,9):er ror MSB4018:在MS.MarkupCompiler.ValidationPass.ValidateXaml(String fileName,Assembly [] assemb lie,Assembly callingAssembly,TaskLoggingHelper log,Boolean shouldThrow)\ r C:\ Program Files \ MSBuild \ Microsoft \ Silverlight \ v3.0 \ Microsoft.Silverlight.Common.targets(210,9):er ror MSB4018:在Microsoft.Silverlight.Build.Tasks.ValidateXaml.XamlValidator.Execute()\ r \ n C:\ Program Files \ MSBuild \ Microsoft \ Silverlight \ v3.0 \ Microsoft.Silverlight.Common.targets(210,9):er ror MSB4018:在Microsoft.Silverlight.Build.Tasks.ValidateXaml.XamlValidator.Execute()\ r \ n C:\ Program Files \ MSBuild \ Microsoft \ Silverlight \ v3.0 \ Microsoft.Silverlight.Common.targets(210,9):er ror MSB4018:在Microsoft.Silverlight.Build.Tasks.ValidateXaml.Execute()\ r \ n C:\ Program Files \ MSBuild \ Microsoft \ Silverlight \ v3.0 \ Microsoft.Silverlight.Common.targets(210,9):er ror MSB4018:在Microsoft.Build.BuildEngine.TaskEngine.ExecuteInstantiatedTask(EngineProxy engin) eProxy,ItemBucket bucket,TaskExecutionMode howToExecuteTask,ITask task,Boolean&amp; taskResult)
可能导致此行为的任何想法?
使用Silverlight 3
这是MSBuild文件的简化版本,无法构建在IDE中构建良好的sln(抱歉无法在此处进行格式化):
&lt;?xml version =“1.0”encoding =“utf-8”?&gt; &lt; Project xmlns =“http://schemas.microsoft.com/developer/msbuild/2003”DefaultTargets =“Compile”&gt; &LT;&的ItemGroup GT; &lt; ProjectToBuild Include =“.. \ UI \ Forte.UI.sln”&gt; &LT;性状&gt;配置=调试和LT; /性状&gt; &LT; / ProjectToBuild&GT; &LT; /&的ItemGroup GT; &lt; Target Name =“Compile”&gt; &lt; MSBuild Projects =“@(ProjectToBuild)”&gt;&lt; / MSBuild&gt; &LT; /目标&GT; &LT; /项目&GT;
感谢您的帮助!
答案 0 :(得分:0)
到目前为止,唯一的办法是,我找到了解决这个问题的方法是参考实际的装配而不是项目。这有点儿,有人有更好的主意吗?