有趣的错误-MSB3246:解析的文件的图像质量不好,没有元数据,或者无法访问。 图片太小。

I got a very strange warning recently when building a .NET Core app with "dotnet build."

最近,使用“ dotnet构建”构建.NET Core应用程序时,我得到一个非常奇怪的警告。

MSB3246: Resolved file has a bad image, no metadata, or is otherwise inaccessible. 
Image is too small.

Interesting Bug used under CC https://flic.kr/p/4SpmL6
Eek! It's clear, in that something is "too small" but what? A file I guess? Maybe it's the wrong size?

ek! 很明显,有些东西“太小了”,但是又是什么呢? 我猜是文件吗? 可能尺寸不正确?

The error code is MSB3246 which is nice and googleable/searchable but it was confusing because I couldn't figure our what file specifically. It just felt vague.

错误代码是MSB3246,它很好并且可谷歌搜索/搜索,但令人困惑,因为我无法具体确定我们的文件。 只是感到模糊。

BUT!

但!

I had recently been overclocking my machine (overly aggressively, gulp, about 40%) and had a very nasty hard reboot. As a result I had a few dozen files get orphaned - specifically the files were zero'ed out! Zero is small, right?

我最近对我的机器进行了超频(过于激进,大口吃,大约40%),并且进行了非常讨厌的硬重启。 结果,我有几十个文件被孤立了-特别是文件被清零了! 零很小,对吧?

Turns out you can pass parameters over to MSBuild from "dotnet build" and see what MSBuild is doing internally. For example, you could

事实证明,您可以将参数从“ dotnet build”传递到MSBuild,并查看MSBuild在内部进行的操作。 例如,您可以

/fileLoggerParameters:verbosity=diagnostic

but that's long. So how about:

但这很长。 那么如何:

dotnet build /flp:v=diag

Cool. What deep logging do I see now?

凉。 我现在看到什么深度日志?

Primary reference "deliberately.zero.bytes.dll". (TaskId:41)
13:36:52.397 1:7>C:\Program Files\dotnet\sdk\2.1.400\Microsoft.Common.CurrentVersion.targets(2110,5): warning MSB3246: Resolved file has a bad image, no metadata, or is otherwise inaccessible. Image is too small. [S:\work\zero-byte-ref\zero-byte-ref.csproj]
Resolved file path is "S:\work\zero-byte-ref\deliberately.zero.bytes.dll". (TaskId:41)
Reference found at search path location "{RawFileName}". (TaskId:41)

Now with "verbose" turned on I can see that one of the references is zero'ed out/corrupted/bad. I reinstalled .NET Core in my case and doubled checked all the DLLs/Assemblies that I was bringing in - I also ran chkdsk /f - and I was back in business!

现在打开“ verbose”,我可以看到其中的一个引用被归零/损坏/损坏。 在我的情况下,我重新安装了.NET Core,并仔细检查了我要带入的所有DLL /程序集-我还运行了chkdsk / f-然后我又重新开始工作!

I hope this helps someone who might stumble on error MSB3246 and wonder what's up.

我希望这对可能偶然发现错误MSB3246并想知道怎么回事的人有所帮助。

Even better, thanks to Rainer Sigwald who filed a bug against MSBuild to update the error message to be more clear. In the future I'll be able to debug this without changing verbosity!

更好的是,感谢Rainer Sigwald向MSBuild提交了一个错误,以更清楚地更新错误消息。 将来,我将能够在更改详细程度的情况下对其进行调试!

翻译自: https://www.hanselman.com/blog/interesting-bugs-msb3246-resolved-file-has-a-bad-image-no-metadata-or-is-otherwise-inaccessible-image-is-too-small

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值