Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error "The type or namespace name could not be found" during a build process

I'm using in C# Windows Application, I have using

TempProWin --> For Windows Application Projects
TempProApp --> For Database and functionality like Class File using CSLA Method.

In TempProWin.frmLogin.cs:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using  TempProApp;

private void frmLogin_Load(object sender, EventArgs e)
{
 UserLoginList oUserLoginList = UserLoginList.GetUserLoginList();
 cmbUserName.DataSource = oUserLoginList;
 cmbUserName.DisplayMember = "Select User";
}

But When I build this application, I got the following error:

Error 5 The type or namespace name 'TempProApp' could not be found (are you missing a using directive or an assembly reference?)

I already include reference of TempProApp.dll from the path of D:\TempPro\TempProApp\bin\Debug

like image 454
user1941948 Avatar asked Feb 07 '14 11:02

user1941948


People also ask

How do you fix the type or namespace name could not be found?

That may be it's in a different project in the current solution, in a external DLL, or just in a different namespace in another file in the current project. Start by hovering the mouse over the error, and open the drop down that appears. If it has an "include" option, click that, and it should fix it.

Why am I getting error CS0246 the type or namespace name could not be found?

error CS0246: The type or namespace name `________' Could not be found. Are you missing a using directive of assembly reference? This error is caused when the namespace that you are trying to use does not exist.

How do I fix error cs0234?

To fix this error, simply update the example . csproj file to use a previous System. CommandLine version. Note that this package is only used to parse the options for the example.

What is a namespace in C#?

Namespaces are used in C# to organize and provide a level of separation of codes. They can be considered as a container which consists of other namespaces, classes, etc. A namespace can have following types as its members: Namespaces (Nested Namespace)


2 Answers

RightClick on TempProApp and Go to definition.

On the top most, you will see the dll name and its version. You can verify that whether you are using the same dll version or not.

like image 109
M.S. Avatar answered Sep 18 '22 20:09

M.S.


A spurious “The type or namespace name could not be found” build error can result if you have other build warnings.

I'd partially coded an asynch HTTP method, which was generating warnings about missing awaits. I planned to get the rest of the system building, then fix that.

But I started getting the above hard error. I've spent the last three hours trying to isolate its cause. I tried all the suggested fixes, quadruple checked names, etc., and even deleted and recreated the project that was generating the complaints. No change. It seemed strange to me that when I clicked Go To Definition on the offending type reference, VS 2012 could find it with no problem. WTF*

As a last resort, I commented out the code that was producing the warnings. This fixed the spurious error messages and the build succeeded.

So, if you've ruled out the other causes and you have other build warnings, try fixing those.

like image 35
Tristan Fabrini Avatar answered Sep 19 '22 20:09

Tristan Fabrini