Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 339
Simon Kiely Avatar asked Sep 10 '26 15:09

Simon Kiely


2 Answers

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.

like image 111
C-F Avatar answered Sep 13 '26 03:09

C-F


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

like image 35
SLaks Avatar answered Sep 13 '26 03:09

SLaks



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!