.NET Namespace Regarding Explict (named) Versus Implicit (global Or Root) Namespaces?
Sep 27, 2010
I have a solution that contains many projects all using the same root namespace. No code files explicitly name a namespace. So lets say the root namespace is ExampleRootNamespace.Now a problem comes into play when I want to add an explicitly named namespace to one of the code files I am working on. I want to be able to isolate this code from the rest of the assembly to be able to run FxCop against it. So I add something like Namespace Interfaces.CSV to the code file.
This causes any code that references this assembly to need to say Imports ExampleRootNamespace.Interfaces.CSV. So far so good. I can even run FxCop against the assembly. The problem now is that in other assemblies I cannot say any longer things like:
Public class frmInputBoolean Inherits
ExampleRootNameSpace.frmFormTemplate
Visual Studio is now asking me to rename the namespace to:
Public class frmInputBoolean Inherits
Global.ExampleRootNameSpace.frmFormTemplate
There are hundreds of errors related to this. So my questions are:
1) Why would basically naming a namespace under the root for the first time cause issues with the program?
2) Are there any workarounds to this issue without renaming?
I also want to add that with regards to ExampleRootNamespace.Interfaces.CSV I am not referencing this anywhere in the codebase. I'm currently just referencing it from a unit test project. So I don't see why adding this namespace causes an issue.
View 2 Replies
ADVERTISEMENT
Sep 27, 2010
I am working on a solution that does not name namespaces in code files. Instead it uses the root name space of the project (which is the same across all assemblies). Basically there is only one implicit namespace.
Well, I am trying to isolate some code so that I can run FxCop against it. I explicated named the code file with a namespace to do this. This works for FxCop, but it bricks the entire solution.Visual Studio is now asking me to prefix all uses of the implicit namespace with Global. So instead of:
[Code]...
View 1 Replies
Jan 6, 2010
I'm trying to set up a .NET 3.5 web service project in Visual Studio. My goal is to include a namespace in this web service that I can expose to web applications that references this web service.I have added the namespace "MyWebservices", but I am not able to find it after referencing the web service.[code]I have also attempted to modify the "Root Namespace" property of the web service project, but I can't get that to work for me either.
View 3 Replies
Feb 28, 2010
How to change root namespace of my program
View 6 Replies
Aug 21, 2009
[code]How do I do this in VB, while having a root namespace in the application, is this possible?
View 4 Replies
Sep 23, 2011
For those of you interestested in mathematics you can find a root of a number in two different ways. Lets say you want to find the 5th root of 27.
[Code]...
View 2 Replies
Aug 22, 2009
In VB.Net you can do something like the following without any issues... just ignore the fact that this is a pretty useless class :-)
Imports System
Public Class Class1
Public Shared Function ArrayToList(ByVal _array() As String) As Collections.Generic.List(Of String)
[code]....
However if you do the same thing in C#...
using System;
public class Class1
{
public static Collections.Generic.List ArrayToList(string[] _array)
[code]....
You will get an error on the line with the return on "Collections.Generic.List" saying "The type or namespace name 'Collections' could not be found (are you missing a using directive or an assembly reference?)"I know that you have to actually have a using directive to System.Collections.Generic to use List but I don't know why. I also don't understand why I don't get the same error in the function declaration, but only in the return statement.
Edit: Just to note, the question is really about the referencing of a sub-namespace such as in the example being able to reference Collections within System.
View 3 Replies
Mar 29, 2009
[URL] The jist of the problem is in fact that in the weka.classifiers.trees namespace you have the following members:
namespace weka.classifiers.trees.j48
and
public class J48 : weka.classifiers.Classifier (Member of weka.classifiers.trees)
Lamentably VB .NET in VS 2008 does not seem to be smart enough to distinguish betweem the two (which is odd, because there is no such problem in VS 2003, or in C# in VS 2008) because of it's lack of case sensitivity. Or possibly because of the fact that ikvmc emits an assembly compiled for the 1.1 run time... I'm not sure. I'm also not quite sure how you would resolve this particular issue and given the time sensitivity of this project I do not have the time to learn C# or Java to an extensive degree.
View 1 Replies
Feb 10, 2010
I have an VS2008 solution with 2 projects, WebUI and Domain; WebUI references domain. The Root Namespace in the WebUI project is:MyCompany. MyProjectName.WebUI. The Root Namespace in the Domain project is blank. (Namespaces are manually declared for all classes). So everything has been working fine, until I tried to reference a class in Domain via a fully qualified path: [Code]
Does this make any sense? So, then I cleared my WebUI Root Namespace, and voila, the fully qualified declaration then does work. However, doing this then seemed to invalidate the registration of all my user controls on my pages. The only thing that seemed to solve this was in the codebehind of each user control, manually add a namespace of MyCompany.MyProjectName.WebUI. which might make sense as perhaps the namespaces of the pages somehow had still retained the root namespace value. But, if I was to create a brand new aspx page and drop a user control on (this is before manually adding the namespace), even that page couldn't properly register it. Yet, the user control properly rendered in design view. so the VS UI seemed to be able to properly resolve it, but the compiler seemingly can't.
So from what I can tell, I can at least get things to work by manually wrapping user controls in the proper namespace. Why this is necessary for aspx pages, that have no namespace specified, to see the user controls, seems to make no sense. Is there some fundamental principle I am misunderstanding??
View 2 Replies
Feb 9, 2009
I VB 2005 you can set the root namespace name of a project under the project properties. Where can I set this using VB2008?
View 4 Replies
Jan 25, 2010
How does one gain programatic access to the information that is entered into the "My Project" properties Application section?I am able to pick up the assembly name from those properties, but I haven't been able to pick these up.Below is the line of code that makes me interested in picking this up programatically. I have found that if the name within the quotes for Sections (GenConfig) doesn't match exactly what is entered in those properties, I will get an application error during run time.How do I reference that property?Is there a better way to pick that value up?
Dim applicationSettingsSection As ClientSettingsSection = config.SectionGroups("applicationSettings").Sections("GenConfig.My.MySettings")
View 4 Replies
Dec 19, 2010
I was a VB6 programmer. And back in the day global variables, functions and subroutines were put in a module. The program started in the module using a sub named Main(). Now in vb2010 it looks like using sub Main() is possible only for console apps, which is not what I want, I'm still trying to write a windows app but it looks like everything has to go at the top of the starting form?? How is this good coding practice? Shouldn't public vars and functions be in their own module?What is considered best practice?Are there any links that would walk me through the differences between vb6 and vb2010?
View 2 Replies
Mar 2, 2010
Scenario:A widget developer codes using HTML and javascript.my vb.net application allows developers to create widgets for other users.in javascript you can call window.external to comunicate with the host windows scripting object and I would like to add a helper namespace with many functions to aid the development of widgets similar to windows sidebar's System namespace.
Problem:So I could allow developers to use Window.External.System but how can I just allow them to access System directly without using Window.External?Microsoft adds a System Namespace to windows sidebar gadgets host window which is just an internet explorer server window.
View 1 Replies
Dec 4, 2009
Which is the best way to store global variables, in My.Settings or My.Namespace. The reason I ask is because I need to know certain boolean values if certain forms are open from other forms. At present I am defining Global Boolean variables in My.Application, which give the result I require.
View 3 Replies
Jan 14, 2010
I have to create an xml doc for a vendor who specifically states they must have their xml as follows:
<?xml version="1.0" encoding="utf-16" standalone="yes"?>
<WMWROOT xmlns="http://www.blahblah.com/BLAH/Interface">
<WMWDATA>[code].......
I cannot find a way to get LINQ to spit out xml the way they want. Question is, can LINQ do it or do I need to resort to hardcoding the xml the old way before LINQ to XML?
View 5 Replies
Nov 21, 2011
I use Excel PIA thru "Imports Excel = Microsoft.Office.Interop.Excel". IDE allows to set "global" reference for any namespace (in Project -> 'Project name' Properties -> References). But it doesn't allow to set alias for this namespace, so I have to write "Imports Excel = ..." thru all files where I need it. This would be great to have such thing in IDE!
View 3 Replies
Jan 16, 2009
just want to know what is the difference between these date values?Once some one told me that its difference is server date and client date but not sure which one he meant.Below is 3 type of date currently I'm using and don't know what is the difference between them.
DateTime.Now is from System.DateTime.Now
Now is from Microsoft.VisualBasic.DateAndTime
Today.date is also from System.DateTime
View 4 Replies
Mar 15, 2012
evrytime i add new controls to a form in vb.net the designer regenerates code and asks me to make corrections, so i have to keep on changing the object declarations to global using the 'global' keyword evertime it regenarates code,especialy dataset objects.how can i prevent this?
View 1 Replies
May 1, 2009
i could use Global x as string in vb6 in a module to declare it with global privelages, how can i do this in vb2008? how to declare a global variable in vb2008? so that i could use it anywhere i want. i know global variables are not recommended in programming but i need one.
View 4 Replies
Mar 17, 2011
I need to read an xml document from a database record into an XDocument object in order for it to be deserialized. So that the deserialization will work, I need to apply a specific namespace to each of the level 1 elements. So XML looks a bit like this:
[Code]...
How do I prevent the blank/empty namespace being added to each child element of the element to which the required namespace has been applied?
View 1 Replies
Apr 20, 2012
All it really does is make me have to dim each variable, making it compile badly if I forget to dim a variable.
View 3 Replies
Jan 29, 2012
Imports System.Windows.Forms
ERROR : 'Namespace' can occur only at file or namespace level
View 5 Replies
Apr 10, 2010
The type or namespace name 'Messaging' does not exist in the namespace 'System' (are you missing an assembly reference?)
View 2 Replies
Oct 8, 2009
how to close application root folder or sub root folder at the time when application is in running mode?
View 7 Replies
Nov 16, 2011
This class is located in the namespace Acme.Infrastructure.Interface.A class with the same name EventArgs exists in the System namespace.In another project in my solution I have a class Acme.BusinessModules.MyModule.MyClass.When attempting to use the EventArgs class I have to fully qualify the class name or the compiler thinks I am using the System.EventArgs class.My understanding of namespace resolution was that the compiler would first look for the class in the current namespace, and then its parents. It seems that the compiler checks in System before it checks in sibling namespaces. Is it correct that System is checked before the sibling? Or is this behaviour caused by other issues (Imports order?)?
View 1 Replies
Dec 8, 2011
I am getting this error,here is my code.
Public Class Sample2
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button1.Click
[Code]....
View 4 Replies
Sep 8, 2011
I have short code like this :
Dim arr1 As New List(Of Integer)
For i As Integer = 1 To 100
arr1.Add(i)
[Code]....
My problem is : after RemoveAt command is value of array 2 is change this is true, but why it effect to array 1 , i don't want array 1 value change
View 4 Replies
Nov 4, 2010
I'm just starting out learning C# this may be really simple but in VB i have these namespaces
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Globalization" %>
<%@ import Namespace="System.Data.SqlClient" %>
How do I go about using those namespaces in C#?
I tried
namespace System.Data
and
using System.Data
but they didn't work
View 4 Replies
Dec 12, 2009
In C#, if you do this, it will compile:
namespace Name
{
public class Test
{
[code]....
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?
View 1 Replies
Jul 13, 2010
Is something like this possible?
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.
View 3 Replies