Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
125 views
in Technique[技术] by (71.8m points)

c# - ASP.NET - type or namespace does not exist

I want to have one project that is linked to and uses another project.

I'm using ASP.NET. I have a solution file. It has many files and projects in it.

Recently, I made a new file called Testing that has two projects: Testing.Web (WebForms) and Testing.Core (Class library). Ignore ServiceA for the moment.

Directory

I added a reference to Testing.Core in Testing.Web.

Reference

Both projects target .NET Framework 4.

Testing.Web target framework

Testing.Core target framework

Everything builds. I can locally run the code until I try to invoke a .aspx pop-up that uses Testing.Core.

Server Error with Testing.Core

I made sure that the Testing.Core.dll referenced in Testing.Web (above) is in the correct location: TestingTesting.CoreinDebugTesting.Core.dll.

The pop-up works if I remove references to the Testing.Core project. When I add it back, the Server Error message appears again.

I figured maybe there was a namespace issue, so I made the ServiceA project (first screen shot). It just has one class with a HelloWorld() method.

ServiceA code

I added a ServiceA reference to Testing.Web. I use ServiceA.dll by instantiating its one class and invoking its one method--same Server Error.

Server Error 2 with ServiceA

I checked the configuration manager. It all looks good there too.

Configuration manager

I looked at Testing.Web and Testing.Core's Properties > Build setup and made sure it was in line with what other Stack Overflow posts advised:

  • Define DEBUG constant checked
  • Define TRACE constant checked
  • Advanced > Debug Info: full selected

Testing.Web can reference other projects in the solution file (e.g., my Utilities project, which also targets .NET Framework 4).

It just doesn't seem to like any new class library that I make and try and link Testing.Web to.

I'm using Visual Studio Professional 2015.

I'm stuck. Any help would be hugely appreciated!

question from:https://stackoverflow.com/questions/66053574/asp-net-type-or-namespace-does-not-exist

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

So, for anyone that has tried everything else with this error, here's what my issue was.

IIS (Internet Information Services), the software that is used to make a computer a web server.

I had IIS configured such that the binaries that the framework couldn't find (in my case, Testing.Core.dll and ServiceA.dll) needed to be manually put in the root directory's bin folder.

It didn't matter that Testing.Core and ServiceA were added to Testing.Web as a reference in Visual Studio--at runtime, debugging locally, it needed those .dll files in the root directory's bin folder.

FYI, someone who knows IIS better than I do said it's not good practice to have IIS set up this way, but it's what I inherited.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...