Skip to content

Publishing a singel file breaks the assembly for this library. #274

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
JanssonTheBest opened this issue Dec 5, 2023 · 7 comments
Closed

Comments

@JanssonTheBest
Copy link

I recently tried publishing my project as a single file, by merging all the assemblies into to one exe, where I've used x86 on everything, but the screenrecorderlib assembly breaks.

System.BadImageFormatException
HResult=0x8007000B
Message=Could not load file or assembly 'ScreenRecorderLib, Version=1.0.8721.22425, Culture=neutral, PublicKeyToken=null'. An attempt was made to load a program with an incorrect format.

This exception was originally thrown at this call stack:
System.Runtime.Loader.AssemblyLoadContext.InternalLoad(System.ReadOnlySpan, System.ReadOnlySpan)
System.Reflection.Assembly.Load(byte[], byte[])
System.Reflection.Assembly.Load(byte[])
Costura.AssemblyLoader.ReadFromEmbeddedResources(System.Collections.Generic.Dictionary<string, string>, System.Collections.Generic.Dictionary<string, string>, System.Reflection.AssemblyName) in Common.cs
Costura.AssemblyLoader.ResolveAssembly(object, System.ResolveEventArgs) in ILTemplate.cs
System.Runtime.Loader.AssemblyLoadContext.InvokeResolveEvent(System.ResolveEventHandler, System.Reflection.RuntimeAssembly, string)
System.Runtime.Loader.AssemblyLoadContext.OnAssemblyResolve(System.Reflection.RuntimeAssembly, string)

Inner Exception 1:
BadImageFormatException: An attempt was made to load a program with an incorrect format. (0x8007000B)

@JanssonTheBest JanssonTheBest changed the title Publicing a signle file breaks the asembly for this library. Publishing a singel file breaks the assembly for this library. Dec 5, 2023
@sskodje
Copy link
Owner

sskodje commented Dec 5, 2023

Unfortunately, to my knowledge, single file deployment does not work with libraries compiled with c++/cli.

dotnet/sdk#12345

@sskodje sskodje closed this as completed Dec 5, 2023
@JanssonTheBest
Copy link
Author

Unfortunately, to my knowledge, single file deployment does not work with libraries compiled with c++/cli.

dotnet/sdk#12345

Any idea where i could start researching? What exactly is the issue, why cant I merge everything into one assembly?

@sskodje
Copy link
Owner

sskodje commented Dec 5, 2023

It's an issue with the dot net build tools apparently. I don't know any more unfortunately.

@JanssonTheBest
Copy link
Author

image
How would I do this?

@sskodje
Copy link
Owner

sskodje commented Dec 5, 2023

@JanssonTheBest
Copy link
Author

JanssonTheBest commented Feb 17, 2024

https://learn.microsoft.com/en-us/nuget/quickstart/install-and-use-a-package-in-visual-studio

I solved the problem through selfextracting and .net reflection

@D0nw0r
Copy link

D0nw0r commented May 15, 2025

https://learn.microsoft.com/en-us/nuget/quickstart/install-and-use-a-package-in-visual-studio

I solved the problem through selfextracting and .net reflection

Can you share your solution for this? I am running into the same problem and cant find a way :\

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants