Webservice Error: Could not create type ‘AWebService’
Description:
This one had me seriously stumped for over an hour.
I had created my webservice code file (.cs) and after creating the .asmx file I got an exception reading, ‘Could not create type ….’ .
My .asmx file contained the following directive :
<%@WebServiceLanguage="C#"CodeBehind="~/App_Code/aWebService.cs" Class="aWebService" %>
See solution below ads
Solution
This error occurs when the code specified by the CodeBehind attribute is enclosed within a namespace.
My code was as follows.
namespace MyWebService
{
public class aWebService : System.Web.Services.WebService
{
public SysAdminSvc()
{
…………. blah blah blah
As you can see my code is within the namespace MyWebService …. PROBLEM !!!
Remove enclosing namespace.(MyWebService)
The correct way of specifying a namespace for this code is using the Webservice attribute as follows.
[WebService(Namespace = "http://www.xhydra.com")]
Yes I know this is a newbie- type error but I am learning a lot of stuff daily.
HAPPY CODING
technorati tags C# .NET, webservices


August 3rd, 2007 at 12:01 am
I have encountered this error several time and the above is just one of the many causes of this error.
August 6th, 2007 at 9:47 pm
I had this exact error, but the cause was not the above - it wasn’t the namespace deal you describe above. There are several possible causes, as Jorge says.
August 7th, 2007 at 5:08 am
The error itself is as specific as stating that ‘car will not start’ .
This article suggests one of the possible causes that car will not start.
If you have checked your car and this is not the reason it wont start then…. why dont you move along then