"GenerateResource" 任务意外失败
The "GenerateResource" task failed unexpectedly
今天我安装了 ReSharper 免费试用版来清理 Visual Studio 2015 年的一个应用程序。
我一直使用 alt + b + h
构建此应用程序,这与选择 Build -> Publish AppName
相同,在生成 EXE 时,这通常非常可靠,可以使用。
然而,在做了一些清理(主要是 LINQ 查询、重命名和删除不再使用的 methods/fields)之后,我在尝试发布时看到了这个错误:
Error The "GenerateResource" task failed unexpectedly.
System.Runtime.InteropServices.ExternalException (0x80004005): A generic error occurred in GDI+.
at System.Drawing.Image.Save(Stream stream, ImageCodecInfo encoder, EncoderParameters encoderParams)
at System.Drawing.Image.Save(MemoryStream stream)
at System.Drawing.Image.System.Runtime.Serialization.ISerializable.GetObjectData(SerializationInfo si, StreamingContext context)
at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter)
at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter)
at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph)
at System.Resources.ResourceWriter.WriteValue(ResourceTypeCode typeCode, Object value, BinaryWriter writer, IFormatter objFormatter)
at System.Resources.ResourceWriter.Generate()
at System.Resources.ResourceWriter.Dispose(Boolean disposing)
at System.Resources.ResourceWriter.Close()
at Microsoft.Build.Tasks.ProcessResourceFiles.WriteResources(IResourceWriter writer)
at Microsoft.Build.Tasks.ProcessResourceFiles.WriteResources(String filename)
at Microsoft.Build.Tasks.ProcessResourceFiles.ProcessFile(String inFile, String outFile)
at Microsoft.Build.Tasks.ProcessResourceFiles.Run(TaskLoggingHelper log, ITaskItem[] assemblyFilesList, ArrayList inputs, ArrayList outputs, Boolean sourcePath, String language, String namespacename, String resourcesNamespace, String filename, String classname, Boolean publicClass)
at Microsoft.Build.Tasks.ProcessResourceFiles.Run(TaskLoggingHelper log, ITaskItem[] assemblyFilesList, ArrayList inputs, ArrayList outputs, Boolean sourcePath, String language, String namespacename, String resourcesNamespace, String filename, String classname, Boolean publicClass)
at Microsoft.Build.Tasks.GenerateResource.Execute()
at Microsoft.Build.CommandLine.OutOfProcTaskAppDomainWrapperBase.InstantiateAndExecuteTask(IBuildEngine oopTaskHostNode, LoadedType taskType, String taskName, String taskLocation, String taskFile, Int32 taskLine, Int32 taskColumn, AppDomainSetup appDomainSetup, IDictionary`2 taskParams) ITHelpre
并且没有生成任何输出。
我已经重新启动 VS 但没有任何效果,并且还注意到我能够通过打开 Developer Command Prompt for VS2015
和 运行 "msbuild C:/path/to/solution.sln"
.
来构建项目
这确实在正确的位置创建了一个 EXE,但每当我尝试打开它时,我得到
Appname has stopped working - Windows is collecting more information about the problem. This might take several minutes...
有没有人能告诉我如何弄清楚这个问题?
额外详情
查看 VS 中的表单设计器后,我可以看到我的一张图像已损坏(颜色已更改,并且有很多以前没有的线条和标记)
删除了我发现的一些看起来已损坏的图像,项目已构建,但在执行时仍然崩溃
在调试模式下 运行 之后,我注意到它在调用 PageControl
时在资源设计器中抛出异常(即使它已经被声明)。
这似乎是在更改后发生的:
Class PageControl1
{
// Code goes here
}
为此:
namespace AppName
{
Class PageControl1
{
// Code goes here
}
}
我不太明白 - 对我来说,应用程序使用的 class 应该与该应用程序中使用的所有其他 class 位于同一个命名空间中是有道理的.我将非常感谢对此的任何见解。
将 PageControl1
改回原来的样子后,我删除了 2 个损坏的图像(在进行上述 namespace
更改后,它们似乎直接损坏了,并用一些新的替换了它们图片,这解决了我的问题。
今天我安装了 ReSharper 免费试用版来清理 Visual Studio 2015 年的一个应用程序。
我一直使用 alt + b + h
构建此应用程序,这与选择 Build -> Publish AppName
相同,在生成 EXE 时,这通常非常可靠,可以使用。
然而,在做了一些清理(主要是 LINQ 查询、重命名和删除不再使用的 methods/fields)之后,我在尝试发布时看到了这个错误:
Error The "GenerateResource" task failed unexpectedly.
System.Runtime.InteropServices.ExternalException (0x80004005): A generic error occurred in GDI+.
at System.Drawing.Image.Save(Stream stream, ImageCodecInfo encoder, EncoderParameters encoderParams)
at System.Drawing.Image.Save(MemoryStream stream)
at System.Drawing.Image.System.Runtime.Serialization.ISerializable.GetObjectData(SerializationInfo si, StreamingContext context)
at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter)
at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter)
at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph)
at System.Resources.ResourceWriter.WriteValue(ResourceTypeCode typeCode, Object value, BinaryWriter writer, IFormatter objFormatter)
at System.Resources.ResourceWriter.Generate()
at System.Resources.ResourceWriter.Dispose(Boolean disposing)
at System.Resources.ResourceWriter.Close()
at Microsoft.Build.Tasks.ProcessResourceFiles.WriteResources(IResourceWriter writer)
at Microsoft.Build.Tasks.ProcessResourceFiles.WriteResources(String filename)
at Microsoft.Build.Tasks.ProcessResourceFiles.ProcessFile(String inFile, String outFile)
at Microsoft.Build.Tasks.ProcessResourceFiles.Run(TaskLoggingHelper log, ITaskItem[] assemblyFilesList, ArrayList inputs, ArrayList outputs, Boolean sourcePath, String language, String namespacename, String resourcesNamespace, String filename, String classname, Boolean publicClass)
at Microsoft.Build.Tasks.ProcessResourceFiles.Run(TaskLoggingHelper log, ITaskItem[] assemblyFilesList, ArrayList inputs, ArrayList outputs, Boolean sourcePath, String language, String namespacename, String resourcesNamespace, String filename, String classname, Boolean publicClass)
at Microsoft.Build.Tasks.GenerateResource.Execute()
at Microsoft.Build.CommandLine.OutOfProcTaskAppDomainWrapperBase.InstantiateAndExecuteTask(IBuildEngine oopTaskHostNode, LoadedType taskType, String taskName, String taskLocation, String taskFile, Int32 taskLine, Int32 taskColumn, AppDomainSetup appDomainSetup, IDictionary`2 taskParams) ITHelpre
并且没有生成任何输出。
我已经重新启动 VS 但没有任何效果,并且还注意到我能够通过打开 Developer Command Prompt for VS2015
和 运行 "msbuild C:/path/to/solution.sln"
.
这确实在正确的位置创建了一个 EXE,但每当我尝试打开它时,我得到
Appname has stopped working - Windows is collecting more information about the problem. This might take several minutes...
有没有人能告诉我如何弄清楚这个问题?
额外详情
查看 VS 中的表单设计器后,我可以看到我的一张图像已损坏(颜色已更改,并且有很多以前没有的线条和标记)
删除了我发现的一些看起来已损坏的图像,项目已构建,但在执行时仍然崩溃
在调试模式下 运行 之后,我注意到它在调用 PageControl
时在资源设计器中抛出异常(即使它已经被声明)。
这似乎是在更改后发生的:
Class PageControl1
{
// Code goes here
}
为此:
namespace AppName
{
Class PageControl1
{
// Code goes here
}
}
我不太明白 - 对我来说,应用程序使用的 class 应该与该应用程序中使用的所有其他 class 位于同一个命名空间中是有道理的.我将非常感谢对此的任何见解。
将 PageControl1
改回原来的样子后,我删除了 2 个损坏的图像(在进行上述 namespace
更改后,它们似乎直接损坏了,并用一些新的替换了它们图片,这解决了我的问题。