Why is Visual Studio not picking up my Class Libraries? - c#

I have a asp.net MVC 4 Application I'm working using visual Studio 2010.
I have added 3 Class libraries to the solution and for some reason only one of them is being picked up by visual studio.
So in any class where I reference the other in Using statement. I get the following error "The type or namespace name "*" does not exist in the namespace "MyProject"(are you missing an assembly reference?)"
I have right clicked on the main project, selected properties and checked that all the class libraries are listed under projects, which they are.
I have right clicked on the solution, selected properties and ProjectDependcies, and this is also set up correctly.
The class libraries are all listed in the References folder for the main Project.
I've tried cleaning and rebuilding , no joy any suggestions ??? Thanks

The DLLs are likely built using an later version of the framework than your project is targeting.

The version of .NET that your class libraries are targetting is greater than the version your application is targeting.
Either demote your libraries to use the version of .net targeted by your application, or promote your application to the version used by your libraries.

Related

References missing from c# Class Library created in Visual Studio

I've got a class library. I had created it with VS 2013 a few years ago. It has a References section where I can right click and Add Reference.
I just created a new c# class library in VS 2019 and References does not exist. It does have a Dependencies subgroup.
This seems like a newbie question but I can't find any suggestions of how to add Assembly References and can't think of what I'm missing.
Thanks for any help.
I just figured it out. I had created a .NET Standard Library vs. .NET Framework. I just created a new project, chose .NET Framework class library and now I see Reference.
If you right click on "Dependencies", there should be an option "Add Reference" - this will open the "References" window and you should be able to add packages, projects or .Net assemblies to the solution. They are then listed under "Dependencies".

Not able to use My Class library in C#

I am using Visual Studio 2017. I have a solution and in that solution I have 2 projects. One project is a library I made. This library is using Target Framework .Net Standard 1.6 and Output type: Class Library. The other project is a Windows Application using Target Framework: .Net Framework 4.6.1 and output type: Windows Application.
I added my class library to my windows application and the reference is in the Reference section, but when I try to use a class from the library, it cannot find it. Also I tried adding the "Using MyLibrary" and it still cannot find the reference. What else can I do?
I'm not sure why but the whole solution must had been corrupted or something. So I remade a whole new solution and created the projects again and copied all my files over and it worked. Not sure what the whole problem was but it is now working.

The type or namespace name 'xxx' could not be found

I've developed a dll in .net 2.0. Now I need that dll to be used in other project in the same solution. The project that I am using is also on .net 2.0. It is showing me an error of could not be found.
If I change the target platform from .net 2.0 to 3.5 it works fine in the main project.
Please help me in this.
I found the solution. Problem was with the dll that has been refer with in the dll xxx that I need to use in project. The dll is refers two more dll with in it so I need to add reference of both of that dll in main project and then I can use using xxx statement.

Class library references on Visual Studio 2015

I've added a new Class Library (Package) project to my solution. It's my first experience with a .NET Core (or whatever I'm using, still confused)
My class library contains two references: .NET Framework 4.5.1 and .NET Platform 5.4
I'm trying to import some code from a sample project that uses IPrincipal. For some reason it's saying that it doesn't exist on namespace "System.Security" altohugh I can get it trough intellisense.
What's wrong with my project settings?
The new feature of .NET Core and Class Library (Package) is that it targets multiple platform and will compile into multiple assemblies which get automatically packaged into a nuget package.
When your class library targets multiple targets, it will compile to all of them. So if a certain library is only available on full .NET framework but not on .NET Core or other target framework, then you may receive intellisense if your editor is set to .NET 4.5. More information can be found in my other recent answer.
You can switch back and forth with the pull down menu on top left of the coding window, show in the screenshot below.
If you do not want to target a certain framework, you have to remove it's moniker from the project.json file or use preprocessor directives to write platform specific code or libraries/replacements.
.NET Core is heavily modularized and most of only the core modules are referenced in the default project and if you need additional one you need to reference them within the dotnet5.x section.
Basically you have multiple places with "dependencies" in your project.json, a global one where you can add dependencies which are available on all targeted frameworks and one within each "frameworks" section for each of the targets only.
Though the other answer covers some basic concepts, it would require some attention on which classes are available and which are not.
Microsoft temporarily host a web site at http://packagesearch.azurewebsites.net to assist.
If you can find a suitable package for RC1 from there, then you can add it to your project.json file. If not, you will have to conditional compile it to a desktop profile or use other alternatives.

Reference Component Microsoft.CSharp could not be found

I found this problem on my C# project which I started at Visual Studio 2010, when I go to another PC I use in 2008, I open the project.csproj:
A get or set accessor expected
and warning:
The referenced component 'Microsoft.CSharp' could not be found.
I thought that it was about .NET Framework or Microsoft.CSharp is not located, because it says that:
Could not resolve this reference. Could not locate the assembly "Microsoft.CSharp". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors
but I'm not sure about the problem, can you guys give me a solution? Really appreciated.
It sounds like you are targeting .NET 4.0 in the project, and then trying to load it in VS2008 which only targets up to .NET 3.5.
If you need to use the project in VS2008, then you should re-target the project at .NET 3.5:
and then remove any incorrect references (they'll probably have yellow warning triangles on them anyway).
The A get or set accessor expected also suggests you're using new C# syntax, for example dynamic. If you need to target older C# compilers, you'll have to not do that. If you are using multiple IDE versions and it is being a problem, then to ensure you don't do that accidentally you can set the language version for the project via Project Properties -> Build -> Advanced:

Categories