【问题标题】:"fatal error N1002: Out of Memory" : Failed to build UWP release after successfully generated mdilexe“致命错误 N1002:内存不足”:成功生成 mdilexe 后无法构建 UWP 版本
【发布时间】:2020-09-14 21:09:00
【问题描述】:

1.摘要
我在跨平台 Xamarin(使用 Microsoft Visual Studio Enterprise 2019 版本 16.6.0)解决方案中有一个 UWP 项目,使用 .Net Standard 2.0 的库,使用最新 Windows 10 版本 1903(内部版本 18362)的 UWP,它可以在调试时成功运行( Android项目也可以在真手机上调试成功)。但是当我更改为发布和创建应用程序包时,它因“内存不足”而失败。 构建过程将近15分钟,系统内存(12G)终于用完了,直到失败。 编译成功生成mdileexe,但是突然失败。这可能是一个新的错误,我找不到任何类似的案例。

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 预览版 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.由遵守工具创建的第三个库
这些库位于“\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

有人请帮助我。非常感谢!

【问题讨论】:

  • 嗨。欢迎来到 StackOvervflow。将文本包装为 代码示例 将使您的文本在提供长日志时更具可读性。这确实保留了文本格式。那么就不需要在每一行都明确地
    了。
  • 我明白了!并且会节省很多时间。谢谢!
  • 您的项目中似乎包含未发布的模型nuget包,可以分享您使用的哪个nuget吗?
  • 我已在问题中添加了所有 nuget 包和第三个库列表。期待您的帮助。谢谢!
  • 您的应用是否使用过Microsoft.Data.Sqlite api,如果没有,请尝试将其删除并重新构建。

标签: c# xamarin uwp xamarin.uwp


【解决方案1】:

最后,我通过禁用反射和序列化部分解决了这个问题。每次合规需要超过10分钟,非常耗时。我在这里分享我的步骤。

  1. 我联系了Compiling Apps with .NET Native,它真的很有帮助。我已检查或修改代码以确保:

    • 删除 Binary/XML 序列化,由用户定义序列化替换
    • 不能动态创建多维数组
    • 无动态类型
    • 删除潜在的无限泛型类型扩展,例如:

    公共抽象类 LoadRangeBase : IDataLoadRange 其中 TLoadLange : LoadRangeBase, new()

但遵守仍然失败。

2.Comply在另一台有24G内存的机器上,仍然失败。编译器可能是32位的,更多的内存是没用的

3.将解决方案拆分为两个解决方案。每个解决方案都符合成功。我真的很惊讶。所以构建失败绝对不是由无限泛型类型扩展引起的,构建失败不是由代码引起的。在遵守过程中,我发现每个解决方案占用的内存超过2G,reflectionlog.csv的大小超过900M。我的代码是基于通用抽象类的类型系统,我想它可能真的内存不足,需要更多内存来处理反射和序列化。所以.NET Native 工具链可能应该升级到 64 位。

4.尽量减少内存使用

  • 删除不需要或未定向引用的 NuGet 包或项目
  • 根据Runtime Directives (rd.xml) Configuration File Reference修改rd.xml,删除&lt;Assembly Name="*Application*" Dynamic="Required All" /&gt;,增加&lt;Namespace Name="YourNamespace" Dynamic="Excluded" Serialize="Excluded" /&gt;,避免反射和序列化。 构建成功,msix 文件大小一般减少 5-6M。

最后,我的建议是在 UWP 中注意泛型。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-06-01
    • 2014-01-25
    • 2011-10-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多