Cory Walker
Cory Walker

Reputation: 21

System.InvalidProgramException: Invalid IL code when moving 3rd party .NET component (Dundas Gauge for .NET)

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:

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?

Upvotes: 2

Views: 1262

Answers (1)

Lex Li
Lex Li

Reputation: 63289

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

Upvotes: 0

Related Questions