Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xamarin.iOS is unable to find the 'Bitmap' type in the NuGet package System.Drawing.Common #31851

Closed
kzryzstof opened this issue Aug 20, 2018 · 6 comments

Comments

@kzryzstof
Copy link

commented Aug 20, 2018

With Visual Studio 15.8.1 on Windows, I have created an iOS application using Xamarin.iOS targeting iOS 11.4. To build the application, I have set up a build agent on macOS that is running the latest Xamarin 11.14.0.11.

Then I have created a new .netstandard 2.0 library that references the NuGet package System.Drawing.Common. I have added the following class in it:

using System.Drawing;

namespace library
{
    public class SomeClass
    {
        private readonly Bitmap m_bitmap;

        public SomeClass(Bitmap bitmap)
        {
            m_bitmap = bitmap;
        }
    }
}

The library is then referenced by the iOS project and everything is building.

Then, in the ViewController of the iOS project, I have added the following code:

public partial class ViewController : UIViewController
{
    private SomeClass m_someClass;

    public ViewController (IntPtr handle) : base (handle)
    {
        m_someClass = new SomeClass(new System.Drawing.Bitmap());
    }

    // ...
}

I have finally added the reference to the NuGet package System.Drawing.Common to the iOS project.

Now, it is failing to build and I get the following error:

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

error CS7069: Reference to type 'Bitmap' claims it is defined in 'System.Drawing.Common', but it could not be found

Question

I followed the answer to that issue. Everything is up-to-date (Visual Studio & Xamarin on macOS). I tried to manually copy System.Drawing.Common from the .netstandard20 of the package to the output as well as adding the DLL directly to the project as a reference. I never got anything working.

Is this a bug?

@karelz

This comment has been minimized.

Copy link
Member

commented Aug 20, 2018

@marek-safar @weshaggard @ericstj - maybe some packaging problem?

@kzryzstof

This comment has been minimized.

Copy link
Author

commented Aug 21, 2018

PS
I had the same issue with an application using Xamarin.Android but I got fixed after updating Visual Studio to 15.8.1 and Xamarin 11.14.0.11 (as recommended in the mentioned issue).

Xamarin.iOS does not seem to be fixed.

@ericstj

This comment has been minimized.

Copy link
Member

commented Aug 21, 2018

This is an issue with the Xamarin SDK, as I mentioned here Xamarin requested that we not apply a library from this package but instead let their SDK provide the library. I'm not sure where the best place is to file Xamarin issues. It looks like the previous mono issue does mention some hints:

What version are you using? I tried with
Xamarin.iOS
Version: 11.11.0.280 (Visual Studio Community)
Hash: e85a7be8
Branch: master
Build date: 2018-05-03 11:35:00-0400
and I have /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.iOS/Facades/System.Drawing.Common.dll installed

You might double check that you have that and also double check that you're referencing the assembly which actually defines Bitmap (System.Drawing). It's possible that the Xamarin SDK may not auto-reference that.

Typically to debug this sort of issue you can examine build logs and see what references are passed to the compiler.

@karelz

This comment has been minimized.

Copy link
Member

commented Aug 21, 2018

@marek-safar @akoeplinger can you please help route the issue to the right bug database?
Closing here in CoreFX.

@karelz karelz closed this Aug 21, 2018

@marek-safar

This comment has been minimized.

Copy link
Contributor

commented Aug 27, 2018

Please fill an issue on https://github.com/mono/mono as Xamarin does not yet expose all types possible in this package.

@kzryzstof

This comment has been minimized.

Copy link
Author

commented Aug 27, 2018

Issue 10310 filled on mono's github. Thank you for your help!

@karelz karelz added this to the 3.0 milestone Nov 15, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.