Reputation: 8369
I have a solution that contains two projects developed in visual studio 2012 express, and both targeting the .net framwork 4.5.
the first "Dao" project purpose is to take data from a database. and take these data to the second project as a dll library
the second project "UI" purpose is to display data coming from dll library
when i added reference to the second project and wrote using statement, I got the following error:
The type or namespace name 'Dao' could not be found (a using directive or an assembly reference missing?)
I tried to change the target of the two projects to .net framework 4.0 and .net framework 3.5 , but I got the same error.
I also add this piece of code to be sure that the target is change but I got true :
using System;
using Dao; // error
namespace Ui
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(Type.GetType("System.Reflection.ReflectionContext", false) != null);
Console.ReadKey();
}
}
}
What do I need to do to fix the problem? Thanks a bunch.
Upvotes: 0
Views: 4724
Reputation: 995
First things first:
Add a reference to Dao - in source explorer right click references->Add->projects tab.
Add a using statement at the top of your code something like using Dao;
Ensure Dao is a public class
This way your code will know to reference Dao, it is usually better to create a new instance of Dao:
Dao example = new Dao();
Then when calling Dao you would call example instead, so example.(name of method)
Upvotes: 3
Reputation: 7147
You need to add a reference to your Dao assembly from your UI assembly. Right Click on References, Add Reference. In the Projects tab, select your Dao project and hit OK.
Upvotes: 5