简体   繁体   English

“ GenerateResource”任务意外失败

[英]The “GenerateResource” task failed unexpectedly

Today I installed the free trial of ReSharper to clean up an application in Visual Studio 2015. 今天,我安装了ReSharper的免费试用版,以清理Visual Studio 2015中的应用程序。

I have always built this application by using alt + b + h which is the same as choosing Build -> Publish AppName , and this is usually pretty reliable when it comes to producing an EXE, ready to use. 我一直使用alt + b + h来构建此应用程序,这与选择Build -> Publish AppName ,并且在生成可随时使用的EXE时通常非常可靠。

However, after doing some cleaning up (mainly LINQ queries, renames and deleting no-longer-used methods/fields), I see this error when try to publish: 但是,在进行了一些清理(主要是LINQ查询,重命名和删除不再使用的方法/字段)之后,尝试发布时出现了此错误:

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            

And no output is generated. 并且不生成任何输出。

I have restarted VS with no effect, and have also noticed that I was able to build the project by opening Developer Command Prompt for VS2015 and running "msbuild C:/path/to/solution.sln" . 我已经重新启动VS没有任何效果,并且还注意到我能够通过打开Developer Command Prompt for VS2015并运行"msbuild C:/path/to/solution.sln"来构建项目。

This did create an EXE in the right place, but whenever I try opening it I get 确实在正确的位置创建了一个EXE,但是每当我尝试打开它时,我都会得到

Appname has stopped working - Windows is collecting more information about the problem. This might take several minutes...

Does anyone have any tips as to how I can get to the bottom of this? 关于我如何深入了解这个问题,有没有人有任何提示?

Extra Details 额外细节

After looking at the Form Designer in VS, I can see that one of my images is corrupted (the colours have changed and lots of lines and marks which weren't there before) 在VS中查看“表单设计器”后,我可以看到我的一张图像已损坏(颜色已更改,并且之前没有出现很多线条和标记)

Removing a couple of images I found which looked corrupted, the project built, but still crashes on execution 删除我发现的几张看起来已损坏的图像,构建了项目,但是在执行时仍然崩溃

After running in debug mode I noticed it was throwing an exception in the Resource Designer when PageControl was being called (even though it had already been declared). 在调试模式下运行后,我注意到它在调用PageControl时在资源设计器中引发了异常(即使已声明)。

This seems to have happened after changing this: 更改以下内容后似乎发生了这种情况:

Class PageControl1
{
    // Code goes here
}

To this: 对此:

namespace AppName
{
    Class PageControl1
    {
        // Code goes here
    }
}

Which I don't quite understand - to me it makes sense that a class being used by the application should live in the same namespace as all the other classes used in that application. 我不太了解-对我来说,应用程序使用的类应与该应用程序中使用的所有其他类位于相同的名称空间中,这是有意义的。 I would very much appreciate any insight into this. 我非常感谢对此有任何见解。

After changing PageControl1 back to how it looked originally, I removed the 2 corrupted images (which appear to have become corrupt straight after making the above namespace change, and replaced them with some new images, and this solved my problem. PageControl1恢复为原始PageControl1后,我删除了2个损坏的图像(在更改了上述namespace之后,这些图像似乎已经损坏了,并用一些新图像替换了它们,这解决了我的问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 “ GenerateResource”任务意外失败,C#Windows Form和DevExpress - The “GenerateResource” task failed unexpectedly C# Windows Form and DevExpress “ GenerateResource”任务意外失败,内部出现空引用异常 - The “GenerateResource” task failed unexpectedly whit inner null reference exception 错误“ GenerateResource”任务意外失败,C#Windows Forms应用程序 - Error the “GenerateResource” task failed unexpectedly C# Windows Forms app 资源,“ GenerateResource”任务意外失败(Image.Save),以及TIFF? - Resources, “GenerateResource” task failed unexpectedly (Image.Save), and TIFFs? Microsoft.Build.Tasks.v12.0.dll上的UniversalApp错误“ GenerateResource任务意外失败” - UniversalApp Error “GenerateResource task failed unexpectedly” on Microsoft.Build.Tasks.v12.0.dll “ GenerateResource”任务意外失败-尝试读取或写入受保护的内存。 这通常表明其他内存已损坏 - The “GenerateResource” task failed unexpectedly- Attempted to read or write protected memory. This is often an indication that other memory is corrupt Winform C#应用程序中的“ GenerateResource”任务失败 - “GenerateResource” task failed in winform c# app “复制”任务意外失败 - The “Copy” task failed unexpectedly “ValidateAppxPackage”任务意外失败 - The “ValidateAppxPackage” task failed unexpectedly “ WireUpCoreRuntime”任务意外失败 - The “WireUpCoreRuntime” task failed unexpectedly
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM