YamlDotNet icon indicating copy to clipboard operation
YamlDotNet copied to clipboard

System.IO.FileLoadException: System.IO.FileLoadException : Could not load file or assembly 'YamlDotNet

Open samueleresca opened this issue 6 years ago • 9 comments
trafficstars

Hi,

I'm getting the following error when I try to use the package in a netcoreapp2.1

System.IO.FileLoadException : Could not load file or assembly 'YamlDotNet, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null'. Error 2147500035 (Exception from HRESULT: 0x80004003 (E_POINTER))

samueleresca avatar Dec 12 '18 15:12 samueleresca

I'm getting that, too, but for Version 6.0.0.0 - what's wrong here. I'm not very used to nuget package management. This is really annoying. Can anyone help?

Onnno avatar Apr 02 '19 19:04 Onnno

Was it working with an earlier version? Maybe this is due to the merging of the signed and non-signed packages. From release 6.0.0, the YamlDotNet assembly will always vhave a strong name, which means that updating the YamlDotNet assembly without recompiling you code won't work. In general, if you upgrade a major version, you should expect to have to make changes to your code anyways.

aaubry avatar Apr 02 '19 20:04 aaubry

@samueleresca, are you still having this problem? There was an error in the building scripts that caused some released assemblies to have version 0.0.0.0. Maybe this was the cause of your problem?

aaubry avatar Apr 02 '19 20:04 aaubry

No, it was not working with an earlier version. (I uninstalled 6.0.0. and removed the reference and installed 5.0.0). The only idea I have is that the public key might not work. But I removed it from the references, so it looks like this:

<Reference Include="YamlDotNet, Version=5.0.0.0, Culture=neutral, processorArchitecture=MSIL">
  <HintPath>..\packages\YamlDotNet.5.4.0\lib\net45\YamlDotNet.dll</HintPath>
</Reference>

Doesn't work anyway.

Onnno avatar Apr 03 '19 09:04 Onnno

I'm fighting with the same issue having YamlDotNet as dependency for https://github.com/kubernetes-client/csharp I have 4.2.3 on the same server/IIS other App, but 6.0.0 is issue.

Could not load file or assembly 'YamlDotNet, Version=6.0.0.0, Culture=neutral, PublicKeyToken=ec19458f3c15af5e' or one of its dependencies. A strongly-named assembly is required.

nudzo avatar May 31 '19 08:05 nudzo

I couldn't resolve that issue. I instead use SharpYaml now. Problem is, that docfx uses YamlDotNet also, but using version 4.2.2.0. Have a look at packages/docfx.console.2.42.3\tools. Before docfx executes, it copies all files from your postprocessors build directory (where your post processor dll is build to), to packages/docfx.console.2.42.3\tools\wlerfkm temporarily where wlerfkm is some temporary folder name. That's where your version 6.0.0 should be copied. However, there then still is the conflict you mentioned due the order folders are searched for assemblies...

Onnno avatar Jun 04 '19 12:06 Onnno

I think there are different issues here. First, if you have an assembly that is referencing a version of YamlDotNet prior to version 6.0.0 and try to update the assembly to a version >= 6.0.0, that won't work because the new assembly has a strong name while the old one doesn't. But anyways you should not be doing that because YamlDotNet uses semantic versioning, which means that major version number increments indicate a breaking change. Even if your code was able to load the assembly, it would probably fail at runtime with a MissingMethodException or simmilar.

The proper solution is to recompile your assemblies against version 6.0.0. If you can't do that because some dependency that you don't control uses an older version, you should keep using that version until the dependency is updated.

If this does not address someone's issue, please provide more details and, if possible, some code that reproduces the problem. Thanks!

aaubry avatar Jun 10 '19 16:06 aaubry

In my case... KubernetesNet client do reference 6.0.0. Nevertheless I tried some some small class just with YamlDotNet and there's issue too. I'm targeting Framework 4.6 or 4.7. I tried to recompile KubernetesNet with dependency to 6.1.1, but issue is the same. At the moment I downgraded to 5.4.0 for KubernetesNet and my stuff... this is only working setup for me, thus unsigned YamlDotNet.

nudzo avatar Jun 14 '19 09:06 nudzo

I've had the same issue. First I created a .NetStandard2.0 class library project but then changed my mind and wanted to execute it as a console app as a demo. I changed the project's output type from class library to console application but missed that the project type still was .NetStandard2.0 instead of .NetCoreApp2.1. Changing that made the runtime environment load the assembly (YamlDotNet 6.1.1, not YamlDotNet.NetCore 1.0.0) just fine.

KristianVirkus avatar Jun 18 '19 05:06 KristianVirkus