Getting reference error on naming controls - WPF - c#

I have a solution named Solution1, which has multiple projects named Project1, Project2 etc. In Project1, I have a usercontrol called "DesignElement". When I name the UserControl from the XAML, using the "x:Name" and then compile it, i get the following compile error:
"The type or namespace name 'Project2 ' does not exist in the namespace 'Solution1.Project1.Project2' (are you missing an assembly reference?)"
Where is this reference of Project2 coming in Project1? Why does this compile error arise? Also, if I am not going to use the "x:Name" in any controls, then the solution compiles and runs fine. Any help on the same is appreciated.

Just because you have two projects in the same solution doesn't mean that they can instantly see each other.
Here is the proper flow to making them see each other
Create a solution
Add projects
In project two right click on references in Solution Explorer and hit add reference
^^^^^this is the step you missed^^^^
In the collumn on the left of the popup click solution
Choose project one
Add using or xmlns in your code to project one
reference project one's code

Related

VS 2015 CS0234 False Error

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

Missing an assembly reference

In a solution I am working on, in a sub project I have added a reference to another project. After adding the reference, I was able to successfully add the using statement and have the auto-complete pick up the right extension I was looking for. The code wrote as usual, but when I compiled, I get the error
The type of namespace name 'Name1' does not exist in the namespace 'Name2' (are you missing an assembly reference?)
So I have searched the forums, I have added several other system references and I have gotten nothing. I ran NuGet to update the solution packages, and that didn't make a difference either. For some reason, when I add the reference (using the add reference pop-up GUI) the reference to Name1 doesn't have a dll file in it. If I browse to the dll file directly, it still gives me the same issue when compiling.
Maybe you can copy the dll to [projectname] / Debug /
or [projectname] / Release /

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.

VisualStudio.Net reference not working

I create a new solution called "WordpressAutomation"
I create a new project, a class library, called "WordpressAutomation" in this solution
I create a new project, a unit test project, called WordpressTests in this solution
I add a reference to the project WordpressAutomation in the project WordpressTests"
This should be ok, shouldn't it?
However, as can be seen from the screenshot, when adding this using line in a class in the project WordpressTests,
the reference doesn't work. Even though it is there, as can plainly be seen.
When entering "using", the class library "WordpressAutomation" doesn't appear among the alternatives.
And I get this error message when trying to run:
"The type or namespace "WordpressAutomation" could not be found (are you missing a using directive or an assembly reference?)"
Why is this happening? The reference is clearly there?
http://i.stack.imgur.com/L0g5R.png
Your project isn't actually including the .cs files to compile; they are only shown for information (they should appear as solid files with the C# logo):
Right click on these files and include them in the project. Then check what namespace they declare inside them. At the moment, your WordpressAutomation project simply doesn't contain any types.

missing references at debug time

hi there i know its most be a silly mistake but i couldn't find it. i add two references to my project by Right click on References and browse them, i simply use component of these Dlls in my program with no problem, auto complete code is work fine for classes of these Dlls. But when i run my program got error like:
The type or namespace name 'GlobalizationDateTimePicker' does not exist in the namespace 'GHDiamond.Windows.Forms' (are you missing an assembly reference?)
for this line in myform.Designer.cs:
this.DateTimePicker_AZ = new GHDiamond.Windows.Forms.GlobalizationDateTimePicker();
References names are: GHDiamond.dll and GHDiamond.Win.dll. they are in Object browser too when a add them, but when i Build my project, GHDiamond.Win is not there anymore ! any help will be appreciated
Select the Reference in the Solution Explorer and go to the property window. Make sure that the property "Copy Local" is set to "True". This causes the dll to be copied to the output directory.
I have had something similar which was caused by missing dependent dlls. Autocomplete worked until i built then i would get a load of compile errors. make sure there are no other dlls that you need.

Categories

Resources