Parser Error Message: Could not create type 'WebService.asmx.cs'

12,076

Solution 1

The correct class name is "SearchService". You specified a file name.

Solution 2

I've come across this error using Visual Studio Development Server when my project output directory was not bin\

One of my DLLs has versions for different platforms (x86, x64), so I created corresponding configurations, and they got by default output directories like this: "bin\x86\Dedug", "bin\x64\Debug". But the Visual Studio Development Server still tried to load binaries from the bin\ folder and of course failed.

I fixed the issue by specifying bin\ output folder in my debug configurations.

Solution 3

class="..." expects a fully-qualified class-name, not a filename.

Share:
12,076
Simon Kiely
Author by

Simon Kiely

Masters machine learning student who doesn't know Python. At all.

Updated on June 04, 2022

Comments

  • Simon Kiely
    Simon Kiely almost 2 years

    I am following this tutorial to create dynamic search results from an SQL server as a user types. It is telling me to create a .asmx file, which is not a format I have ever worked with before. I now have a .asmx and .asmx.cs file. Here is the code I have thus far :

    WebService.asmx.cs :

    public class SearchService : WebService
    {
      [WebMethod]
      public searchResult[] Search(string txtSearch)
      {
    //Declare collection of searchResult
            List resultList = new List();
            var db = Database.Open("mPlan");
            var result = db.Query("SELECT * from Users where Username like '%" + txtSearch + "%'");
           try
           {
               foreach(var record in result)
                {
                   searchResult result = new searchResult();
                   result.Username = ["Username"].ToString();
                   resultList.Add(result);
               }
               return resultList.ToArray();
           }
           catch
           {
               return null;
           }
      }}
    

    WebService.asmx :

    <%@ WebService Language="C#" class="WebService" %>
    using System;
    using System.Collections.Generic;
    using System.Web;
    using System.Web.Services;
    using System.Data.SqlClient;
    
    [System.Web.Script.Services.ScriptService]
    [System.Web.Script.Services.GenerateScriptType(typeof(searchResult))]
    public class searchResult
    {
        public string Title;
        public string img;
        public string href;
    }
    

    Here is my error message, can anyone help me with this please?

    Parser Error Message: Could not create type 'WebService.asmx.cs'

    It highlights line 1 of WebService.asmx as the source of the error.