Posts

Thought I'd give this a spin as I'd ultimately like to migrate a classic app away from the old System.Drawing namespace to the new unified world. Only snag is I can't seem to get it to compile in a simple project. I created a default unified C# app targeting .NET 4.5, added a reference to the assembly above and tried to compile this code:

using( var image = new Bitmap( 600, 400 ) ) { }

However I get the following error:

Error CS0012: The type 'System.Drawing.Size' is defined in an assembly that is not referenced. Consider adding a reference to assembly 'OpenTK, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' (CS0012)

Now System.Drawing.Size is defined in Xamarin.Mac which I'm referencing so I'm wondering if the Cycle6 assembly above is referencing a different version or something? I'm running Xamarin.Mac 2.4.1.6 (Indie). Any thoughts? Sample project attached.

Well sysdrawing-coregraphics does indeed depend on OpenTK but if I add a reference to the one included in the Xamarin.Mac framework folder it has System.Drawing.Color defined which is also defined in the sysdrawing-coregraphics version of System.Drawing.dll. This means anything referencing Color will not compile meaning I'm dead in the water currently unfortunately.

No worries! So /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/4.5/OpenTK.dll is actually an alias to /Library/Frameworks/Xamarin.Mac.framework/Versions/2.4.1.6/lib/reference/net_4_5/OpenTK.dll and that does contain a definition for some System.Drawing types (the other version in /.../Versions/2.4.1.6/lib/reference/net_4_5/full/ does not).

Chris, this is great. However, I'm getting compile errors on System.Drawing.Color references in my Xamarin.Mac application. I see that the color classes are only included in the IOS builds so are we supposed to be getting Color et al. from some other reference in XM?

Hi, I'm alittle bit beginner with compiling libraries, I'm using Xamarin on mac I tried to compile the library I got the following.
make: *** No rule to make target ../mono/mcs/class/System.Drawing/System.Drawing.Drawing2D/Blend.cs', needed by bin/ios/System.Drawing.dll'. Stop.

Thanks I built it, and I added it to the references,
Now I'm getting the following error.
(Path).../AvicennaPage.xaml.cs(4,4): Error CS7069: Reference to type System.ICloneable' claims it is defined assembly mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089', but it could not be found (CS7069) (Avicenna)

The error roughly says "I can't find System.Configuration". The "Mono for Android" part makes me think you are using Android? sysdrawing-coregraphics uses CoreGraphics, which is only available for macOS and iOS.

In any case, please start a new topic in the right forum. This is unrelated enough.

I'm trying to convert my project from Xamarin.Mac mobile to Xamarin.Mac 4.5.
Now I get errors with drawing. When building it says that System.Drawing.Color is referenced multiple times and if I look at the System.Drawing and the OpenTK assemblies, they both contain a Color class. Did anyone else run into this?

Chris, I downloaded your sysdrawing-coregraphics-Cycle6.zip, added a reference to System.Drawing.dll, and OpenTK.dll at /Library/Frameworks/Xamarin.Mac.framework/Versions/3.8.1.0/lib/reference/mobile/OpenTK.dll, but I am getting the following error:

I was able to build the sysdrawing-coregraphics from source and got some DLLs in bin folder. Then I created a simple Xamarin.iOS project and referenced the System.Drawing.dll in bin/iOS folder. During compilation I am getting:

I don't understand why does it look for Xamarin.Mac when targeting Xamarin.iOS. I am not using the System.Drawing library directly but rather using 3rd party library which internally uses System.Drawing.

I would be glad if you could give me any directions how to solve my problem.