我我的Visual Studio 2010的更新版本10.0.30319.1 RTM版本,並開始在生成過程中收到以下異常:的NullReferenceException在Microsoft.Silverlight.Build.Tasks.CompileXaml.LoadAssemblies(ITaskItem [] ReferenceAssemblies)
System.NullReferenceException:未將對象引用設置爲對象的實例。 在Microsoft.Silverlight.Build.Tasks.CompileXaml.LoadAssemblies(ITaskItem [] ReferenceAssemblies) 在Microsoft.Silverlight.Build.Tasks.CompileXaml.get_GetXamlSchemaContext() 在Microsoft.Silverlight.Build.Tasks.CompileXaml.GenerateCode(ITaskItem項布爾isApplication) 在Microsoft.Silverlight.Build.Tasks.CompileXaml.Execute() 在Bohr.Silverlight.BuildTasks.BohrCompileXaml.Execute()
BohrCompileXaml.Execute的代碼如下:
public override bool Execute() {
List<TaskItem> pages = new List<TaskItem>();
foreach (ITaskItem item in SilverlightPages) {
string newFileName = getGeneratedName(item.ItemSpec);
String content = File.ReadAllText(item.ItemSpec);
String parentClassName = getParentClassName(content);
if (null != parentClassName) {
content = content.Replace("<UserControl", "<" + parentClassName);
content = content.Replace("</UserControl>", "</" + parentClassName + ">");
content = content.Replace("bohr:ParentClass=\"" + parentClassName + "\"", "");
}
File.WriteAllText(newFileName, content);
pages.Add(new TaskItem(newFileName));
}
if (null != SilverlightApplications) {
foreach (ITaskItem item in SilverlightApplications) {
Log.LogMessage(MessageImportance.High, "Application: " + item.ToString());
}
}
foreach (ITaskItem item in pages) {
Log.LogMessage(MessageImportance.High, "newPage: " + item.ToString());
}
CompileXaml xamlCompiler = new CompileXaml();
xamlCompiler.AssemblyName = AssemblyName;
xamlCompiler.Language = Language;
xamlCompiler.LanguageSourceExtension = LanguageSourceExtension;
xamlCompiler.OutputPath = OutputPath;
xamlCompiler.ProjectPath = ProjectPath;
xamlCompiler.RootNamespace = RootNamespace;
xamlCompiler.SilverlightApplications = SilverlightApplications;
xamlCompiler.SilverlightPages = pages.ToArray();
xamlCompiler.TargetFrameworkDirectory = TargetFrameworkDirectory;
xamlCompiler.TargetFrameworkSDKDirectory = TargetFrameworkSDKDirectory;
xamlCompiler.BuildEngine = BuildEngine;
bool result = xamlCompiler.Execute(); // HERE we got the error!
而且任務的定義:
<BohrCompileXaml
LanguageSourceExtension="$(DefaultLanguageSourceExtension)"
Language="$(Language)"
SilverlightPages="@(Page)"
SilverlightApplications="@(ApplicationDefinition)"
ProjectPath="$(MSBuildProjectFullPath)"
RootNamespace="$(RootNamespace)"
AssemblyName="$(AssemblyName)"
OutputPath="$(IntermediateOutputPath)"
TargetFrameworkDirectory="$(TargetFrameworkDirectory)"
TargetFrameworkSDKDirectory="$(TargetFrameworkSDKDirectory)"
>
<Output ItemName="Compile" TaskParameter="GeneratedCodeFiles" />
<!-- Add to the list list of files written. It is used in Microsoft.Common.Targets to clean up
for a next clean build
-->
<Output ItemName="FileWrites" TaskParameter="WrittenFiles" />
<Output ItemName="_GeneratedCodeFiles" TaskParameter="GeneratedCodeFiles" />
</BohrCompileXaml>
可能是什麼原因?我怎樣才能獲得更多信息CompileXaml類中發生了什麼?
對不起,我很新的這一切的東西,所以你可以請更清晰。我如何設置這些屬性? – 2010-05-12 13:11:47
已添加代碼。我不知道BohrCompileXaml是什麼,但你必須修改它。 – 2010-05-12 13:30:52
正如我所看到的CompileXaml沒有這樣的字段.. – 2010-05-12 13:45:49