Multiple project solution, 'missing assembly reference' despite including it - c#

I have two projects in the current solution:
abc.Dashboard
abc.ThingyService
abc.ThingyService needs to be able to use a class from abc.Dashboard.
I've added a reference to abc.ThingyService pointing at abc.Dashboard (right click on project -> add reference -> projects -> abc.Dashboard) but it's not recognising that it has been added.
One of the files in the abc.ThingyService project contains:
using abc.Dashboard.Services
When I compile, I get the error:
The type or namespace name 'Dashboard' does not exist in the namespace 'abc' (are you missing an assembly reference?)
Am I missing something very obvious here? :/

Do you see the entry for Dashboard under the references section of ThingyService project in solution explorer ?
I would give a try to these steps.
1) Remove the reference and readd again and see.
2) Close Visual Studio and reopen it and see
3) Try to add the Project reference instead of selecting the dll while adding the reference.
4) Right click and build the Dashboard project and then build the ThingyService project. If that works, you probably need to check your build order.

I believe you also need to add the project as a dependency.
http://msdn.microsoft.com/en-us/library/et61xzb3(v=vs.80).aspx
This determines build order, making sure that the linked project has been compiled first.

Related

In my bot application getting error while adding assembly reference to "Microsoft.Bot.Builder.Dialogs"

Getting an error in adding assembly reference to "Microsoft.Bot.Builder.Dialogs" that Type or namespace name Builder does not exist in the namespace "Microsoft.Bot".
I have added the reference to "Microsoft.Bot.Builder" but still I am getting this error in Using statement.
Please suggest what could be the reason.
The problem you are having is that the using statement can't find the referenced assembly. So, you need to add either a project reference or assembly dll reference. If you have access to the code and want to debug the referenced code, then you should add a project reference.
To add a project reference, first you have to add the Microsoft.Bot.Builder project to your solution. It looks like the project code can be downloaded from this link.
Once you have downloaded the code, the project can be added to your solution by right clicking on the solution name in Visual Studio Solution Explorer and then selecting Add / Existing Project.
After the project has been added to your solution, a project reference can then be added by by right clicking on references (under your project), selecting Add, then click on projects, and then double click on the project you just added.
If instead you don't think you will want to debug and step through the bot code, then you can add a dll assembly reference. Make sure that you have the latest version of the Microsoft.Bot.Builder.Dialogs dll. Right click on references from Visual Studio Solution Explorer. Select Browse and then navigate to the folder where the dll is located. If you believe the assembly you wish to reference has been installed, then you can click on Assemblies instead and click on the appropriate assembly.
For more info on references, see this link.

Added a project but it says its missing

So I added a project to my solution, it builds, but I can't seem to reference it, as it says its missing. I've looked and tried all the answers here:
The type or namespace name could not be found
but none worked for me. all projects are set to target .NET Framework 4.5, Site project is dependant on the reference project, they all have the same Configuration Properties (Debug, Any CPU, Build)...
Any other ideas?
I could be wrong but i think a depency is only used for build order.
Did you add the project as a reference via Project folder => References(Right click on it) and select Add Reference...
Then open Solution,Projects and check the project that holds the namespace you are using(in your case DataTables.mvc)
Images for clarity :

The type or namespace name 'Device' does not exist in the namespace 'System'

I am trying to work with GeoCoordinate which is meant to be supported by .Net Framework 4.5. I am working on winodws 8 and I have .Net Framework 4.5, but I keep getting The type or namespace name 'Device' does not exist in the namespace 'System' error.
Any solution?
The type or namespace name 'XXX' could not be found...
Always bear in mind, if you get this error there are three possibilities.
You missed the using directive.
You missed the Assembly reference
You have "using directive" as well as "Assembly reference" in place but the current project's target framework version is lower than the referenced assembly target framework version.
Almost all the cases above three steps should solve the problem.
Hope this helps.
Does not have added reference of System.Device dll in your project.
Steps to Add Reference.
1. Right click on the Reference folder on your project.
2. Select Add Reference.
3. Expand Assemblies option.
4. Search System.Device in the serach box at right corner side.
5. After searching, click on checkbox to select and click on ok.
If you are using VS.NET:
Right click on the References folder on your project.
Select Add Reference.
Select the .NET tab (or select the Browse button if it is not a .NET Framework assembly).
Double-click the assembly containing the namespace in the error message.
Press the OK button.
If you are using the command line, use the /r: or /reference: option. For Example:
csc.exe /reference:System.Drawing.dll MyFontDisplayApp.cs
When you recompile, this error will no longer appear.
It is also possible that your project uses x64 libraries and your machine has limited x64 libraries. I think this happened in my case.
Possible Solution: I copied library from x86 folder to bin folder of my project. Then added the new reference(discard the old reference to same library). AND IT WORKED.
Note: Please correct me if I am wrong here.

The type or namespace [...] could not be found (no overloaded target framework)

The type or namespace name 'Highscores2' could not be found (are you missing a using directive or an assembly reference?)
I've seen several threads on here with similar "type or namespace could not be found" problems, but the only root-cause was to make sure that the 'missing' namespace was also targeting the same framework.
In my particular case, "Target framework" is not set (and is even grayed out) in the properties of all of the projects, so that doesn't appear to be the issue.
The "using Highscores2;" is spelled correctly (copy/pasted from the namespace declaration) and the build order appears to be correct.
Additionally, the Highscores2 project builds fine on its own, and in a demo solution that came with the project, that solution actually builds just fine.
What other types of things (that I'm missing) can cause the "type or namespace could not be found" error?
You can have it as a project in the solution, but if you are trying to access it from another project that one must have a reference. You can open the target project's properties and check the "References" tab, and you should see an Add button.
Here is the MSDN page if it helps: msdn.microsoft.com/en-us/library/f3st0d45(v=vs.100).aspx
I've had a problem with this before with multiple projects. When I added a reference to the second project, in this case the one referencing HighScore2.dll, it was pointed to the /release build of the dll. However, in Debug /release isn't built, and so it couldn't find it. This may be a longshot, but if this is the case you can open up the csproj with notepad and edit the path for the assembly to use $(Configuration) in the path to point to the correct build configuration.

Cannot compile solution?

I have business layer in my solution. I added console project to the solution. Added necessary reference to console application. Created instances of classes in business layer. I'm using resharper so code looks correct.
when I try to build I get the error like
Error 127 The type or namespace name 'BusinessLayer' could not be found (are you missing a using directive or an assembly reference?) C:\ConsoleApplication\Program.cs 13 25
if I reference business layer from web project under the same solution it compiles, but with console it's not.
do you have any idea what can be the problem?
Add using BusinessLayer; in the top of your application, if you already did that, then try to clean and rebuild the solution.
Also make sure that both the library and the console application have the same .net framework version, for example both are 4.0 and not one of them 4.0 client profile...
You seem to confuse a library (project) reference and a using statement judging by your comment:
I have the reference at the top of the page.
You need both to add a reference (right-click your project's References folder in Solution Explorer > Add Reference...) and add a using directive at the top of the code file to import the required namespaces.
You'll have to add a reference to that assembly from your console project.
You add references at the project level not the solution level, so the reference you added to your web application doesn't help your console app.
Right click over your solution, configuration manager, you will see all projects, be sure that you have marked all necessary projects to build with right platform.
Hope it helps.
Rebuild the BusinessLayer class library and build your solution again.

Categories