Tip: Missing a namespace?

When using classes in certain namespaces of .NET you need to include the using statement at the top of you code.
If you fail to do so the compiler won’t be able to find the class.


XmlDoc.Load(Path.GetDirectoryName(Assembly.GetAssembly(typeof(OCIForm)).CodeBase) + “SampleXMLFile.xml”);

Here the Path and Assembly classes will not be found because I haven’t included the System.IO and System.Reflection namespaces.

You can add them manually if you know by hard which namespace to use for this class. But if your memory fails you, you could simply right clich the classname and select Resolve > Using System.IO;
The using statement will be added automatically.

Resolve function in VS

Resolve function in VS

Visual studio will automatically search for the namespace. 😉

Tagged with: ,
Posted in .NET

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: