Parser Error : Could not create type

I don’t know if this is dragging something up from the dim and distant past, but I had this problem. I fixed it. So I thought I’d to share it.

When you create a web service in Visual Studio (I’m using 2010 but I’d imagine it’s the same for others), it creates a file called Service1.asmx

You will be tempted to rename it to MyService.asmx (or whatever).

Then you’ll look inside and see the line

public class Service1: System.Web.Services.WebService

which you’ll change to

public class MyService: System.Web.Services.WebService

and then when you try running it, you get the error

Could not create type ‘MyProject.MyService’

Because it still thinks the class is called Service1.

If you right click the .asmx file and select view markup, you’ll see it still says:

<%@ WebService Language="C#" CodeBehind="MyService.asmx.cs" Class="MyProject.Service1" %>

change it to

<%@ WebService Language="C#" CodeBehind="MyService.asmx.cs" Class="MyProject.MyService" %>

save it, try it.

It worked for me.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)