C# Missing References

If you are getting an error like “The type or namespace name does not exist in the namespace” you may have found yourself tweaking the references or the using statements in your C# code.

The using statement and the referencing statement differ in that the using statement is a logical link and reference to the namespace library, this makes it so you can shorten your qualifications to objects. Instead of typeing System.Windows.Forms.Textbox. You place a using statement “using System.Windows.Forms” at the top of your page and you only have to now use the word Textbox to reference the object. These are also usually statements to libraries within your current namespace.

The References are registrations to libraries and dlls that are to be used outside your namespace.

Recently in a project, there were a number of projects that had change adding some ENUM references that were prominently used in the application. These errors made it immpossible to build the solution. In order to rid yourself of this error, you must resolve a conflict, or supply a reference or using statement.

First, check the statement where the error occurs. Make sure the namespace/library that the object refers to is available in the project. If you find the source cs file, look to see if the Namespace is different than where the object is being used. If they are different, then either fully qualify the namespace in front of the object, or add the “using <full namespace>;” statement at the top.

Try and compile the application, if you still have the error, then look in the current project (where the error occurs) References list and see if the assembly/library is there. It’s it isn’t, then add the new Reference by either locating the .NET object, COM object, project, or file.

When this has been added, try compiling again. If you still get the error, then you’ll have write some comments here and provide your code for me to be able to help you further.

Leave a Reply