2014-07-12 77 views
2

我在我的應用程序中使用AvalonDock,並且注意到當我定位到x64時,它在加載佈局時似乎執行得慢很多。當我瞄準x86時,佈局立即加載,然而在64位中它會在看到結果之前凍結大約一秒左右。AvalonDock在64位中較慢

這個問題似乎與XmlSerializer在64位運行時表現更差有關,並且搜索時,人們建議在編譯時使用sgen.exe生成* .XmlSerializers.dll。但不幸的是,這似乎並沒有爲運行SGEN後建事件的工作:

「$(SDK40ToolsPath)\x64\sgen.exe」 /a:"$(TargetPath)" /force /r "Xceed.Wpf.AvalonDock.dll" 

產生以下錯誤:

1>EXEC : error : Cannot deserialize type 'Microsoft.Windows.Shell.SystemParameters2' because it contains property 'IsGlassEnabled' which has no public setter. 

我真的不希望有使用/ t命令來定位每個類型。

有沒有其他人遇到過這個問題並有解決方案?

回答

0

我遇到了這個問題,我發現的唯一解決方案是單獨指定類型。我找到this article by Mikhail Shilkov,它顯示了一個簡潔的方式來爲.csproj文件中的後期構建任務指定多種類型。我只指定在new XmlSerializer()構造函數調用中引用的類型:

<Target Name="AfterBuild" DependsOnTargets="AssignTargetPaths;Compile;ResolveKeySource" Inputs="$(MSBuildAllProjects);@(IntermediateAssembly)" Outputs="$(OutputPath)$(_SGenDllName)"> 
    <!-- This contents of this list was determined by looking at the new XmlSerializer() calls in the code. --> 
    <ItemGroup> 
    <SgenTypes Include="Xceed.Wpf.AvalonDock.Layout.LayoutRoot" /> 
    <SgenTypes Include="Xceed.Wpf.AvalonDock.Layout.LayoutAnchorablePaneGroup" /> 
    <SgenTypes Include="Xceed.Wpf.AvalonDock.Layout.LayoutAnchorablePane" /> 
    <SgenTypes Include="Xceed.Wpf.AvalonDock.Layout.LayoutAnchorable" /> 
    <SgenTypes Include="Xceed.Wpf.AvalonDock.Layout.LayoutDocumentPaneGroup" /> 
    <SgenTypes Include="Xceed.Wpf.AvalonDock.Layout.LayoutDocumentPane" /> 
    <SgenTypes Include="Xceed.Wpf.AvalonDock.Layout.LayoutDocument" /> 
    <SgenTypes Include="Xceed.Wpf.AvalonDock.Layout.LayoutAnchorGroup" /> 
    <SgenTypes Include="Xceed.Wpf.AvalonDock.Layout.LayoutPanel" /> 
    </ItemGroup> 
    <Delete Files="$(TargetDir)$(TargetName).XmlSerializers.dll" ContinueOnError="true" /> 
    <SGen BuildAssemblyName="$(TargetFileName)" BuildAssemblyPath="$(OutputPath)" References="@(ReferencePath)" ShouldGenerateSerializer="true" UseProxyTypes="false" KeyContainer="$(KeyContainerName)" KeyFile="$(KeyOriginatorFile)" DelaySign="$(DelaySign)" ToolPath="$(SGenToolPath)" Types="@(SgenTypes)"> 
    <Output TaskParameter="SerializationAssembly" ItemName="SerializationAssembly" /> 
    </SGen> 
</Target> 

做了這些改變之後,我遇到了另一個錯誤:

Generated serialization assembly is not signed

這是通過除去從集信息以下行禁用簽名解決。 CS:

#pragma warning disable 1699 
[assembly: AssemblyDelaySign(false)] 
[assembly: AssemblyKeyFile(@"..\..\sn.snk")] 
[assembly: AssemblyKeyName("")] 
#pragma warning restore 1699 

另一種辦法是使在Project Properties > Signing簽約,但我沒有試過。