Jump to content
  • Advertisement
Sign in to follow this  
Thevenin

[.net] Customizing assembly error message.

This topic is 4291 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!