none
'FontStyle' is ambiguous in the namespace 'System.Drawing'.

    Question

  • in VB.Net 2017 I am using code from a previous project to create a new project and in the old one it worked fine. I cannot understand what am I missing out on that the FontStyle and Font are both underscored as being an error and the error message that comes up is:

    'FontStyle' is ambiguous in the namespace 'System.Drawing',  and 'Font' is ambiguous in the namespace 'System.Drawing'.

    I added a reference to System.Drawing and it did not solve the issue.


    Thursday, December 07, 2017 5:47 PM

All replies

  • Hi

    Did you just update the Visual Studio verion today? If so, then it may be an issue already reported (and supposedly in the next update). You will probably find that the application/project builds and runs just fine in the meantime.

    One possible temporary work around is to UNCHECK the option:

    Options->Projects and Solutions->Allow Parallel Project Iniutialization


    Regards Les, Livingston, Scotland

    Thursday, December 07, 2017 6:04 PM
  • I opened Options->Projects and Solutions and I did not find 'Allow Parallel Project Iniutialization' in the list of options.
    Thursday, December 07, 2017 6:48 PM
  • I opened Options->Projects and Solutions and I did not find 'Allow Parallel Project Iniutialization' in the list of options.

    Hi

    Well, don't know what to say. Here is an image on my setup.


    Regards Les, Livingston, Scotland

    Thursday, December 07, 2017 6:54 PM
  • this line is missing in my VS
    Thursday, December 07, 2017 9:47 PM
  • I have enterprise edition on Windows 7 and don't have that option either.

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Thursday, December 07, 2017 10:06 PM
    Moderator
  • Hi

    I am using Win 10 and VS Community - there must be some differences........

    I had the exact same issues as OP, and found that 'fix' via the Help->Send Feedback->Report a Problem.


    Regards Les, Livingston, Scotland


    • Edited by leshay Thursday, December 07, 2017 11:19 PM
    Thursday, December 07, 2017 11:17 PM
  • Well I'm using 15.4.1, no plans to update at the present time. Currently working on a multi billion dollar project with a team expanding world-wide so no chance to updating any time soon.

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Thursday, December 07, 2017 11:32 PM
    Moderator
  • Hi

    Well, I am working on a a multi-billion project too, but we are going Galaxy wide - so there!  :)  :)


    Regards Les, Livingston, Scotland

    Thursday, December 07, 2017 11:46 PM
  •  Have you added any references to any 3rd party controls or classes in the application?  What namespaces have you Imported at the top of your code?

     I have seen this same error when i have added references to 3rd party controls or classes and they contain classes,  structures, or enumerations in them that have the same name as one of the .Net classes,  structures,  or enumerations.  You can usually fix it by simply changing the Import statements and the code that accesses the Imported namespaces.

     If you look at the meaning of the word "ambiguous" which means, "open to more than one interpretation; having a double meaning.",  it gives an idea of the problem.  The error is indicating that there are two or more FontStyle objects and Font objects in the imported namespaces and VS does not know which one you are referring to in your code.


    If you say it can`t be done then i`ll try it

    • Edited by IronRazerz Friday, December 08, 2017 1:11 AM
    Friday, December 08, 2017 12:00 AM
  • @Iron, very good point.

    If we go with that than perhaps a Import alias might be of assistance.

    Imports sysDraw = System.Drawing
    Public Class Form1
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Dim fs As New sysDraw.FontStyle
        End Sub
    End Class
    

    If in the following image you used this and sysDraw is not grey then what Iron mention should fix your problem, if it's still grey then it's not that. Grey as in the Dim statement.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Friday, December 08, 2017 1:58 AM
    Moderator
  • Hi Moshe,

    >>'FontStyle' is ambiguous in the namespace 'System.Drawing',  and 'Font' is ambiguous in the namespace 'System.Drawing'.

    Refer to this document that says:

    There can be a few causes for this error. In VB, you should be aware that more names then you're used to from C# are available without class specification. Also, case does not matter in VB, which can further liken the chances on collisions.

    Even in the event that you don't find the actual conflicting issue, you can resolve this in the same way you would in C#: rename it in the Imports statement(just as Karen said):

    Imports IM = yourAssembly.Imyinterface

    Then change the code such that uses of Imyinterface are replace with IM.

    NOTE: If the error does not point to a particular line, the conflict may be out of your hand. Normally, a full Clean Solution and Rebuild helps a lot, but occasionally a misbehaving file (i.e., another error) causes this error to popup first without clear source. Try to rollback recent changes to the place where it did work.

    Also refer to: Ambiguous in the namespace, maybe there are some 3rd libraries to cause this issue.

    Regards,

    Stanly


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, December 08, 2017 6:28 AM
  • Please add a line at the top in your class.
    Imports System.Drawing

    Ashidacchi

    Friday, December 08, 2017 7:04 AM
  • Yea something like this for the whole of America


    Success
    Cor

    Friday, December 08, 2017 8:49 AM
  • @Cor and @Les, can you please stay on topic from here on out, thanks.

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites


    Friday, December 08, 2017 10:33 AM
    Moderator
  • @Cor and @Les, can you please stay on topic from here on out, thanks.

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites


    Karen,

    It was just an reaction on this: Currently working on a multi billion dollar project with a team expanding world-wide so no chance to updating any time soon.

    OT? Les and I did think so. 

    :-)

    Although more on topic, I've version 15.4.5 (updated this week) and I don't also see that line.

    :-)

    Les and I am both from a part of Europe where talking about money is not done.


    Success
    Cor



    Friday, December 08, 2017 11:06 AM
  • Moshe,

    I did not want to come in this thread, but in my experience gives System drawing endless warnings about ambiguous if there is a reference to System.Media.

    The solution is then to fully qualify your identifiers. 

     


    Success
    Cor

    Friday, December 08, 2017 11:20 AM