Skip to content

VS2022 - "CefSharp.Core.Runtime.dll" ends up in my "bin" folder instead of only in "bin\x86" #3854

@UweKeim

Description

@UweKeim

(As @amaitland granted me permission to paste my Stack Overflow issue here, following is the posting)

Using CefSharp.WinForms successfully since years, I recently am unable to run my WinForms .NET 4.8 application, because of this runtime error:

System.BadImageFormatException

Die Datei oder Assembly "CefSharp.Core.Runtime, Version=94.4.50.0,
Culture=neutral, PublicKeyToken=40c4b6fc221f4138" oder eine
Abhängigkeit davon wurde nicht gefunden. Es wurde versucht, eine Datei
mit einem falschen Format zu laden.

Translated to English this should read something like:

System.BadImageFormatException

Could not load file or assembly "CefSharp.Core.Runtime, Version=94.4.50.0,
Culture=neutral, PublicKeyToken=40c4b6fc221f4138"" or one of its dependencies. An attempt was made to load a program with an incorrect format.

This happened literally out of nowhere, after all these years of successfully using CefSharp.

I recently switched to VS 2022 RC, but I'm not sure whether this is the cause of it.

Upon further investigation, I found out that the x86 version of "CefSharp.Core.Runtime.dll" ended up both in my "bin" folder, as well as in my "bin\x86" folder.

Since my application also supports x64 and therefore on my system runs as 64-bit, it tries to load the x86 "CefSharp.Core.Runtime.dll" from the "bin" folder instead of the "bin\x64" folder.

Both folders "bin\x64" and "bin\x86" contains their respective correct version of "CefSharp.Core.Runtime.dll", but in addition there is also the x86 version of "CefSharp.Core.Runtime.dll" directly in "bin".

When manually deleting the "CefSharp.Core.Runtime.dll" in the bin folder, everything works correctly, again and my application runs correctly.

AssemblyResolve is not fired, since it is only called for failed resolutions, and since "CefSharp.Core.Runtime.dll" is present directly in "bin", no failure in terms of assembly resolution occurs.

I've also tried to uninstall and install CefSharp NuGet packages, but still does not hinder the build process from putting "CefSharp.Core.Runtime.dll" directly into the "bin" folder.

I do suspect some build script/target of CefSharp to be the cause of this, but unfortunately I'm not that much into MSBuild to understand what to look for and where.

My question

How to force CefSharp to not put bitness dependent assemblies into "bin" but only into "bin\x86" and "bin\x64"?

Update 1

I do think something along in "CefSharp.Common.94.4.50\buildTransitive\CefSharp.Common.targets" is responsible for this, but again, I'm not sure where to adjust and what to adjust.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions