MissingManifestException in mscorlib.dll on IMessa

2019-08-31 05:28发布

问题:

In my view model, I have a IMessageService, which is initialized in the constructor:

private IMessageService messageService;
public MyViewModel()
{
    messageService = ServiceLocator.Default.ResolveType<IMessageService>();
}

Its Show method works, but ShowError, ShowInformation and ShowWarning (anything in need of a resource, here the icons) crash with a MissingManifestException pointing towards Catel.Properties.Resources.resources manifest.

Is the error on my side (wrongly installed Catel) or is it because it's the .Net 4.0 version of Catel? Surprisingly, I have another Catel for .Net 4.0 project which doesn't show this error.

EDIT: Show, when given a MessageImage, works flawlessly and does show the icon.

EDIT 2: Nevermind my last edit, everything now seems to work... for no reason. Calling Show with a MessageImage would have "loaded" the resource or something? That seems unlikely.

回答1:

I found the source: CLR Exception breaking in debug mode.

It looks like Catel sometimes throw some handled exceptions, and if you have Common Language Runtime checked in your exceptions settings (Visual Studio menu > Debug > Exception...), your debugger will break on these.

That's not so bad, just hit F5 (Continue) to get through.

What puzzled me was that this MissingManifestException broke again after hitting F5. The fact is that it seems to break for multiple resource icons, looking like it just keep on breaking like a real unhandled exception.

But no, so if you ever get a Catel exception, keep on hitting F5 or disable the CLR exceptions breaking.

Edit: as Geert suggest, you indeed don't need to disable every CLR exception breaking... Just disable the MissingManifestException.