I get (depending on the way I try to use "Test") either "'Name' is not a member of '<Default>'." or "Type 'Name.Test' is not defined." in my error list. I've found two ways to make it work, but neither are reasonable to expect of a user. One is to remove the "Root Namespace" from the project properties. The other is to include that namespace between "Global" and "Name".
I have made a custom tool that uses CodeDom to generate code for both C# and VB.NET. This is the reason why neither of the two fixes above are feasible: I can't expect my users to have an empty root namespace, and I'd hate to have to do VB-specific tricks in my code generation (kind of defeats the purpose of using a language-neutral tool, doesn't it?) such as picking out the "Root Namespace" (not that I'd know how off the top of my head) and including it in my code generation.
I don't want to leave out the global modifier either, because it protects the tool from users picking bad names for the generated output. Does anybody have a suggestion for how I should deal with this?
Namespace Transaction, Document Class Signer Public Sub New()
[Code].....
I basically want to be able to instantiate the Signer class from either Namespace. The reason is that I mistakenly set it up in the Transaction class and need to migrate it over to the Document class without breaking existing legacy code. I'd prefer to not have the same Signer class duplicated in both Namespaces if possible.
I am building an ASP.Net application and want to use Namespaces for the first time. Within an App_Code folder, I have created three classes called RewriteContext, RewriteModule, and RewriteHandler.
I am using XML Literals and Linq to XML to read/write data to an external system.[code]The client now wants to put the url in a parameter table so the table can change to point to a test server or a real server. I assume that I cannot put a variable in my Imports statement.So how to I access the correct URL from a variable?url...
I had weird compile errors. When I opened a project of mine today, suddenly I received over 100 errors. It gives even error for try catch, foreach and all those functions under system and Microsoft.VisualBasic namespace. I have also class libraries and although references are looking added, main project doesnt recognize references as well. I tried clean solution, rebuilt solution, cleared my aspnet tmp folder, re-added references but no help. what could be the problem? anyone experienced such problem. my VS2010 isnt spoiled because any other project works fine,even with same class libraries.
I am converting projects from C# to Visual Basic, and the namespaces in VB.NET behave in a weird way. There is some kind of hidden default namespace, and it's annoying. I want it to behave identical to C#, which works as expected - things go into the namespaces you create for them.
I've been getting around it usually with say
using MyClassLibrary;in C#, and in VB Imports MyClassLibrary Imports MyClassLibrary.MyClassLibrary
but it would be nice to have the functionality the same, and also logical.The other bigger problem is, I have a .tt file, and the C# project generates the code in a different namespace to the VB one.
Is there some solution to make both behave identically with regards to namespaces?
I am working with VB.Net and am kinda new. I was wondering, if my asp.net project has a lot of shared functions, can I put them all into one Namespace? Do I have to put them into a class?
I have a bunch of methods that do some formatting on data that is contained in a structure. I'm passing the structure to the methods as a parameter. The problem is that the same structure is returned from 2 different webservices depending on the program flow (I did not create these services and cannot change them). So at one point I would be passing WebService1.Service.MyStruct and later I might have to pass WebService2.Service2.MyStruct.
Is there a way I can write only one method to handle both type of parameter? The struct is the same and only differs by namespace. I can overload the methods but I was wondering if there was another way to do this with reflection or something along those lines.
VB has a feature that C# does not, imported namespaces at a project level (My Project>References>Imported Namespaces). When new people check projects out of source control none of our custom imports are included. Where is this VB specific Imported Namespaces stored?
When I add an 3party Library (Gibraltar.Agent) to a VB.NET project I get namespaces which interfere with my current code. For example the namespace Gibraltar.Agent.IS makes the following code invalid:
Is it possible to have a single class reside within two name-spaces and how can I do this?
To clarify: We have a class library (let say root namespace is classLib1), which has grown over time (more classes) and I want to logically group classes into different namespaces. However some of the older classes need to be grouped into these new namespaces (e.g classLib1.section1) and doing so will break legacy code in other assemblys that use this class library. So I want to be able to refer to a class using both name-spaces until we can phase the old ones out.
I can't find any information on this, which suggests there is a reason that people would not want to do this!?!
If I create a new class library project in VB.NET, I can create subfolders (a la C#), add WinForm objects to these subfolders, and then specify a namespace:
Namespace Sub1.Sub2 Public Class SomeForm Public Sub New() InitializeComponent()
[code]...
This resolves as ProjectRootNamespace.Sub1.Sub2.SomeForm, which is good.However, if I create a new WinForms project in VB.NET, and attempt the same thing, I get this error in the designer:The class SomeForm can be designed, but is not the first class in the file. Visual Studio requires that designers use the first class in the file. Move the class code so that it is the first class in the file and try loading the designer again.Is there a way to have forms in sub-namespaces of a VB.NET WinForms app instead of in the root namespace?
i hav a problem in building a solution in vs 2008.I'm opening vb.net project in VSS repository.When i tried to build the application its giving lot of compile error.After examining the code i've found that the namespaces are not imported in *.vb file , hence the types used in the file are not accessible .I know that we can import namespaces at application level
Just wondering what the recommended practice is for importing namespaces. Are you always better importing the namespace like the fisrt snippet of code, or are you better to type the full namespace inline with your code.
I like both methods; the first is tidier and takes less code, the second can identify exactly where your accessing some logic from which can provide some clarity when looking over the code. Just wondering if there are pros/cons for either or if this is just a personal preference, currently I use a combination but would like to keep consistant.
I am generating this XML using the serializer in VB.net as shown below
Dim string_writer As New StringWriter() Dim serializer As New XmlSerializer(GetType(MyClass)) serializer.Serialize(string_writer, addr) txttest.Text = string_writer.ToString()
though it is returning XML, I see xmlns="http://tempuri.org/ in all the elements, is there anyway I hide this one.
I am use to VB.NET. The game source code I am learning from is written in C#. I find it annoying that I have to add using System.Diagnostics to the source code in order to type Debug.WriteLine.... I checked under project properties, but I cannot find the References tab that allows me to add namespaces to Imported Namespaces. Where do I find this in C#?
i read that WindowsFormsApplicationBase, is in the Microsoft.VisualBasic.ApplicationServices namespace
Do I have to really add the full-blown Microsoft.VisualBasic.ApplicationServices just to get WindowsFormsApplicationBase in c# ? What's the consequence on the size and performance of my c# app if I do so ?
I have created an SSISpackage in my asp.net project.To call the ssis package, i have written the following code.
dim app as new Application() dim package as Package=app.LoadPackage("C:ProjectsMyPackage.dtsx") dim result as DTSExeResult=package.Execute() Response.Write(result.Tostring())
but it shows some errors.i think some namespaces are missing.What all namespaces have to be imported?
I've got an assembly (loaded as ReflectionOnly) and I want to find all the namespaces in this assembly so I can convert them into "using" ("Imports" in VB) statements for an auto-generated source code file template.
Ideally I'd like to restrict myself to top-level namespaces only, so instead of:
using System; using System.Collections; using System.Collections.Generic;
you'd only get:
using System;
I noticed there is a Namespace property on the System.Type class, but is there a better way to collect Namespaces inside an assembly that doesn't involve iterating over all types and culling duplicate namespace strings?
I've created a project which references some other projects in my solution. I've added the references properly to my project (which I've done a thousand times before), and used them in an Imports statement. I can successfully create references to the objects contained in the referenced namespace at design-time but whenever I attempt to build or run the project, I get build errors saying that the referenced projects do not exist. Their Imports statements change to the broken green underline and the only way to remedy the problem is to re-add the references in my project's properties.
I know that the referenced projects are valid, will compile etc... because they work fine for other projects in the solution. Also, I can go to the definition of their objects as long as I don't build/run.
I would like to import System.Data.OleDb to my list of references, but it won't let me, I can't find it on the list but it's obviously there cause I can type olede.oledbparameter.
My list shows System.Data System.Data.DataSetExtensions System.Data.Entity System.Data.Linq System.Data.Services.Client System.Data.SqlXml
I can't find System.Data.Oledb. Now, I did a "hack" job and got it added, but I couldn't figure out how to do it with the GUI. I edited the .proj file with notepad and added it manually.
How can I add it with the GUI? Steps: Clicked on Project Clicked on Add Reference... Clicked on .Net, Com, Projects Couldn't find it on either of those lists.
After being spoiled for years with C# automatically setting the default namespace for new classes to match my folder structure, I'm wondering if there is any way to get VB.NET to do the same?
I've been aware for awhile that it doesn't do this automatically but I've never really researched alternatives. keep my VB.NET class namespaces in sync with my project folder structures?