VisualStudio.Net reference not working - c#

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.

Related

The type for namespace name 'FormHome' could be not be found {are you missing a using directive or an assembly reference}

there is no place for assemlbies in my project. I tried many methods to find it, but without success.
The problem is that it can't find the class - it's not in the same namespace as your current code.
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.
If it doesn't, you need to find out where that class is, and add a reference to uit, either via the project in the same solution, or via the DLL, and then add the appropriate using line to the top of all files that reference it.

Getting reference error on naming controls - WPF

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

Library reference imports ok, intellisense sees everything, objects instatiated... then I build and it can't find anything?

I run into this every once in a while and I never really figured out how to fix it. I have a class library that is in the same solution as the test console project. when I add a reference to the library in the console project and add the using statement, intellisense sees all of the classes just fine. So I write some code and use those classes. All of the class members are showing just fine. Then I hit build. I get an error that the classes from the library cannot be found (are you missing a using directive or an assembly reference?). Now all of a sudden, all my objects are underlined in red and no longer color coded as classes, and the using statement is also underlined in red. The reference to the library is still in the references folder. Wtf
If I remove the reference and readd it, its the same thing. It'll see everything just fine until i build.
Check that warning in your screen, saying "Referenced assembly UTILibrary could not be resolved because it has dependency on System.Web....". UTILibrary is probably using System.Web internally, so this dependency must also be added to TestConsole project.
Add it and all should be fine.

How do I get an empty project to compile as a dll?

I created a new VS "empty" project, and in it made a class. I decided to try this out as a library, went into properties and set the output type to class library. It compiles to a dll, though when I add it as a reference to another project, typing in "using ..." doesn't have my new library in there. If I create a new library project, past my class in there, compile that into a dll, then it works fine. So what I want to know is, what settings to I need to change in a blank project to get it to act as a dll?
using directives are about namespaces, not assemblies.
If your library is empty, it's not contributing anything to a namespace, so a using directive won't find anything.
It's very important that you understand the difference between a namespace and an assembly - you could have library Foo.dll which only contains Bar.Xyz. You would add a reference in your project to Foo.dll, but a using directive for Bar.
As a more concrete example, the Enumerable class in the System.Linq namespace comes from System.Core.dll - but you still add the using directive for System.Linq, not System.Core. Indeed, if you try to add a using directive for System.Core, you'll get an error - because that namespace doesn't exist. (A namespace effectively doesn't exist if it has no members.)

Referenced class lib doesn't seem

I have a class lib and I referenced it to another windows project. I added its namespace to my Form.cs (using SaglikNetClassLib;). they are seem unknown when I want to access to classes. I can see their properties and methods. But the complier says "Error 7 The type or namespace name 'SaglikNetClassLib' could not be found (are you missing a using directive or an assembly reference?), Do you have any suggestion?
KR,
Çağın
Are you targeting the .net Client Framework? Visual Studio let's you add references to incompatible assemblies, but then gives exactly that error.
Check your project settings to make sure you're targeting the full .net framework.
Also, check that the Ilalcar class is public and not internal (which is the default if it's only declared as class without any modifier)
You probably need an using statement to put the class into scope.
using SaglikNetClassLib;
C# won't auto suggest it if the project has not been rebuild. Also make sure the class library project has been build before using it in code.
Intellisense seems to lag behind a bit at times. Simply pressing f5 (run) sometimes rebuilds the project completely and simply runs or gives a better error message.

Categories

Resources