-
Jan 21st, 2006, 06:37 PM
#1
Thread Starter
Admodistrator
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 06:52 PM.
-
Jan 21st, 2006, 06:57 PM
#2
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...
-
Jan 21st, 2006, 07:31 PM
#3
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)
-
Jan 21st, 2006, 07:42 PM
#4
Thread Starter
Admodistrator
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?
-
Jan 22nd, 2006, 01:21 AM
#5
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.
-
Jan 22nd, 2006, 02:24 AM
#6
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!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
-
Jan 22nd, 2006, 03:57 AM
#7
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.
-
Jan 22nd, 2006, 08:15 AM
#8
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.
-
Jan 22nd, 2006, 02:25 PM
#9
Thread Starter
Admodistrator
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
-
Jan 22nd, 2006, 07:12 PM
#10
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.
-
Jan 23rd, 2006, 05:16 AM
#11
Re: Permanently turn off vb.namespace?
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.
-
Jan 23rd, 2006, 05:21 AM
#12
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.
-
Jan 23rd, 2006, 05:27 AM
#13
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.
-
Jan 23rd, 2006, 05:32 AM
#14
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.
-
Jan 23rd, 2006, 06:14 AM
#15
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.
-
Jan 23rd, 2006, 07:23 AM
#16
Re: Permanently turn off vb.namespace?
The way I do it is to use C# instead
-
Jan 23rd, 2006, 04:52 PM
#17
Re: Permanently turn off vb.namespace?
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.
-
Jan 24th, 2006, 07:04 AM
#18
Re: Permanently turn off vb.namespace?
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.
-
Jan 24th, 2006, 05:30 PM
#19
Re: Permanently turn off vb.namespace?
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.
-
Jan 24th, 2006, 05:57 PM
#20
Re: Permanently turn off vb.namespace?
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
-
Jan 24th, 2006, 06:43 PM
#21
Thread Starter
Admodistrator
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|