2

A console application that works well using the .NET 2.0 runtime in Windows throws an System.InvalidProgramException when executed in the Mono runtime.

The application uses a legacy 3rd party component - Dundas Gauge for .NET - to generate images.

The exception details follow:

System.InvalidProgramException: Invalid IL code in Dundas.Gauges.WebControl.GaugeCore:.ctor (Dundas.Gauges.WebControl.GaugeContainer): IL_0013: stfld     0x0400019c
at Dundas.Gauges.WebControl.GaugeContainer..ctor () [0x00000] in <filename unknown>:0
at GSR.Dashboard.Gauges.GrowthGaugeFactory.CreateGaugeContainer () [0x00000] in <filename unknown>:0
at GSR.Dashboard.GaugeCompiler.Program.Main (System.String[] Args) [0x00000] in <filename unknown>:0

Clearly, we have a problem in the 3rd-party's code - a constructor - of which I have no control over.

Additional details:

  • This is a .NET 3.5 app compiled using Visual Studio 2008.

  • I have attempted to run this using multiple versions of Mono on Windows (Mono 5.2.0.224 x64, Mono 3.12.1 x32) and FreeBSD (Mono 4.8.1 amd64).

  • The same exception occurs in all of these runtimes.

  • The 3rd-party component is a 32-bit build.

  • The 3rd-party component appears to be obfuscated when inspected using ILDasm.

What can be done to troubleshoot this issue and get the program to run in Mono? I find it kind of crazy that such a popular component contains invalid IL. How could it possibly work on Microsoft's .NET runtime but not the Mono runtime?

1 Answers1

0

Mono is just an open source MSIL runtime, based on Microsoft published standards. Thus, if the obfuscated assembly (like the one you met) uses some .NET Framework specific tricks (which is quite common and usually are why obfuscators are expensive and effective), Mono would not be able to execute it, as that goes against the design of Mono (standard compliance would be more important than compatibility with .NET Framework in some cases).

So in your case, you can only go back to .NET Framework and Windows. That's also something the licensing of that third party assembly would require if you read end user license agreement.

BTW, Dundas was not only popular but later purchased by Microsoft and became a .NET Framework built-in component. Mono guys attempted to clone it, but they were too busy on other things, so that subproject did not finish,

https://github.com/mono/mono/tree/master/mcs/class/System.Windows.Forms.DataVisualization/System.Windows.Forms.DataVisualization.Charting

Lex Li
  • 60,503
  • 9
  • 116
  • 147
  • The original Dundas Gauge license that I have does not specify the runtime nor the operating system on which it must be run. Note that this component was purchased before the Microsoft acquisition of Dundas IP. – Cory Walker Oct 23 '17 at 11:58