How do I prevent Visual Studio from automatically adding unneeded includes in VB modules

David McDivitt 221 Reputation points
2023-01-17T20:10:10.8+00:00

I often copy modules from one project to another and often times Visual Studio will add several includes at the top of the class. When surveying through source code I find unnecessary includes have been added. If an include is needed I want compilation to fail rather than have it added automatically. How do I turn this off?

Developer technologies | VB
Developer technologies | Visual Studio | Other
Developer technologies | Visual Studio | Other
A family of Microsoft suites of integrated development tools for building applications for Windows, the web, mobile devices and many other platforms. Miscellaneous topics that do not fit into specific categories.
0 comments No comments
{count} vote

Answer accepted by question author
  1. Jiachen Li-MSFT 34,231 Reputation points Microsoft External Staff
    2023-01-18T01:57:49.3133333+00:00

    Hi @David McDivitt , You can uncheck Add missing imports on paste.

    It is available in Options→Text Editor→ Visual Basic→Advanced→ Import Directives.

    Best Regards.
    Jiachen Li
    ----------
    If the answer is helpful, please click "Accept Answer" and upvote it.
    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.

    2 people found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Dirk Seynaeve 0 Reputation points
    2025-03-04T11:42:37.5133333+00:00

    Even with the option (Options→Text Editor→ Visual Basic→Advanced→ Import Directives.) switched off, and after restarting Visual Studio, it continues to adding Imports to my code.

    My version is Microsoft Visual Studio Community 2022 (64-bit) - Version 17.13.2


Your answer

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