Search code examples
c#overridingmessageboxcitrix

Override MessageBox.Show


I am seeking to override the System.Windows.Forms.MessageBox.Show() method to save modifying a monolithic codebase to use a new messagebox function.

I am using the Citrix Mobility SDK to instrument a legacy C# Windows application to facilitate more intuitive functionality on a mobile device such as iPad or Nexus tablet.

I wish to display a local messagebox on the device, and to do so, I need to replace all calls to MessageBox.Show in the application with a CustomMessageBox.Show function. The codebase is enormous, and I would rather not modify every file to use CustomMessageBox.Show as it would be a large and dangerous job, as well as resulting in tight coupling between the SDK and the application.

Thus, is there a way to override MessageBox.Show so that I can reimplement the function for use with this third party SDK, as it would be the most elegant option?


Solution

  • No, you cannot override MessageBox.Show because it is a static method.