.NET Web Service "Could not create type"
The markup and code-behind file contents for my .NET开发者_C百科 Web Service are as follows (pretty much what VS generated):
Services.asmx:
<%@ WebService Language="VB" CodeBehind="Services.asmx.vb" Class="Services" %>
Services.asmx.vb:
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
Public Class Services
Inherits System.Web.Services.WebService
<WebMethod()> _
Public Function HelloWorld() As String
Return "Hello World"
End Function
End Class
When I try to access the web service, I get:
Parser Error Message: Could not create type 'Services'
I've tried qualifying the Services class specification in the markup with a namespace, to no avail.
When I put the code-behind in the same file as the .asmx, everything works fine.
So when I change the build configuration to Any CPU, it works because the .dll containing the type ends up in the bin folder. When the build configuration is set to x86, the .dll ends up only in either bin/x86/Debug or bin/x86/Release, where IIS doesn't look. Seems silly. Am I missing something?
I would say it's a problem related with the class name matching a namespace. Have you tried renaming the Services class to something else?
Indeed, I had two folders (x86 and x64) for two configurations, and IIS is looking for dll's only in main bin folder. I copied the dll file and it worked immediately.
I had this problem compiling the web project. Names all matched, worked fine in another solution.
Noticed that it was a 'web' project. Removed project and added it back as existing project, and it came back without being identified as a 'web' project - and then it compiled and ran fine.
精彩评论