Skip to content

OffScreen fails to load with BadImageFormatException when running in Godot 4.0 #4473

@emelrad12

Description

@emelrad12
  • What version of the product are you using?
    Version=112.2.70.0
    CefSharp.OffScreen.NETCore

  • What architecture x86 or x64?
    x64

  • What version of .Net?
    6.0
    But it is using actually Godot.NET.Sdk/4.0.2
    Which seems to be a fork of Microsoft.NET.Sdk

  • On what operating system?
    Win11

  • Are you using WinForms, WPF or OffScreen?
    OffScreen

  • What steps will reproduce the problem?
    Make a new Godot c# project and import Cef sharp into it
    Try to load a new ChromiumWebBrowser()

  • What is the expected output? What do you see instead?
    I get this exception
    ERROR: System.BadImageFormatException: Could not load file or assembly 'CefSharp.Core.Runtime, Version=112.2.70.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138'. An attempt was made to load a program with an incorrect format.
    File name: 'CefSharp.Core.Runtime, Version=112.2.70.0, Culture=neutral, PublicKeyToken=40c4b6fc221f4138' ---> System.BadImageFormatException: Could not load file or assembly ''. An attempt was made to load a program with an incorrect format.
    File name: ''
    at System.Runtime.Loader.AssemblyLoadContext.InternalLoad(ReadOnlySpan1 arrAssembly, ReadOnlySpan1 arrSymbols)
    at System.Runtime.Loader.AssemblyLoadContext.LoadFromStream(Stream assembly, Stream assemblySymbols)
    at GodotPlugins.PluginLoadContext.Load(AssemblyName assemblyName) in /root/godot/modules/mono/glue/GodotSharp/GodotPlugins/PluginLoadContext.cs:line 69
    at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingLoad(AssemblyName assemblyName)
    at System.Runtime.Loader.AssemblyLoadContext.Resolve(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName)
    at CefSharp.Cef.get_IsInitialized()
    at CefSharp.OffScreen.ChromiumWebBrowser..ctor(String address, IBrowserSettings browserSettings, IRequestContext requestContext, Boolean automaticallyCreateBrowser, Action`1 onAfterBrowserCreated, Boolean useLegacyRenderHandler) in C:\projects\cefsharp\CefSharp.OffScreen\ChromiumWebBrowser.cs:line 213
    at WeirdGame.UI.CefMain.Init() in D:\Projects\WeirdGame\Src\UI\CefMain.cs:line 11
    at WeirdGame.GameMain._Ready() in D:\Projects\WeirdGame\GameMain.cs:line 28
    at Godot.Node.InvokeGodotClassMethod(godot_string_name& method, NativeVariantPtrArgs args, godot_variant& ret) in /root/godot/modules/mono/glue/GodotSharp/GodotSharp/Generated/GodotObjects/Node.cs:line 1801
    at WeirdGame.GameMain.InvokeGodotClassMethod(godot_string_name& method, NativeVariantPtrArgs args, godot_variant& ret) in D:\Projects\WeirdGame\Godot.SourceGenerators\Godot.SourceGenerators.ScriptMethodsGenerator\WeirdGame.GameMain_ScriptMethods.generated.cs:line 40
    at Godot.Bridge.CSharpInstanceBridge.Call(IntPtr godotObjectGCHandle, godot_string_name* method, godot_variant** args, Int32 argCount, godot_variant_call_error* refCallError, godot_variant* ret) in /root/godot/modules/mono/glue/GodotSharp/GodotSharp/Core/Bridge/CSharpInstanceBridge.cs:line 24

  • Does this problem also occur in the CEF Sample Application
    No, it is only related to using godot

Note that Godot switched to net 6.0(not using mono anymore) recently and is using a fork of the net sdk, so most likely CefSharp is having an issue with that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions