Reputation: 13434
I am working with C# winforms Application i am dll in my project when call that function from that dll i get unwanted MessageBox from that .Is it possible to block that MessageBox?
Upvotes: 2
Views: 2524
Reputation: 1974
If your dll is managed code you can decompile it and remove MessageBox call like 0xA3 suggested. If your dll is native you can use API hooking. Example of WinAPI hooking you can find here. It's in C++, but can be easily translated to C#.
Upvotes: 0
Reputation: 2956
You can study that dll with hex-editor, debugger or some resource viewer to find out how dialog box is created and then subscribe to that Windows event (Like OnCreate - surf WinAPI docs for info on Windows creation functions). In your event handler try to suppress dialog box and see if dll function is happy about the fact that dialog wasn't shown
Upvotes: 0
Reputation: 176169
There is no nice option to get rid of the message box if this is a third-party dll.
However, as C# is compiled to IL you can view the byte code and remove the call to MessageBox.Show
or replace it with a call to Trace.WriteLine
. You can do this e.g. using the ildasm.exe
/ilasm.exe
tools coming with the SDK.
Upvotes: 1
Reputation: 136613
If push comes to shove, you can fire up a thread that kills off any open windows by title using WinAPI or libraries.
I'd resort to less harsh mechanisms like changing the dll first or putting a change req to the right people.
Upvotes: 2