C# 无效的资源文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6973/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-07-31 16:45:21  来源:igfitidea点击:

Invalid Resource File

提问by Dan Walker

When attempting to compile my C# project, I get the following error:

尝试编译我的 C# 项目时,出现以下错误:

'C:\Documents and Settings\Dan\Desktop\Rowdy Pixel\Apps\CleanerMenu\CleanerMenu\obj\Debug\CSC97.tmp' is not a valid Win32 resource file.

Having gone through many Google searches, I have determined that this is usually caused by a 256x256 image inside an icon used by the project. I've gone through all the icons and removed the 256x256 versions, but the error persists. Any ideas on how to get rid of this?

经过多次 Google 搜索,我确定这通常是由项目使用的图标内的 256x256 图像引起的。我已经浏览了所有图标并删除了 256x256 版本,但错误仍然存​​在。关于如何摆脱这种情况的任何想法?



@Mike: It showed up mysteriously one night. I've searched the csproj file, but there's no mention of a CSC97.tmp (I also checked the solution file, but I had no luck there either). In case it helps, I've posted the contents of the csproj file on pastebin.

@Mike:有一天晚上它神秘地出现了。我搜索了 csproj 文件,但没有提到 CSC97.tmp (我也检查了解决方案文件,但我也没有运气)。如果有帮助,我已经在 pastebin 上发布了 csproj 文件内容

@Derek: No problem. Here's the compiler output.

@德里克:没问题。这是编译器输出。

------ Build started: Project: Infralution.Licensing, Configuration: Debug Any CPU ------
Infralution.Licensing -> C:\Documents and Settings\Dan\Desktop\Rowdy Pixel\Apps\CleanerMenu\Infralution.Licensing\bin\Debug\Infralution.Licensing.dll
------ Build started: Project: CleanerMenu, Configuration: Debug Any CPU ------
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Csc.exe /noconfig /nowarn:1701,1702 /errorreport:prompt /warn:4 /define:DEBUG;TRACE /main:CleanerMenu.Program /reference:"C:\Documents and Settings\Dan\Desktop\Rowdy Pixel\Apps\CleanerMenu\Infralution.Licensing\bin\Debug\Infralution.Licensing.dll" /reference:..\NotificationBar.dll /reference:..\PSTaskDialog.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll /reference:obj\Debug\Interop.IWshRuntimeLibrary.dll /debug+ /debug:full /optimize- /out:obj\Debug\CleanerMenu.exe /resource:obj\Debug\CleanerMenu.Form1.resources /resource:obj\Debug\CleanerMenu.frmAbout.resources /resource:obj\Debug\CleanerMenu.ModalProgressWindow.resources /resource:obj\Debug\CleanerMenu.Properties.Resources.resources /resource:obj\Debug\CleanerMenu.ShortcutPropertiesViewer.resources /resource:obj\Debug\CleanerMenu.LocalizedStrings.resources /resource:obj\Debug\CleanerMenu.UpdatedLicenseForm.resources /target:winexe /win32icon:CleanerMenu.ico ErrorHandler.cs Form1.cs Form1.Designer.cs frmAbout.cs frmAbout.Designer.cs Licensing.cs ModalProgressWindow.cs ModalProgressWindow.Designer.cs Program.cs Properties\AssemblyInfo.cs Properties\Resources.Designer.cs Properties\Settings.Designer.cs Scanner.cs ShortcutPropertiesViewer.cs ShortcutPropertiesViewer.Designer.cs LocalizedStrings.Designer.cs UpdatedLicenseForm.cs UpdatedLicenseForm.Designer.cs
error CS1583: 'C:\Documents and Settings\Dan\Desktop\Rowdy Pixel\Apps\CleanerMenu\CleanerMenu\obj\Debug\CSC97.tmp' is not a valid Win32 resource file

Compile complete -- 1 errors, 0 warnings
------ Skipped Build: Project: CleanerMenu Installer, Configuration: Debug ------
Project not selected to build for this solution configuration 
========== Build: 1 succeeded or up-to-date, 1 failed, 1 skipped ==========

I have also uploaded the icon I am using. You can view it here.

我还上传了我正在使用的图标。你可以在这里查看。



@Mike: Thanks! After removing everything but the 32x32 image, everything worked great. Now I can go back and add the other sizes one-by-one to see which one is causing me grief. :)

@迈克:谢谢!删除除 32x32 图像以外的所有内容后,一切正常。现在我可以回去将其他尺寸一一添加,看看哪一个让我感到悲伤。:)

@Derek: Since I first got the error, I'd done a complete reinstall of Windows (and along with it, the SDK.) It wasn't the main reason for the reinstall, but I had a slim hope that it would fix the problem.

@Derek:自从我第一次遇到错误以来,我已经完全重新安装了 Windows(以及随之而来的 SDK。)这不是重新安装的主要原因,但我希望它能修复问题。

Now if only I can figure out why it previously worked with all the other sizes...

现在,如果我能弄清楚为什么它以前适用于所有其他尺寸......

采纳答案by Mike Stone

I don't know if this will help, but from this forum:

我不知道这是否会有所帮助,但来自此论坛

Add an .ico file to the application section of the properties page, and recieved the error thats been described, when I checked the Icon file with an icon editor, it turn out that the file had more than one version of the image ie (16 x 16, 24 x 24, 32 x 32, 48 x 48 vista compressed), I removed the other formats that I didnt want resaved the file (just with 32x 32) and the application now compiles without error.

在属性页面的应用程序部分添加一个 .ico 文件,并收到所描述的错误,当我用图标编辑器检查图标文件时,结果发现该文件有多个版本的图像,即 (16 x 16、24 x 24、32 x 32、48 x 48 vista 压缩),我删除了我不想重新保存文件的其他格式(仅使用 32x 32),并且应用程序现在可以无误地编译。

Try opening the icon in an icon editor and see if you see other formats like described (also, try removing the icon and seeing if the project will build again, just to verify the icon is causing it).

尝试在图标编辑器中打开图标,看看您是否看到其他类似描述的格式(另外,尝试删除图标并查看项目是否会再次构建,只是为了验证图标是否导致它)。

回答by Mike Stone

Is this a file you created and added to the project or did it mysteriously show up?

这是您创建并添加到项目中的文件还是它神秘地出现了?

You can maybe check your .csproj file and see how it is being referenced (it should be a simple xml file and you can search for CSC97.tmp).

您可以检查您的 .csproj 文件并查看它是如何被引用的(它应该是一个简单的 xml 文件,您可以搜索 CSC97.tmp)。

Perhaps post the information you find so we can have more details to help solve your problem

也许发布您找到的信息,以便我们了解更多详细信息来帮助您解决问题

回答by Derek Park

Looking around, it seems some people resolved this by repairing or reinstalling the .NET SDK. You might want to give that a try.

环顾四周,似乎有些人通过修复或重新安装 .NET SDK 解决了这个问题。您可能想尝试一下。

P.S. I see why you didn't include more of the compiler output, now. Not much to really see there. :)

PS 我明白为什么你现在没有包含更多的编译器输出。在那里真正可以看到的不多。:)

回答by meddlingwithfire

I had a similar issue with an "obj/debug/*.tmp" file erroring out in my build log. Turns out my C:\ drive was out of space. After clearing some space, my builds started working.

我在构建日志中遇到了类似的“obj/debug/ *.tmp”文件错误问题。原来我的 C:\ 驱动器空间不足。清理一些空间后,我的构建开始工作。