VS2015 VSIX System.OutOfMemoryException

2019-07-04 04:32发布

问题:

I created a new VSIX project and added a new item -> Extensibility -> Custom Tool Window

Then I tried to build, but it gave an error:

    1>------ Build started: Project: JSBQ, Configuration: Debug Any CPU ------
1>E:\JSBQ\packages\Microsoft.VSSDK.BuildTools.14.2.25123\tools\VSSDK\Microsoft.VsSDK.Common.targets(126,5): error MSB4018: The "VSCTCompiler" task failed unexpectedly.
1>E:\JSBQ\packages\Microsoft.VSSDK.BuildTools.14.2.25123\tools\VSSDK\Microsoft.VsSDK.Common.targets(126,5): error MSB4018: System.OutOfMemoryException: Out of memory.
1>E:\JSBQ\packages\Microsoft.VSSDK.BuildTools.14.2.25123\tools\VSSDK\Microsoft.VsSDK.Common.targets(126,5): error MSB4018:   
 at System.Drawing.Image.FromFile(String filename, Boolean useEmbeddedColorManagement)
1>E:\JSBQ\packages\Microsoft.VSSDK.BuildTools.14.2.25123\tools\VSSDK\Microsoft.VsSDK.Common.targets(126,5): error MSB4018:  
  at Microsoft.VisualStudio.CommandTable.BitmapItem.Read(TextReadVSCTCStream s, XmlElement itemNode)
1>E:\JSBQ\packages\Microsoft.VSSDK.BuildTools.14.2.25123\tools\VSSDK\Microsoft.VsSDK.Common.targets(126,5): error MSB4018:   
 at Microsoft.VisualStudio.CommandTable.ItemList.Read(TextReadVSCTCStream s, XmlElement listNode)
1>E:\JSBQ\packages\Microsoft.VSSDK.BuildTools.14.2.25123\tools\VSSDK\Microsoft.VsSDK.Common.targets(126,5): error MSB4018:    at Microsoft.VisualStudio.CommandTable.CommandTable.ReadCMDSSection(TextReadVSCTCStream s, XmlElement listNode)
1>E:\JSBQ\packages\Microsoft.VSSDK.BuildTools.14.2.25123\tools\VSSDK\Microsoft.VsSDK.Common.targets(126,5): error MSB4018:    
at Microsoft.VisualStudio.CommandTable.CommandTable.Read(TextReadVSCTCStream s)
1>E:\JSBQ\packages\Microsoft.VSSDK.BuildTools.14.2.25123\tools\VSSDK\Microsoft.VsSDK.Common.targets(126,5): error MSB4018:   
 at Microsoft.VisualStudio.CommandTable.CommandTable.Read(String fileName, ReadOptions ro, IMessageProcessor errorProcessor)
1>E:\JSBQ\packages\Microsoft.VSSDK.BuildTools.14.2.25123\tools\VSSDK\Microsoft.VsSDK.Common.targets(126,5): error MSB4018:    
at Microsoft.VisualStudio.CommandTable.CommandTable.Read(String fileName, IMessageProcessor errorProcessor)
1>E:\JSBQ\packages\Microsoft.VSSDK.BuildTools.14.2.25123\tools\VSSDK\Microsoft.VsSDK.Common.targets(126,5): error MSB4018:   
 at Microsoft.VisualStudio.CommandTable.Compiler.Compile()
1>E:\JSBQ\packages\Microsoft.VSSDK.BuildTools.14.2.25123\tools\VSSDK\Microsoft.VsSDK.Common.targets(126,5): error MSB4018:   
 at Microsoft.VisualStudio.CommandTable.VSCTCompiler.Execute()
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

and

    Severity    Code    Description Project File    Line    Column  Suppression State
Error       The "VSCTCompiler" task failed unexpectedly.
System.OutOfMemoryException: Out of memory.
   at System.Drawing.Image.FromFile(String filename, Boolean useEmbeddedColorManagement)
   at Microsoft.VisualStudio.CommandTable.BitmapItem.Read(TextReadVSCTCStream s, XmlElement itemNode)
   at Microsoft.VisualStudio.CommandTable.ItemList.Read(TextReadVSCTCStream s, XmlElement listNode)
   at Microsoft.VisualStudio.CommandTable.CommandTable.ReadCMDSSection(TextReadVSCTCStream s, XmlElement listNode)
   at Microsoft.VisualStudio.CommandTable.CommandTable.Read(TextReadVSCTCStream s)
   at Microsoft.VisualStudio.CommandTable.CommandTable.Read(String fileName, ReadOptions ro, IMessageProcessor errorProcessor)
   at Microsoft.VisualStudio.CommandTable.CommandTable.Read(String fileName, IMessageProcessor errorProcessor)
   at Microsoft.VisualStudio.CommandTable.Compiler.Compile()
   at Microsoft.VisualStudio.CommandTable.VSCTCompiler.Execute()    JSBQ

I did not edit any code, so why am I getting this error?

System : Windows 10
editor : Visual Studio 2015
.NET : 4.5

回答1:

I also meet this problem. It happens after added new tool window.

From the exception stack, I discover that the error is caused by reading image. So, I go to check the image created along with tool window. Finally, I discover that xxxx.png is a bad file and cannot be opended.

After deleted xxxx.png and commented bitmap node of xxxx.png in package.vsct, the VSIX project build successfully.