Coder Perfect

[duplicate] The type or namespace name could not be found.


In Visual Studio 2010, I have a C# solution with numerous projects. The first is a test project (named “PrjTest”), while the second is a Windows Forms Application project (named “PrjForm”). PrjForm also references a third project, which it is able to reference and use correctly.

PrjForm is a class that uses PrjTest, and PrjForm has a using statement:

using PrjTest;

The name ‘PrjTest’ was not found in the type or namespace (are you missing a using directive or an assembly reference?)

To fix this, I’ve tried the following:

I completed my homework and spent way too much time hunting for an answer online; nevertheless, none of the solutions have proven to be helpful.

What other options do I have?

Asked by Anders

Solution #1

See this question.

It turned out to be a problem with client profiling.

“.Net Framework 4 Client Profile” was selected for PrjForm. I modified it to “.Net Framework 4” and now the build is complete.

Thank you all very much! After all the time spent searching online, I guess it’s no surprise that I find the answer minutes after posting. I guess the trick is knowing the correct question to ask.

Answered by Anders

Solution #2

In my circumstance, I had the following:

.NET 4.5 is a referenced DLL.

.NET 4.0 project

The 4.0 project couldn’t look within the namespace of the 4.5.DLL because of the aforesaid mismatch. I fixed it by recompiling the.DLL to target.NET 4.0.

Answered by DeepSpace101

Solution #3

This also worked for me. Thank you very much. I was attempting to run an RDF example in DotNet using the dotnetrdf kit.

NET4 Client Profile: For all client desktop applications, use the NET4 Client Profile (including Windows Forms and WPF apps).

.NET Framework 4 (Full): Only use NET4 Full if your project requires features or assemblies that aren’t available in the Client Profile. This includes the following: If you’re creating server applications, such as:

Employ System.Data.OracleClient.dll, which is deprecated in NET4 and not included in the Client Profile, if you use legacy client scenarios.

If you’re targeting developer scenarios and need a tool like MSBuild or access to design assemblies like System.Design.dll, this is the place to go.

Answered by Dee

Solution #4

Having NuGet packages generated with a newer version of.NET can also cause this problem.

The original error:

frmTestPlanSelector.cs(11,7): error CS0246: The type or namespace name 'DatabaseManager' 
could not be found (are you missing a using directive or an assembly reference?) 

I discovered this further up in the log:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\ Warning: Microsoft.Common.targets(1605,5) MSB3275: Because it has an indirect dependency on the assembly “System.Data.SQLite, Version=, Culture=neutral, PublicKeyToken=db937bc2d44ff139,” which was built against the “.NETFramework,Version=v4.5” framework, the primary reference “[redacted]DatabaseManagerbinReleaseDatabaseManager.dll” could not be resolved. This is a newer version of the framework than the one being used now, “.NETFramework,Version=v4.0.”

Reinstalling the NuGet packages was the solution:

Answered by Miebster

Solution #5

Because the other project was written in.NET 4.5 and the other in 4.0, I was able to fix my.

Answered by kurdapya

Post is based on