"致命错误N1002。Out of Memory" : 在成功生成mdilexe后,构建UWP版本失败。

问题描述 投票:1回答:1

1. 小结 我有一个跨平台Xamarin(用Microsoft Visual Studio Enterprise 2019 Version 16.6.0)解决方案的UWP项目,库使用.Net Standard 2.0,UWP使用最新的Windows 10版本1903(build 18362),调试时可以成功运行(Android项目也可以在真实手机中调试成功)。但当我改成发布和创建应用包时,却以 "内存不足 "失败。 构建过程近15分钟,系统内存(12G)终于用完,直至失败。 编译器成功生成了mdilexe,但突然失败了。这可能是一个新的错误,我找不到类似的情况。

2.错误信息 ilclog.csv的摘要

 Message    Normal  Transform summary   
Message Normal      ms | heap delta | name  
Message Normal  265805 |       1300 | Analysis  
Message Normal   52943 |      -1221 | Reducer   
Message Normal   44998 |        245 | CreateMetadata    
Message Normal   33212 |        313 | Mcg   
Message Normal   32044 |          4 | GenerateCodeAndCompile    
Message Normal   28039 |       -108 | WriteAssemblies   
Message Normal   15547 |       -127 | ReducedCopyComplete   
Message Normal   11605 |         44 | ReducedCopyInitialize 
Message Normal    5616 |         28 | McgTypeOf 
Message Normal    4547 |         66 | LazyGenerics  
Message Normal    3722 |        202 | ReducedCopyMethodBodies   
Message Normal    2571 |         45 | McgRedirect   
Message Normal    2143 |        114 | ReducedCopyPopulateTypes  
Message Normal    1963 |         18 | StaticInitData    
Message Normal    1844 |        178 | ReducedCopyLateMetadata   
Message Normal     723 |          5 | ReflectionMappingInfoEmit 
Message Normal     650 |          3 | McgRedirect   
Message Normal     509 |         18 | TypeofTypeHandle  
Message Normal     461 |         -9 | DumpNativeResources   
Message Normal     433 |          1 | ResourceExtractor 
Message Normal     333 |         12 | EventSource   
Message Normal     205 |          5 | Delegate  
Message Normal     178 |          4 | GetType   
Message Normal     172 |         32 | ReflectionInvoke  
Message Normal     162 |          4 | SaveRVAStatics    
Message Normal     158 |        -13 | ReducedCopyPassResourcesToMutableAssembly 
Message Normal     142 |          7 | McgAccessor   
Message Normal     128 |         30 | ReducedCopyEmptyTypes 
Message Normal     103 |          2 | DispatchProxyIntrinsics   
Message Normal      80 |          0 | ValueType 
Message Normal      76 |         15 | DebuggerGuidedStepThroughJmc  
Message Normal      76 |          0 | ScrubOpenCalls    
Message Normal      67 |          2 | ReflectionIntrinsics  
Message Normal      52 |          0 | StartupCodeInjector   
Message Normal      41 |          3 | McgFixups 
Message Normal      30 |          1 | ConvertCatchIntoFilter    
Message Normal      25 |          0 | DisableOptimization   
Message Normal      19 |          0 | ReducedCopyCleanup    
Message Normal      16 |          2 | Attribute 
Message Normal      12 |          1 | AddReflectionBlockedAttributes    
Message Normal       2 |          0 | ComImportDetector 
Message Normal       2 |          0 | ResourceManagerCtor   
Message Normal       1 |          0 | DeveloperExperienceModeOnlyCodeRemover    
Message Normal       0 |          1 | ConvertManagedWinMD   
Message Low Done executing task "RunILTransforms".  
Message Low Done building target "RunILTransforms" in file "ILTransforms".  
Message Low Done building project "ILTransforms".   
Message Low     
Message Low     
Message Low Done building target "GenerateMDIL" in file "Nutc". 
Message Low     
Message High    Generating native code  
Message Low Done building target "MDILPrepareMultiFile" in file "Nutc". 
Message Low     
Message Low Done building target "SetBinaryForReferences" in file "Nutc".   
Message Low     
Message Low Task "GenerateMDILGlobalAnalysis"   
Message Normal  Launching 'C:\Users\HHH\.nuget\packages\runtime.win10-x86.microsoft.net.native.compiler\2.2.8-rel-28605-00\tools\x86\ilc\Tools\nutc_driver.exe @"F:\LAB\Fifi.APP.UWP\obj\x86\Release\ilc\intermediate\MDIL\Fifi.APP.UWP.rsp"'   
Message Low Microsoft (R) MDIL Compiler - Version 2.2.28605.00  
Message Low Copyright (c) Microsoft Corporation.  All rights reserved.  
Message Low Scanning input types    
Message Low Scanning 129710 methods.    
Message Low Scanning 26658 methods. 
Message Low Scanning 13836 methods. 
Message Low Scanning 7723 methods.  
Message Low Scanning 4523 methods.  
Message Low Scanning 3401 methods.  
Message Low Scanning 3013 methods.  
Message Low Scanning 1660 methods.  
Message Low Scanning 1233 methods.  
Message Low Scanning 995 methods.   
Message Low Scanning 990 methods.   
Message Low Scanning 831 methods.   
Message Low Scanning 600 methods.   
Message Low Scanning 349 methods.   
Message Low Scanning 180 methods.   
Message Low Scanning 133 methods.   
Message Low Scanning 60 methods.    
Message Low Scanning 10 methods.    
Message Low Scanning 18 methods.    
Message Low Scanning 12 methods.    
Message Low Scanning 10 methods.    
Message Low Scanning 10 methods.    
Message Low Eager code generation   
Message Low Compiling 195955 methods.   
Message Low Deferred code generation    
Message Low Compiling 7 methods.    
Message Low Compiling 1 methods.    
Message Low Call to managed method Initialize succeeded; exit code: 0 while generating CTL.Stack trace metadata statistics  
Message Low Number of methods emitted:   66744  
Message Low Metadata blob size:          1156431    
Message Low Method RVA - token map size: 533952 
Message Low Total native size:           1690383    
Message Low Successfully generated 'F:\LAB\Fifi.APP.UWP\obj\x86\Release\ilc\intermediate\MDIL\Fifi.APP.UWP.mdilexe' 
Message Low fatal error N1002: Out of Memory    
Error       0   
Message Low Done executing task "GenerateMDILGlobalAnalysis" -- FAILED. 
Message Low Done building target "GenerateMDILGlobalAnalysis" in file "Nutc" -- FAILED. 
Message Low Done building project "Nutc" -- FAILED. 
Message Low Compilation failed  

