Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Namespace not recognized (even though it is there) [duplicate]

Tags:

c#

reference

People also ask

Why am I getting error CS0246 the type or namespace name could not be found?

The following situations cause compiler error CS0246. Did you misspell the name of the type or namespace? Without the correct name, the compiler cannot find the definition for the type or namespace. This often occurs because the casing used in the name of the type is not correct.

How do I fix cs0234?

To fix this error, simply update the example . csproj file to use a previous System. CommandLine version. Note that this package is only used to parse the options for the example.

How do I find the namespace of a DLL?

Accepted AnswerWhere 'component_name. dll' is the file name of your DLL. This will display the namespace, classes and all the methods of the . NET dll.

How do I fix assemble reference error in Visual Studio?

Navigate to the startup project in solution explorer. Right click, properties > Application > Target framework. Change the target framework to anything else. Press Yes for the confirmation dialog.


Check to make sure that your project isn't set up to use the .NET Framework 4 Client Profile.

You can check/change this by right-clicking your project (not the solution), select Properties -> Application -> Target framework. The target framework is a dropdown on that page.

This is a problem in Visual Studio (I would even go so far as to call it a bug). AutoMapper requires assemblies that are excluded from the .NET Framework 4 Client Profile. Since your project is using that version of the framework it breaks.

A similar error will propagate to the build process when the .NET Framework version for the project you are referencing is higher than the project making the reference. i.e. A project targeting 4.5 that references a project targeting 4.5.1 will give you this same error.

There needs to be a better error message when this happens because there is no rational explanation as to why it would not build as the error message tells you to reference an assembly you have clearly referenced.


Let me ask a stupid question: Could there be two automapper.dll files? One with an AutoMapper namespace and one without? Confirm the paths in both projects.

I also noticed that the order of the using commands is different. It shouldn't matter, but have you tried to shuffle them?


This has to be the simplest solution if all the other answers does not help you

I was searching for what's wrong with my setup among the answers, Tried all of them - none worked, Then I realized Visual Studio 2018 was developed by Microsoft. So I did what most people do,

Restarted Visual Studio And It worked


If your class does not compile, even if it is in the project check these:

  1. whether class name is exactly the same
  2. whether name space is exactly the same
  3. whether class properties show build action = compile

I resolved this issue by right clicking on the folder containing the files and choosing Exclude From Project and then right clicking again and selecting Include In Project (you first have to enable Show All Files to make the excluded folder visible)