Import of type 'Color' from assembly or module 'System.Drawing.Primitives.dll' failed

Simon 466 Reputation points
2024-02-29T17:21:07.35+00:00

I created a project with ASP.NET Visual Studio 2022 .NET Framework Version 4.8.1 I imported all .dll files from Framework version 4.8.1. Anything that has code referring to 'Color' generates the following error message. Error BC31091 Import of type 'Color' from assembly or module 'System.Drawing.Primitives.dll' failed Which direction should I take to resolve this issue?

Developer technologies | ASP.NET | Other
{count} votes

Accepted answer
  1. Lan Huang-MSFT 30,191 Reputation points Microsoft External Staff
    2024-03-01T08:46:38.6533333+00:00

    Hi @Simon,

    Import of type 'Color' from assembly or module 'System.Drawing.Primitives.dll' failed

    I guess the reason for your error is that you are using an incorrect dll.Maybe you could try using System.Drawing.dll instead.

    Provides basic drawing primitive structures, that exposes the corresponding System.Drawing.dll types in .NET Core.

    https://learn.microsoft.com/en-us/dotnet/api/system.drawing.color?view=netframework-4.8.1

    User's image

    User's image

    I want to use the upgrade tool from Microsoft to convert the desktop version into a web application.

    It is not recommended to use tools for conversion. Web applications and WinForms are fundamentally different and should be designed differently.

    Best regards,
    Lan Huang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.