构建窗口的输出

70>Project Performance Summary: 
70>       14 ms  F:\LAB\Fifi.APP.csproj   5 calls   
70>        1 ms  GetTargetFrameworks                        1 calls   
70>        3 ms  GetTargetPath                              1 calls   
70>        1 ms  GetNativeManifest                          1 calls   
70>        7 ms  GetCopyToOutputDirectoryItems              1 calls   
70>        2 ms  GetPackagingOutputs                        1 calls   
70>   856261 ms  F:\LAB\Fifi.APP.UWP.csproj                 1 calls  
70>   856261 ms  _GenerateAppxPackage                       1 calls  
70> 
70>Target Performance Summary:  
70>        0 ms  _SuppressDeploymentOnlyFeatures            1 calls 
70>        0 ms  _PopulateCommonStateForGetCopyToOutputDirectoryItems 2 calls 

70>     2442 ms  XamlPreCompile                             1 calls 
70>     4311 ms  ComputeNativePackageInputsAndOutputs       1 calls 
70>     4797 ms  ResolveAssemblyReferences                  1 calls 
70>   831183 ms  BuildNativePackage                         1 calls    
70> 
70>Task Performance Summary:    
70>        0 ms  FindAppConfigFile                          1 calls 
70>        0 ms  ResolveNonMSBuildProjectOutput             1 calls 

