Permanently turn off vb.namespace?-VBForums
Results 1 to 21 of 21

Thread: Permanently turn off vb.namespace?

  1. #1

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Permanently turn off vb.namespace?

    Is there a way to do so? Id just like to know that im coding in straight up vb.net without the hassle
    Last edited by |2eM!x; Jan 21st, 2006 at 05:52 PM.

  2. #2
    "The" RedHeadedLefty
    Join Date
    Aug 2005
    Location
    College Station, TX Preferred Nickname: Gig Current Mood: Just Peachy Turnons: String Manipulation
    Posts
    4,495

    Re: Permanently turn off vb.namespace?

    Do you have that dll listed as a reference in your project?? Its not in any of mine, and I cant remember if that was an option I turned off or not.... In order to use any of those, I have to type out the namespace... "Microsoft.VisualBasic...etc..." If its listed as a reference, then just remove the reference...

  3. #3
    "The" RedHeadedLefty
    Join Date
    Aug 2005
    Location
    College Station, TX Preferred Nickname: Gig Current Mood: Just Peachy Turnons: String Manipulation
    Posts
    4,495

    Re: Permanently turn off vb.namespace?

    You can go into your project properties (not solution properties), in the Common Properties folder, there should be an "Imports" node. Click on the node and you should see all of the Imports Statements for the project. Remove the Microsoft.VisualBasic imports statement and you should be good... (this is .NET 2003 directions)

  4. #4

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Permanently turn off vb.namespace?

    I know how to do it guys, but is it possible to auto remove it? Like how it auto adds option strict?

  5. #5
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    88,144

    Re: Permanently turn off vb.namespace?

    Why do you need to "turn it off"? Just don't use it. It's easy to know when you're using a Runtime function because they are all members of modules. That's how you can use them without qualification. If you use a function in VB.NET without qualifying it with a type or instance name and it doesn't turn blue then it's a Runtime function. This means that things like CInt, DirectCast, etc. are not Runtime functions. They turn blue because they are VB.NET keywords, i.e. part of the language itself. Things like Asc, Split, MsgBox are Runtime functions, easily identifiable because the function name doesn't require qualification but does not turn blue. Click the name and press F1 and the help topic will tell you which module they belong to, e.g. Microsoft.VisualBasic.Strings, Microsoft.VisualBasic.Interaction, etc.

    2007-2014

    Why is my data not saved to my database? | MSDN Data Walkthroughs
    MSDN "How Do I?" Videos: VB | C#
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts) | WP8 Turnstile Feather Transition with Pivot Control
    Beginner Tutorials: VB | C# | SQL

  6. #6
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,102

    Re: Permanently turn off vb.namespace?

    You can also use the Object Browser to search for a function to see what is the fully qualified class name for it.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Star Wars Gangsta Rap Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel Core 2 Extreme Ed., 2 WD Raptor 10K RPM 300 GB HDs, 2 GBs DDR2 667 MHz RAM, 2 Viewsonic 24" LCDs, Windows 7 SP-1/Windows 8.1, Office 2010, VS 2013

  7. #7
    ASP.NET Moderator mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,174

    Re: Permanently turn off vb.namespace?

    If you can create a custom project template without the Microsoft.VisualBasic namespace on it, then you could use that and achieve the 'automatically turned off' feature you want.

  8. #8
    Frenzied Member
    Join Date
    Jul 2002
    Location
    Dublin, Ireland
    Posts
    2,028

    Re: Permanently turn off vb.namespace?

    In your Program Files\Microsoft Visual Studio 2003\Common 7\VB7\VBProjects\ there is a file called "EmptyProject.vbproj"

    This is an xml mile that defines your standard new project and it includes the imports section:
    Code:
                <Imports>
                    <Import Namespace = "Microsoft.VisualBasic" />
                    <Import Namespace = "System" />
                </Imports>
    Backup this file then delete the <Import Namespace = "Microsoft.VisualBasic" /> bit and then any new VB projects will not include the Microsoft.VisualBasic namespace.

  9. #9

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Permanently turn off vb.namespace?

    Thanks man, great idea!!
    C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\VBExpress\ProjectTemplatesCache\1033\WindowsApplication.zip

    Is in the newest version

  10. #10
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    88,144

    Re: Permanently turn off vb.namespace?

    Note though that this is still just removing an Import. Every VB.NET app has an implicit reference to the Microsoft.VisualBasic.dll assembly. I guess removing the Import will mean that you would have to qualify all Runtime functions so you will not use any inadvertently. As I posted before though, it is quite simple to identify when you are using a Runtime function. What you do is up to you of course, and this will do no harm, but it seems to me to be a solution to a problem that doesn't exist.

    2007-2014

    Why is my data not saved to my database? | MSDN Data Walkthroughs
    MSDN "How Do I?" Videos: VB | C#
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts) | WP8 Turnstile Feather Transition with Pivot Control
    Beginner Tutorials: VB | C# | SQL

  11. #11
    ASP.NET Moderator mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,174

    Re: Permanently turn off vb.namespace?

    Quote Originally Posted by jmcilhinney
    Note though that this is still just removing an Import. Every VB.NET app has an implicit reference to the Microsoft.VisualBasic.dll assembly. I guess removing the Import will mean that you would have to qualify all Runtime functions so you will not use any inadvertently. As I posted before though, it is quite simple to identify when you are using a Runtime function. What you do is up to you of course, and this will do no harm, but it seems to me to be a solution to a problem that doesn't exist.

  12. #12
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    88,144

    Re: Permanently turn off vb.namespace?

    Don't explode just yet frog. I'm not suggesting that using Runtime functions is a good idea. I'm just saying that you don't need to do anything special to avoid using them. There's no reason to use one inadvertently because it is patently obvious when you have. If you use the method name unqualified and it doesn't turn blue then it's a member of a module. If it's not a member of your own module then it must be a Runtime function.

    2007-2014

    Why is my data not saved to my database? | MSDN Data Walkthroughs
    MSDN "How Do I?" Videos: VB | C#
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts) | WP8 Turnstile Feather Transition with Pivot Control
    Beginner Tutorials: VB | C# | SQL

  13. #13
    ASP.NET Moderator mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,174

    Re: Permanently turn off vb.namespace?

    I was exploding about the VisualBasic namespace being implicitly referenced in VB.NET apps.

    Does this apply to ASP.NET applications too? What would this say about the future of compatibility for ASP.NET v3.0 or v4.0 apps in the future when they remove it.

  14. #14
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    88,144

    Re: Permanently turn off vb.namespace?

    They certainly will not remove the Microsoft.VisualBasic namespace from the Framework. .NET 2.0 has added to it with the My objects. If they ever remove the modules that mimic the VB6 functions I'm sure they will deprecate them first, so you'll get at least one whole iteration of the Framework to eradicate them from your code. Given that each new version of ASP.NET will involve a new Framework, so older apps should still have their native version of the Framework installed, I don't see it being a problem.

    2007-2014

    Why is my data not saved to my database? | MSDN Data Walkthroughs
    MSDN "How Do I?" Videos: VB | C#
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts) | WP8 Turnstile Feather Transition with Pivot Control
    Beginner Tutorials: VB | C# | SQL

  15. #15
    Frenzied Member
    Join Date
    Jul 2002
    Location
    Dublin, Ireland
    Posts
    2,028

    Re: Permanently turn off vb.namespace?

    There is a bit of a potential misunderstanding arising from the fact that namespaces do not exactly map to dlls (in the .NET framework)

    So the Microsoft.VisualBasic namespace is split across a number of assemblies/dlls including System.dll and MicrosoftVisualBasic.dll

    You can remove the reference to the dll MicrosoftVisualBasic.dll which will remove the VB6 compatibility commands like ChDir, MsgBox etc.

    You cannot remove all of the Microsoft.VisualBasic namespace because this includes essential elements such as the VB.Net compiler.

  16. #16
    Noodly Appendage wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,672

    Re: Permanently turn off vb.namespace?

    The way I do it is to use C# instead

  17. #17
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    88,144

    Re: Permanently turn off vb.namespace?

    Quote Originally Posted by Merrion
    You can remove the reference to the dll MicrosoftVisualBasic.dll
    How exactly can you do that? There is no reference to that assembly listed in the Solution Explorer. I can add a reference to that assembly to a C# project if I want and see it listed, but I cannot remove one from a VB.NET project, or at least not the conventional way.

    2007-2014

    Why is my data not saved to my database? | MSDN Data Walkthroughs
    MSDN "How Do I?" Videos: VB | C#
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts) | WP8 Turnstile Feather Transition with Pivot Control
    Beginner Tutorials: VB | C# | SQL

  18. #18
    Noodly Appendage wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,672

    Re: Permanently turn off vb.namespace?

    Quote Originally Posted by jmcilhinney
    How exactly can you do that? There is no reference to that assembly listed in the Solution Explorer. I can add a reference to that assembly to a C# project if I want and see it listed, but I cannot remove one from a VB.NET project, or at least not the conventional way.
    You're not looking in the right place thats why. Its in the Project Properties dialog. Its under "imports" or something and there is a list of namespaces that are loaded regardless of whats in the solution explorer references list.
    I don't live here any more.

  19. #19
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    88,144

    Re: Permanently turn off vb.namespace?

    Quote Originally Posted by wossname
    You're not looking in the right place thats why. Its in the Project Properties dialog. Its under "imports" or something and there is a list of namespaces that are loaded regardless of whats in the solution explorer references list.
    Like I said before, importing a namespace is not the same as referencing an assembly. Importing a namespace just means that you can use members of that namespace in code without qualifying them. If you remove the project-wide import of the Microsoft.VisualBasic namespace you are not prevented from using Runtime functions. It just means that you would have to use, for example, Microsoft.VisualBasic.Interaction.MsgBox in code instead of just MsgBox. You would have to actually remove the reference to the assembly in with the Interaction module is defined. If you add a reference to the Microsoft.VisualBasic.dll assembly to a C# project then you can use MsgBox in C# code. Remove the reference and you can't again, but I'm saying that there is no reference to that assembly visible in a VB.NET project for you to remove, at least not through the IDE anyway.

    2007-2014

    Why is my data not saved to my database? | MSDN Data Walkthroughs
    MSDN "How Do I?" Videos: VB | C#
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts) | WP8 Turnstile Feather Transition with Pivot Control
    Beginner Tutorials: VB | C# | SQL

  20. #20
    Code Monkey wild_bill's Avatar
    Join Date
    Mar 2005
    Location
    Montana
    Posts
    2,888

    Re: Permanently turn off vb.namespace?

    Quote Originally Posted by Merrion
    In your Program Files\Microsoft Visual Studio 2003\Common 7\VB7\VBProjects\ there is a file called "EmptyProject.vbproj"

    This is an xml mile that defines your standard new project and it includes the imports section:
    Code:
                <Imports>
                    <Import Namespace = "Microsoft.VisualBasic" />
                    <Import Namespace = "System" />
                </Imports>
    Backup this file then delete the <Import Namespace = "Microsoft.VisualBasic" /> bit and then any new VB projects will not include the Microsoft.VisualBasic namespace.
    Doesn't work for me, do you suppose its because my empty project is located:
    C:\Program Files\Microsoft Visual Studio .NET 2003\Vb7\VBProjects

  21. #21

    Thread Starter
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Permanently turn off vb.namespace?

    Try my way instead bill

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.