Recently ran into the same problem, struggled for a bit, found this topic but no answers were correct for me.
My issue was that when I removed main window from my WPF project (it does not have a main window), I forgot to remove StartupUri
from App.xaml
. I guess this exception can happen if you have a mistake in StartupUri
, so in case if anybody is struggling with this - check your StartupUri
in App.xaml
.