✅ WPF application doesn't boot when packed to single file
Hello, I made a program in WPF, and in the publish settings I enabled "Produce single file", but the output .exe crashes before the window even shows up. There is an error in the event viewer, but I'm not exactly sure what to make of it (https://pastebin.com/85J3ZzDL). Here are my publish settings:
17 Replies
fix your error at line 67 in
VideoCompressor.xaml.cs
string strExeFilePath = System.Reflection.Assembly.GetExecutingAssembly().Location;
i dont get why this is making it crash
thank you or the response, btw
use
AppDomain.CurrentDomain.BaseDirectory
AppContext.BaseDirectory
That might work instead of using GetExecutingAssemblyoh shit its working now, thank you so much
i did this:
christ why is the executeable so fat
Because the runtime is embedded within the application
You can decide not to, but that would also mean requiring the user to install the runtime
You can turn it off by not using self-contained
yeahh
also what i did doesnt seem to have worked
the application starts now but theres a problem
basically when my program starts it checks to see if some required binaries exist in the working directory, and if they dont, then to download them
Don't use Environment.CurrentDirectory*
Use what I mentioned
ah ok
like this?
Actually, it's better if you use
AppContext.BaseDirectory
same issue came up again with this
I meant the other
yeah im trying that now
it should not give you null
same issue again
gimme a second
this is the code for checking if the binaries i need exist
does Directory.Exists check in the working directory?
hold on
i think i had a brainfart
its working now
its 11:30pm gimme a break 😭
thank you so much for your help
No problem
type
/close
if you want to close this thread