70>     4258 ms  ComputeManagedBinaries                     1 calls 
70>     4796 ms  ResolveAssemblyReference                   1 calls 
70>   831139 ms  LoggerBasedExecTask                        1 calls    
70> 
70>Build FAILED.    
70> 
70>"F:\LAB\Fifi.APP.UWP.csproj" (_GenerateAppxPackage target) (1) ->    
70>(BuildNativePackage target) ->   
70>  C:\Users\HHH\.nuget\packages\microsoft.net.native.compiler\2.2.8-rel-28605-00\tools\Microsoft.NetNative.targets(801,5): error : ILT0005: 'C:\Users\HHH\.nuget\packages\runtime.win10-x86.microsoft.net.native.compiler\2.2.8-rel-28605-00\tools\x86\ilc\Tools\nutc_driver.exe @"F:\LAB\Fifi.APP.UWP\obj\x86\Release\ilc\intermediate\MDIL\Fifi.APP.UWP.rsp"' returned exit code 1  
70> 
70>    0 Warning(s) 
70>    1 Error(s)   
70> 
70>Time Elapsed 00:14:15.65 
========== Build: 69 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========    
========== Package: 0 succeeded, 3 failed ===========  

3. 我做了什么 我已经按照stackoverflow或网站上的提示,检查或尝试了下面所有这些步骤,但没有成功。

  • 确保路径和文件名中只有ASCII字符
  • 确保没有dotfuscator
  • 重新安装visual studio工具并升级
  • 确保已添加到default.rd.xml中。
  • 建立在与编码相同的系统账户中
  • 更新所有NuGet软件包
  • 曾在Visual Studio Enterprise 2019预览版16.7.0 Preview 1.0中尝试,也失败了
  • 移除所有分析器

4. Nuget软件包包含本方案有多个项目,这些nuget包都包含在一个或多个项目中。

 <PackageReference Include="System.Drawing.Common" Version="4.7.0"  />
 <PackageReference Include="Microsoft.Data.Sqlite" Version="3.1.4"  />
 <PackageReference Include="System.Data.SqlClient" Version="4.8.1" />
 <PackageReference Include="Newtonsoft.Json" Version="12.0.3"  />
 <PackageReference Include="Plugin.AudioRecorder" Version="1.1.0"  />
 <PackageReference Include="Plugin.MediaManager.Forms" Version="0.9.7"  />
 <PackageReference Include="Plugin.SpeechRecognition" Version="1.0.0"  />
 <PackageReference Include="Xam.Plugin.Media" Version="5.0.1"  />
 <PackageReference Include="Xamarin.Controls.SignaturePad.Forms" Version="3.0.0"  />
 <PackageReference Include="Xamarin.Essentials" Version="1.5.3.2"  />
 <PackageReference Include="Xamarin.Forms" Version="4.6.0.800"  />
 <PackageReference Include="Xamarin.Forms.InputKit" Version="3.3.0"  />
 <PackageReference Include="Xamarin.Plugin.FilePicker" Version="2.1.41"  />
 <PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform" Version="6.2.10"  />

5.compliance tools创立的第三个库这些库是建立在"\obj\x86\Release\ilc\in\"目录下的(x64和ARM构建仍为空,尚未处理)。

2020/02/27  19:15            58,232 clrcompression.dll
2020/04/07  19:14           936,960 e_sqlite3.dll
2018/11/12  17:29            76,152 Microsoft.AspNetCore.Http.Abstractions.dll
2018/11/12  17:28            32,120 Microsoft.AspNetCore.Http.Features.dll
2018/11/12  17:40           103,800 Microsoft.AspNetCore.Mvc.Abstractions.dll
2018/11/12  17:38            41,040 Microsoft.AspNetCore.Routing.Abstractions.dll
2020/02/27  19:15           300,928 Microsoft.CSharp.dll
2020/04/15  16:49           149,584 Microsoft.Data.Sqlite.dll
2018/11/11  00:26            36,416 Microsoft.Extensions.Primitives.dll
2016/11/30  02:58         1,162,904 Microsoft.Graphics.Canvas.dll
2018/11/12  17:28            74,616 Microsoft.Net.Http.Headers.dll
2020/02/27  19:15           173,952 Microsoft.VisualBasic.dll
2020/02/27  19:15            19,328 Microsoft.Win32.Primitives.dll
2020/02/27  19:15            56,192 mscorlib.dll
2020/02/27  19:15            93,568 netstandard.dll
2019/11/09  00:56           693,680 Newtonsoft.Json.dll
2020/05/16  02:38            93,184 SQLite-net.dll
2020/05/01  14:35             5,120 SQLitePCLRaw.batteries_v2.dll
2020/05/01  14:35            46,592 SQLitePCLRaw.core.dll
2020/05/01  14:35            35,840 SQLitePCLRaw.provider.e_sqlite3.dll
2020/02/27  19:15            15,736 System.AppContext.dll
2020/02/27  19:15            15,744 System.Buffers.dll
2020/02/27  19:15            84,864 System.Collections.Concurrent.dll
2020/02/27  19:15           107,600 System.Collections.dll
2020/02/27  19:15           349,256 System.Collections.Immutable.dll
2020/02/27  19:15            48,208 System.Collections.NonGeneric.dll
2020/02/27  19:15            42,880 System.Collections.Specialized.dll
2020/02/27  19:15            75,344 System.ComponentModel.Annotations.dll
2020/02/27  19:15           265,600 System.ComponentModel.Composition.dll
2020/02/27  19:15            14,720 System.ComponentModel.DataAnnotations.dll
2020/02/27  19:15            15,224 System.ComponentModel.dll
2020/02/27  19:15            24,960 System.ComponentModel.EventBasedAsync.dll
2020/02/27  19:15            33,664 System.ComponentModel.Primitives.dll
2020/02/27  19:15           293,760 System.ComponentModel.TypeConverter.dll
2020/02/27  19:15            17,488 System.Configuration.dll
2020/02/27  19:15            82,296 System.Console.dll
2020/02/27  19:15            20,040 System.Core.dll
2020/02/27  19:15           959,872 System.Data.Common.dll
2020/02/27  19:15            22,400 System.Data.dll
2020/01/17  18:41           984,960 System.Data.SqlClient.dll
2020/02/27  19:15            16,464 System.Diagnostics.Contracts.dll
2020/02/27  19:15            16,464 System.Diagnostics.Debug.dll
2019/11/15  08:54            51,784 System.Diagnostics.DiagnosticSource.dll
2020/02/27  19:15            25,472 System.Diagnostics.FileVersionInfo.dll
2020/02/27  19:15           110,672 System.Diagnostics.Process.dll
2020/02/27  19:15            22,912 System.Diagnostics.StackTrace.dll
2020/02/27  19:15            22,096 System.Diagnostics.TextWriterTraceListener.dll
2020/02/27  19:15            16,456 System.Diagnostics.Tools.dll
2020/02/27  19:15            53,328 System.Diagnostics.TraceSource.dll
2020/02/27  19:15            24,960 System.Diagnostics.Tracing.dll
2020/02/27  19:15            49,024 System.dll
2018/09/18  19:38           143,408 System.Drawing.Common.dll
2020/02/27  19:15            18,296 System.Drawing.dll
2020/02/27  19:15            51,792 System.Drawing.Primitives.dll
2020/02/27  19:15            17,000 System.Dynamic.Runtime.dll
2020/02/27  19:15            16,464 System.Globalization.Calendars.dll
2020/02/27  19:15            16,464 System.Globalization.dll
2020/02/27  19:15            16,464 System.Globalization.Extensions.dll
2020/02/27  19:15           118,352 System.IO.Compression.dll
2020/02/27  19:15            13,392 System.IO.Compression.FileSystem.dll
2020/02/27  19:15            22,904 System.IO.Compression.ZipFile.dll
2020/02/27  19:15            16,464 System.IO.dll
2020/02/27  19:15           112,000 System.IO.FileSystem.dll
2020/02/27  19:15            43,392 System.IO.FileSystem.DriveInfo.dll
2020/02/27  19:15            15,952 System.IO.FileSystem.Primitives.dll
2020/02/27  19:15            41,336 System.IO.FileSystem.Watcher.dll
2020/02/27  19:15            41,344 System.IO.IsolatedStorage.dll
2020/02/27  19:15            46,464 System.IO.MemoryMappedFiles.dll
2020/02/27  19:15            19,024 System.IO.Pipes.AccessControl.dll
2020/02/27  19:15            73,088 System.IO.Pipes.dll
2020/02/27  19:15            66,432 System.IO.Ports.dll
2020/02/27  19:15            15,952 System.IO.UnmanagedMemoryStream.dll
2020/02/27  19:15           115,280 System.Linq.dll
2020/02/27  19:15           448,896 System.Linq.Expressions.dll
2020/02/27  19:15           217,704 System.Linq.Parallel.dll
2020/02/27  19:15            68,688 System.Linq.Queryable.dll
2020/02/27  19:15            94,592 System.Memory.dll
2020/02/27  19:15            15,736 System.Net.dll
2020/02/27  19:15           268,160 System.Net.Http.dll
2020/02/27  19:15            14,720 System.Net.Http.Rtc.dll
2020/02/27  19:15           155,520 System.Net.HttpListener.dll
2020/02/27  19:15           230,776 System.Net.Mail.dll
2020/02/27  19:15            61,816 System.Net.NameResolution.dll
2020/02/27  19:15           108,624 System.Net.NetworkInformation.dll
2020/02/27  19:15            50,560 System.Net.Ping.dll
2020/02/27  19:15           104,824 System.Net.Primitives.dll
2020/02/27  19:15           161,664 System.Net.Requests.dll
2020/02/27  19:15           231,808 System.Net.Security.dll
2020/02/27  19:15            24,960 System.Net.ServicePoint.dll
2020/02/27  19:15           209,488 System.Net.Sockets.dll
2020/02/27  19:15            73,088 System.Net.WebClient.dll
2020/02/27  19:15            48,512 System.Net.WebHeaderCollection.dll
2020/02/27  19:15            19,840 System.Net.WebProxy.dll
2020/02/27  19:15            61,312 System.Net.WebSockets.Client.dll
2020/02/27  19:15            61,000 System.Net.WebSockets.dll
2020/02/27  19:15            13,696 System.Numerics.dll
2020/02/27  19:15            69,200 System.Numerics.Vectors.dll
2020/02/27  19:15            15,952 System.Numerics.Vectors.WindowsRuntime.dll
2020/02/27  19:15            44,112 System.ObjectModel.dll
2020/02/27  19:15           719,232 System.Private.DataContractSerialization.dll
2020/02/27  19:15           467,832 System.Private.Reflection.Metadata.Ecma335.dll
2020/02/27  19:15         1,906,696 System.Private.ServiceModel.dll
2020/02/27  19:15            99,920 System.Private.Uri.dll
2020/02/27  19:15         2,702,712 System.Private.Xml.dll
2020/02/27  19:15           145,792 System.Private.Xml.Linq.dll
2020/02/27  19:15            17,280 System.Reflection.Context.dll
2020/02/27  19:15            15,744 System.Reflection.DispatchProxy.dll
2020/02/27  19:15            17,000 System.Reflection.dll
2020/02/27  19:15            16,256 System.Reflection.Emit.dll
2020/02/27  19:15            16,464 System.Reflection.Emit.ILGeneration.dll
2020/02/27  19:15            15,744 System.Reflection.Emit.Lightweight.dll
2020/02/27  19:15            15,744 System.Reflection.Extensions.dll
2020/02/27  19:15           570,752 System.Reflection.Metadata.dll
2020/02/27  19:15            16,256 System.Reflection.Primitives.dll
2020/02/27  19:15            22,912 System.Reflection.TypeExtensions.dll
2020/02/27  19:15            15,744 System.Resources.Reader.dll
2020/02/27  19:15            16,464 System.Resources.ResourceManager.dll
2020/02/27  19:15            26,696 System.Resources.Writer.dll
2019/11/15  08:37            16,968 System.Runtime.CompilerServices.Unsafe.dll
2020/02/27  19:15            16,256 System.Runtime.CompilerServices.VisualC.dll
2020/02/27  19:15            44,112 System.Runtime.dll
2020/02/27  19:15           169,040 System.Runtime.Extensions.dll
2020/02/27  19:15            16,488 System.Runtime.Handles.dll
2020/02/27  19:15            32,640 System.Runtime.InteropServices.dll
2020/02/27  19:15            22,608 System.Runtime.InteropServices.RuntimeInformation.dll
2020/02/27  19:15            19,024 System.Runtime.InteropServices.WindowsRuntime.dll
2020/02/27  19:15            73,088 System.Runtime.Numerics.dll
2020/02/27  19:15            14,720 System.Runtime.Serialization.dll
2020/02/27  19:15           128,896 System.Runtime.Serialization.Formatters.dll
2020/02/27  19:15            16,464 System.Runtime.Serialization.Json.dll
2020/02/27  19:15            22,608 System.Runtime.Serialization.Primitives.dll
2020/02/27  19:15            16,976 System.Runtime.Serialization.Xml.dll
2020/02/27  19:15           109,944 System.Runtime.WindowsRuntime.dll
2020/02/27  19:15            40,016 System.Runtime.WindowsRuntime.UI.Xaml.dll
2020/02/27  19:15            98,176 System.Security.AccessControl.dll
2020/02/27  19:15            50,768 System.Security.Claims.dll
2020/02/27  19:15           158,792 System.Security.Cryptography.Algorithms.dll
2020/02/27  19:15           121,208 System.Security.Cryptography.Cng.dll
2020/02/27  19:15            84,352 System.Security.Cryptography.Csp.dll
2020/02/27  19:15            46,976 System.Security.Cryptography.Encoding.dll
2020/02/27  19:15            48,000 System.Security.Cryptography.Primitives.dll
2020/02/27  19:15           185,216 System.Security.Cryptography.X509Certificates.dll
2020/02/27  19:15            15,744 System.Security.dll
2020/02/27  19:15            89,472 System.Security.Permissions.dll
2020/02/27  19:15            15,440 System.Security.Principal.dll
2020/02/27  19:15            76,160 System.Security.Principal.Windows.dll
2020/02/27  19:15            15,744 System.Security.SecureString.dll
2020/02/27  19:15            30,728 System.ServiceModel.dll
2020/02/27  19:15            24,072 System.ServiceModel.Duplex.dll
2020/02/27  19:15            23,672 System.ServiceModel.Http.dll
2020/02/27  19:15            24,584 System.ServiceModel.NetTcp.dll
2020/02/27  19:15            29,736 System.ServiceModel.Primitives.dll
2020/02/27  19:15            23,160 System.ServiceModel.Security.dll
2020/02/27  19:15            14,720 System.ServiceModel.Web.dll
2020/02/27  19:15            14,200 System.ServiceProcess.dll
2019/11/15  08:53           755,576 System.Text.Encoding.CodePages.dll
2020/02/27  19:15            16,456 System.Text.Encoding.dll
2020/02/27  19:15            15,744 System.Text.Encoding.Extensions.dll
2018/05/15  13:29            61,072 System.Text.Encodings.Web.dll
2020/02/27  19:15           121,424 System.Text.RegularExpressions.dll
2020/02/27  19:15            56,192 System.Threading.dll
2020/02/27  19:15            19,536 System.Threading.Overlapped.dll
2020/02/27  19:15           168,528 System.Threading.Tasks.Dataflow.dll
2020/02/27  19:15            16,760 System.Threading.Tasks.dll
2020/02/27  19:15            16,256 System.Threading.Tasks.Extensions.dll
2020/02/27  19:15            52,304 System.Threading.Tasks.Parallel.dll
2020/02/27  19:15            29,568 System.Threading.Thread.dll
2020/02/27  19:15            15,744 System.Threading.ThreadPool.dll
2020/02/27  19:15            15,952 System.Threading.Timer.dll
2020/02/27  19:15            14,712 System.Transactions.dll
2020/02/27  19:15           170,360 System.Transactions.Local.dll
2020/02/27  19:15            18,296 System.ValueTuple.dll
2020/02/27  19:15            13,392 System.Web.dll
2020/02/27  19:15            24,448 System.Web.HttpUtility.dll
2020/02/27  19:15            13,696 System.Windows.dll
2020/02/27  19:15            21,880 System.Xml.dll
2020/02/27  19:15            14,440 System.Xml.Linq.dll
2020/02/27  19:15            22,096 System.Xml.ReaderWriter.dll
2020/02/27  19:15            14,416 System.Xml.Serialization.dll
2020/02/27  19:15            16,256 System.Xml.XDocument.dll
2020/02/27  19:15            16,976 System.Xml.XmlDocument.dll
2020/02/27  19:15            18,304 System.Xml.XmlSerializer.dll
2020/02/27  19:15            16,464 System.Xml.XPath.dll
2020/02/27  19:15            16,976 System.Xml.XPath.XDocument.dll
2020/02/27  19:15            14,208 WindowsBase.dll
2020/05/12  00:41           138,872 Xamarin.Essentials.dll
2020/05/16  20:12         1,103,992 Xamarin.Forms.Core.dll
2020/05/16  20:12            13,952 Xamarin.Forms.Platform.dll
2020/05/16  20:12           535,176 Xamarin.Forms.Platform.UAP.dll
2020/05/16  20:12           112,248 Xamarin.Forms.Xaml.dll

