Runtime CS0234 Error accessing SOAP Web Service in VS2010 Web Application
I have an ASP.NET 4 web application that references a SOAP web service. I have an (old fashioned) Web Reference to this web service in my project. When I compile/build in the IDE I get no problems and Intellisense and the Class Viewer all show me that VS knows what is what and where to find it.
However, when I run the solution, I get this error:
The old CS0234 error (The type or namespace '<...>' does not exist...). Intellisense begs to differ.
My web app assembly is called NovaWeb
and my Web Reference is called WS3
. I can see that my Reference.cs file contains the following:
namespace NovaWeb.WS3 {
This was all working great a little while ago, but I apparently changed something and now everything is broken. I've tried cleaning out all of the files in the /bin folder and all of the temporary ASP.NET files in my appdata folder.
Does anyone have any suggestions about how I can troubleshoot this problem?
EDIT: My Work-Around...
I've still got the troublesome project laying around in case someone suggests an answer. I can give it a try to see whether a resolution exists. In the meantime, I couldn't wait for a real resolution so I've taken a work-around.
What I've done is started from scratch with brand-new VS2010/.NET 4 web application projects and moved my source code files over into the new projects piece by piece. There are a few salient differences between the busted-down solution (.sln) and the work-around solution. These are:
- The work-around has one solution (.sln) per project. The problem solution had two web applications and three EF4 data library projects in a single .sln.
- The work-around solution was started from a green field (empty ASP.NET Web Application) template within VS2010 and targeting .NET 4.0 from the outset. The problem solution had parts that began life in VS2008 and originally targeted .NET 2.0.
- The work-around project completely avoids any hint of an App_Code folder. The problem solution had a project with an App_Code folder containing a few utility classes. I'm not sure that this makes the slightest difference, but I did run across at least one posting that开发者_Python百科 suggested the compiler might be confused by a code folder called App_Code in a web application project.
"I gave up and started over" is not much of a resolution to a problem, but I thought I would leave it here, along with this question - in case someone happens by with a solution or in case it is at all helpful to the next person with the same problem.
I'm not usually one for answering my own questions. However, this question has been open with no answers for over a month. It's had a decent number of views, which makes me wonder if others might not have the same problem. Since I've finally found the solution, with the help of some direct support from Microsoft, I thought I would document my solution in case it helps the next person to stumble on this error.
So it turns out that web services is a red herring with this problem. The real crux of the issue is the runtime CS0234 error relating to a referenced type. It can also manifest itself as a runtime CS0103 error too, as I found out the hard way.
I mentioned in my question that I found a work-around. The work-around eventually stopped working and I was out of the water on this project. I contacted Microsoft for support and after four days with my source code they came back to me with a solution.
The problem was related to my compiler configuration for target platform.
Due to some agony that I've suffered in the past over deploying multi-assembly applications on the desktop, I have gotten into the habit of changing my build configurations from Any Platform
to x86
.
This can apparently mess up your compile for an ASP.NET web application. That smells badly like a Visual Studio bug to me, but nevertheless, the solution to my runtime error was to go to the Solution Properties (not project properties) and to select Any Platform
for the build target.
I hope this saves someone some aggravation. If anybody has a reasonable explanation as to why this is not a VS bug or what is going on under the covers, I would be interested to hear it and I promise to upvote you for your trouble!
精彩评论