[Mono-dev] ToolStripManager.RevertMerge

Chad Dettmering chad.dettmering at gmail.com
Tue Feb 24 18:02:59 UTC 2015

Hello Mono Devs! This is my first time posting to this mailing list so
forgive me if I step on any toes.

I was running an application called Chummer5 link:
https://code.google.com/p/chummer5/ with Mono. The application kept
crashing on the method Windows.Systems.Forms.ToolStripManager.RevertMerge.

Being the curious software dev that I am, I decided to download the Mono
and Chummer5 source code to figure out the problem. I might add the
application runs fine on a Windows machine using the official .NET runtime.

After poking around I came to this line of code in Chummer5

// Merge the ToolStrips.
ToolStripManager.Merge(toolStrip, "toolStrip");

which leads to an ArgumentNullException in Mono. The argument is not null
of course but this method calls the base RevertMerge method which takes
(ToolStrip, ToolStrip) as it's parameters, and uses the FindToolStrip
method to find the ToolStrip based on the name. Now this implementation
will always cause the RevertMerge parameter to be null if a Merge has not
been called with the same name.

Digging into the Mono source I came to this line of code inside the
RevertMerge method implementation

if (sourceToolStrip == null)
    throw new ArgumentNullException ("sourceToolStrip");

So Mono is throwing an Exception explicitly in this case and will throw an
Exception everytime RevertMerge is called before Merge using the same

I thought this was odd so I went to the msdn documentation here:

According to the documentation this method shouldn't throw any Exceptions,
instead it should return false if the RevertMerge failed. Also looking at
the example on the page it shows this as a valid way to use the method

// Undo previous merge, if any.
ToolStripManager.RevertMerge(cmsBase, cmsItemsToMerge);

which implies that sending null is valid.

Given all of this information is this a "bug" in Mono? Someone wrote that
Exception explicitly so the code is working as intended but it breaks
compatibility on the application I'm running.

Any more info on this topic would be great! Nice to meet everyone! :)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-devel-list/attachments/20150224/71a76fb3/attachment.html>

More information about the Mono-devel-list mailing list