Resolve conflict between System.Drawing and System.Drawing.Common

1.9k Views Asked by At

I am trying to add SpreadSheetLight to a new Dnn v9.10.2 project running on Windows Server 2019, but I get a runtime error saying

CS0433: The type 'Image' exists in both 'System.Drawing.Common, Version=4.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' and 'System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

when I copy the dlls into the bin folder. I have a file that was using System.Drawing, but it was using the full namespace in it's references. I tried updating those to System.Drawing.Common, but it instead throws the error

CS0234: The type or namespace name 'Common' does not exist in the namespace 'System.Drawing' (are you missing an assembly reference?)

Commenting out the lines of code using System.Drawing resolved the runtime error, but ultimately when trying a simple test of just opening and closing a blank workbook it throws the exception

System.PlatformNotSupportedException: System.Drawing is not supported on this platform.

I haven't been able to find much on how to fix this so any help would be appreciated.

1

There are 1 best solutions below

0
On

Upon first glance it seems that this library is a .NET 3.5 library and DNN Platform 9.10.2 is .NET Framework 4.7.2 you are most likely hitting a compatibility issue with changes in .NET 4.7.

It looks like the source for SpereadSheetLight is available, you could try to recompile it for .NET 4.7.2 and see if you can clear the issue.