I have a project named AAA.System that contains some simple base functions to be shared by all of our other projects. This has been around for about 5 years or so, and we have many projects that reference it which are all working fine.
Now, I am creating a new project (WCF service) and I’m having some issues with namespace resolving. Specifically, I have these usings:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Configuration;
using System.Configuration.Install;
using System.Reflection;
using System.ServiceModel;
using System.ServiceProcess;
using System.Text;
using System.Threading;
using System.Xml;
at some point, I have this line of code:
string fqdn = System.Net.Dns.GetHostName();
which is generating the error:
The type or namespace name 'Net' does not exist in the namespace 'AAA.System' (are you missing an assembly reference?)
So it seems that somehow the visual studio (2010) is trying to resolve to AAA.System.Net.Dns.GetHostName() instead of System.Net.Dns.GetHostName(), but I don’t have any using statements indicating the use of AAA.System. What am I missing here that is indicating to the compiler to use AAA.System?
Is the namespace of the class you are calling the following line set to
AAA?e.g.
To fix it you should be able to prefix the line with
global::.Or just add
System.Netto you using directives