VS 2015 CS0234 False Error - c#

Other Resources Checked/ Ideas tried
Don't understand why we're getting error CS0234
Type or namespace name does not exist
Cleaning the solution then rebuilding.
Removing the obj and bin folders completely for both projects.
Setup
Visual Studio 2015 update 3
.net 4.5
I currently have a solution with 2 projects. 1 project has a direct reference to the other project, they are both .net 4.5. For simplicity, I will call the project that is being referenced 'A', and the project that is referencing A - 'B'.
While developing in B I have full IntelliSense on classes within A. As soon as I build the solution, project A builds successfully, but project B has several errors as such:
The type or namespace name 'x' does not exist in the namespace
'projectName' (are you missing an assembly reference?)
When I double click the error to navigate to the file I see the error on the 'using' statement for about 1 second, then it disappears along with the error from the error list. I can continue clicking through the entire error list until the error list is empty, but as soon as I rebuild the errors reappear.
Any help would be greatly appreciated.

Verify if project B is referencing other dll files that use a higher Framework version than 4.5, also, I have experienced this problem due to some Nuget packages that had to be added in every project that referenced the original one using the package.

Try taking a look at your Project Dependencies. To do this:
Right Click on your Solution and select Properties
Then on the left side of the screen select 'Project Dependencies'
Make sure that Project 'B' depends on Project 'A'.
This will assure that the projects are being built in the correct order. It should already be set this way, but sometimes Visual Studio doesn't set the dependencies up correctly.
Also, make sure that you don't have any references to Project 'A' in Project 'B'. That would create a circular dependency and give you no end of grief.

do you have a file reference or a project reference. If its a file reference (ie you pointed at the output dll of project A) then you need to ensure that the project dependencies say that B depends on A so that they get built in the correct order

Related

Ambiguous domain with the same path

