Sign in to follow this  

[.net] Customizing assembly error message.

This topic is 4074 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

When a user runs my application requiring DirectX9.0c, but doesn't have DirectX 9.0c, the error message thrown is a rather cryptic one. Is it possible to throw a try() catch() over an assembly reference? Or edit the error message displayed?

Share this post


Link to post
Share on other sites
You might be able to catch this exception by hooking the global application exception handler.

Sorry, I don't have my app in front of me to give you code that I am sure works, but I think this snippet from the internet does the same thing.

[STAThread] static void Main() {
Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
Application.Run(new Form1());
}

private void button1_Click(object sender, System.EventArgs e) {
throw new Exception("Whoops");
}

private static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e) {
MessageBox.Show(e.Exception.Message);
}



Though, you would likely be better off trying to load the dll in question manually, and then showing a message and exiting if it is not there. You can always unload it and continue with your processing as normal if everything checks out.

Share this post


Link to post
Share on other sites

This topic is 4074 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this