谁能帮帮我?非常感谢!

c# xamarin uwp xamarin.uwp
1个回答
0
投票

最后,我通过禁用反射和序列化,部分解决了这个问题。每次遵守需要10分钟以上,很耗时。我在这里分享我的步骤。

  1. 我达到了 用.NET Native编译应用程序,这真的很有帮助。我已经检查或修改了代码,以确保。

    • 去掉BinaryXML序列化,用用户定义序列化来代替。
    • 否 动态创建多维数组。
    • 无 动态类型
    • 删除潜在的Infinite通用类型扩展,如。

    公共抽象类LoadRangeBase : IDataLoadRangewhere TLoadLange : LoadRangeBase, new()

但遵从还是失败了。

2.在另一台机器上comply有24G内存,还是失败。编译器可能是32位的,内存再大也没用。

3.将解决方案拆成两个解决方案。每个解决方案符合SUCCESSED。我真的很惊讶。所以构建失败绝对不是Infinite generic type expansion造成的,构建失败不是代码造成的。在遵从过程中,我发现每个解决方案都占用了2G以上的内存,反射log.csv的大小超过900M。我的代码是基于通用抽象类的类型系统,我想可能真的是处理反射和序列化所需的内存多了。所以.NET Native工具链也许应该升级到64位。

4.尽量减少内存占用

  • 删除不需要或不定向引用的NuGet包或项目。
  • 根据以下内容修改rd.xml 运行时指令 (rd.xml) 配置文件参考文献删去 <Assembly Name="*Application*" Dynamic="Required All" />,并加 <Namespace Name="YourNamespace" Dynamic="Excluded" Serialize="Excluded" /> ,避免反射和序列化.构建成功后,msix文件大小一般减少5-6M。

最后,我的建议是注意UWP中的通用类型。

© www.soinside.com 2019 - 2024. All rights reserved.