I am using Visual Studio 2013, with Resharper Ultimate 2015.2, developing a C# .NET 4.5 Console application whose solution space has multiple projects (DataAccessLayer, Domain, etc.)
All of a sudden (this has happened once in the last 3 months but I forgot how I fixed it), one of my C# files gives an Ambiguous Reference error and shows the exact same path.
Related Article: Ambiguous references with the exact same namespace provided the following solutions:
Delete .suo file.
Delete bin directories until all projects.
Resharper > Options > General > Delete Cache ( then restart VS)
Restart VS and rebuild solution
None of these seem to have any effect. I have checked that the references of the offending project only reference the "ambiguous reference" once.
EDIT:
Found another solution here: How to make ReSharper re-evaluate its assembly reference highlighting . Basically deleted Resharper Transient data. Did that. Still have the ambiguous reference. :(
I created another project with the same Includes, same references and same usages... just a subset and it works just fine !!!!!
EDIT 2:
The file compiles with no error!
In installed Resharper 10 and the ambiguous reference disappeared.

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

I have a web ASP.NET project with the bellow structure:
I copied this solution to my test computer and now I get
The type or namespace name 'BussinessLib' could not be found
HousingSurvey is the startup project .
Each project get built successfuly but when I try to build the solution I get
The type or namespace name 'BussinessLib' could not be found
As you see BussinessLib is a reference for Housingsurvey. The using BussinessLib statement is set correctly in the HousingSurvey .
So I rebuild BussinessLib and add the reference to Housingsurvey. Housing Survey as a project builds successfully. but again when I build the solution I get The type or namespace name 'BussinessLib' could not be found
To make things stranger when I check
C:\CSharpTest\HousingSurvey\HousingSurvey\BussinessLib\bin\Debug
BussinessLib.dll is deleted somehow(After I build the solution). I double checked BussinessLib.dll and saw it does get created there whenever I build the BussinessLib project.
I found the most promising answer here:
The type or namespace name could not be found
But above answer did not help me since all of 3 projects in my solution are targeted to the .NET Framework 4.5
Any feedback is greatly appreciated.
Update: please note that this whole solution builds "Successfully" in my UAT computer. Then I copy paste it to the test computer and it fails on build.
For some weird reason, whenever I build the whole solution, Business.dll gets deleted from the bin folder! and that's why code that references it can not find it.
From the HousingSurvey Project, delete the reference to BusinessLib and re-add it again. It is probably an issue with a file path for the original reference.
Also when you add the reference to the project again, be sure to set the 'Copy Local' property to True
In Solution Explorer, click the Show All Files button to display the References node.
Open the References node for the project.
Right-click a reference in the References list, and click
Properties. The properties associated with that reference appear in
a list in the Properties window.
Select Copy Local from the
left-hand column, and then click the arrow in the right-hand column
to change the value to True or False.

Recreating a solution

I'm trying to recreate a solution that had multiple projects in it (only the cs, aspx, etc, remain). When I create a blank solution and blank project files and start re-adding things, I receive the following compiler errors numerous times:
The type or namespace name 'Activation' could not be found (are you missing a using directive or an assembly reference?)
The Activation class is defined in a Activation.cs file that is in a sub folder to the cs file that is using it. I've added and included the files in the project...
The website currently works in production as is, so I'm wondering what type of reference I need...
The following is the structure
Solution
Project1
FileUsingActivation.cs
Folder1
Activation.cs (which contains the class being used in FileUsingActivation.cs that the compiler is complaining about
Edit 1: Just a note that Visual Studio can't resolve the class name, meaning it currently has a squiggly line under the class1 : Activation (Activation portion). But the file is definately included in the project, it's just under another sub folder... I mean I know it won't compile because VS can't resolve the name, but I'm wondering why....
Edit 2: If I add the file to the root of the project, the class name highlights blue, the squiggly goes away as does the error.... so I can't keep the existing folder structure in the project for some reason????
long shot: check for compiler conditionals (like #if some_condition/.../#endif);
Your build configurations might have contained them.
Also, check that the build action is 'compile' for the build configuration that you're trying to build.
Build configurations: MSDN
Conditional Compilation: MSDN
Could be a few things, but given your context...
Are you using .NET 4/VS 2010? The default "Target Framework" for projects is .NET Framework 4 Client Profile, but if you are referencing another project that is the full .NET Framework 4 you'll get this un-informative build error.
To fix this, right-click on your project, click "Properties", and under the "Application" tab set the target framework to .NET Framework 4 (and not .NET Framework 4 Client Profile).
EDIT: For anyone else who stumbles on this question/answer, the above solution will work for you if your classes appear to be included/working while editing (highlighted light blue, etc), and you can right-click "Go-to Definition" for it, but then it gives build errors as if it could not be resolved.

The referenced project x does not exists

Hej All,
I upgraded my solutions of a project from vs2008 to vs2010.
But right now I have a weird problem. I reference a project in multiple solutions (3 solutions)
In 2 of those solutions the referencing goes wrong.
I am able to add the reference (project reference) but when I build I got the warning the referenced project x does not exists. And errors that I have to add an reference.
I already deleted and added the project again, same with the references but no result.
Does anybody have any idea?
Greetz,
Jonathan
I had the a similar problem and the other solutions didn't help. What worked for me was opening the project file in a text editor. There were duplicate references to a library, one as a project reference and one as a dll reference. I deleted both. Then I opened the solution in Visual Studio, and re-added the reference as a project reference. Only one reference got added and I stopped getting the warning.
Make sure your project is not using the ".NET Framework 4 Client Profile" as target framework, this is the most common source of these problems.
You can check this in the project properties under Target Framework.
From MSDN:
If you are targeting the .NET
Framework 4 Client Profile, you cannot
reference an assembly that is not in
the .NET Framework 4 Client Profile.
Instead you must target the .NET
Framework 4. For more information, see
Troubleshooting .NET Framework
Targeting Errors.
I was experiencing the very same issue although I was correctly referencing .NET 3.5 in all the projects migrated from VS 2008 to VS 2010 (all references to System assemblies were using a runtime version v2.0).
Weird however, the error only occured if my solution (and the projects in this solution's subfolders) were located in certain path... I could "solve" the problem by moving the projects or renaming the projects (only the project file, not the output binaries) ?!
Double clicking the reference in the project opened correctly the Object Browser where I could find all the artifacts defined in the referenced project !
I did start to delete everything from the project (classes, resources, references, etc...). At the end, I had only two projects (A referencing B) without any other references and with only one empty class in each. I still had the message "referenced project '..\B\B.csproj' does not exist.". Suddenly, trying to copy the source to another PC and next back into the original path on my machine (kind of black magic to solve the problem), I did get the message "Cannot copy. Resulting file name is too long".
Wierd² !!! I did delete every thing on my PC and did copy back again the sources from the other PC. It passed successfully ! I did recopy again back from the other PC (overwriting now the existing local copy) and again I got the message "Cannot copy. Resulting file name is too long". So the problem occurred only when overwriting existing files.
I found that the error occurred only if the existing file was "readonly". Removing the flag readonly solved this issue. However, this error was the sign of something possibly at the root cause of my initial issue: "referenced project '..\B\B.csproj' does not exist."
So, I decided to check if the project path length was the issue by renaming one of the folder but not changing the total length! The error still occurred (reference not found).
Next (I knwow, you already think I am crazy or stupid. But all those steps were validated by various colleagues), I did copy the solution in a new folder (with a longer path). Surprise, the error did not occurred anymore !!!
But moving the solution back to a folder with the same length (possibly another name) was reintroducing the error (after a "Clean" of the solution otherwise the meta in obj helped to solved the reference).
I was also able to reproduce this by renaming the project file B instead of a folder in the path. A longer or shorter project filename was solving this issue.
The length of the project filepath is "195" :
D:\TFS_Builds\5\XXXX 1.1\Release 1.11\Sources\Release 1.11\Exception Repository\XXXXXX.Framework.ExceptionHandling.Repository.ServiceHost\XXXXXX.Framework.ExceptionHandling.Repository.ServiceHost
Also, as I can be very creative when trying to identify the root cause of a problem, I did create the very same path on C:\ and put the solution in there... Same error occurred.
I never found (until now) the reason of this and have posted a question on MSDN :http://social.msdn.microsoft.com/Forums/en/msbuild/thread/f0eb6aed-5854-4678-9546-09c1a7705e30
Here is what fixed my problem:
I had a refference to a project named "Utilities.Proxy3.5", which would give me a the following warning:
"The referenced project
'..\..\Utilities.Proxy3.5\Utilities.Proxy3.5.csproj' does not exist."
Renaming the project folder and the project files to "Utilities.Proxy35" and re-adding the reference solved the problem. Note: I have only removed a dot between the numbers 3 and 5.
I hope this will help someone.
I had the same issue.
What solved it for me was that i opened each of the reference projects on its own first. VS asks for a permission to fix some of the files. Allow it to do so.
Then open the top project and it will work.
Apparently it was issues with the version of VS that created the original project.
Good luck
Check the lengths of the following:
The path of the referencing project's directory
The relative path to the project it references
If those paths add up to exactly 259 characters, you will experience a bug in the .NET implementation of Path.GetFullPath that will cause VisualStudio 2010 to behave as if the referenced project does not exist.

How to set "Specific Version" property for project references in Visual Studio

I have got a Visual Studio Solution containing several projects and have set up the references between the projects as project references.
When a reference to an assembly is added, the references' properties contain a setting for
Specific Version = True|False
This property is missing for project references. How can it be set? I'd like my solution to load any available assembly (no matter what version) in the bin folder.
I've had a problem when a workflow instance (Workflow Foundation) was deserialized and the dependencies were updated meanwhile.
I think the problem is that what you are asking is not possible directly with a project reference, I think that always implicitly turns into an 'explicit version', because of the nature of the link.
The way you could do this (calling the currently referenced project A, and the referencing project B):
Have the project you want to reference in your solution, just like you do now with the project reference
Explicitly set the dependency chain so the 'referenced' project is built first
Build the referenced project A once first manually
Create an assembly reference in project B to the results from the build in project A
Set the assembly reference to 'Specific Version = false'
The build order (dependency) will guarantee that A is always built before B, and B will reference it from the binary output directory of A.
(altho, it's a little brittle and I would not recommend it since it's easy to get wrong results if the settings are not all right, or the sun aligns with the stars wrong, or some such)
I might be misunderstanding your question, but when you add a project reference, the project's assembly is always loaded into any project that references it when the project is built. Therefore, you'll always have the latest available assembly in the bin folder for that project. VS treats projects differently than other assemblies in that regard.
You can add references to project output dlls instead of projects. Then you will be able to set Specific Version setting.
I have found the solution to my problem. It's described pretty detailed here.
The problem is not a matter of wrong project references, but more a de/serializing of workflow instances question.
Thanks to everybody who tried to help.

Categories

Resources