请大家帮我看看这个could not create type 'service'的问题怎么解决?
我建了个web service,但是当我点生成网站时,出错信息提示说:could not create type 'service',在网上用百度,谷歌查了很久还是没找到解决办法,请大家帮我看看问题到底出在哪里,代码如下:
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Configuration;
using System.Data.SqlClient;
using System.Diagnostics;
[WebService(Namespace = "http://www.contentmaster.com/NorthwindServices")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{
public Service () {
//如果使用设计的组件,请取消注释以下行
//InitializeComponent();
}
/*
[WebMethod]
public string HelloWorld() {
return "Hello World";
}
*/
private void handleWebException(Exception e)
{
EventLog log = new EventLog("Application");
log.Source = "NorthwindServices";
log.WriteEntry(e.Message, EventLogEntryType.Error);
}
[WebMethod]
public decimal HowMuchWillItCost(string productName, int howMany)
{
SqlConnection sqlConn = null;
try
{
ConnectionStringSettings cs =
ConfigurationManager.ConnectionStrings["NorthwindConnectionString"];
string connString = cs.ConnectionString;
sqlConn = new SqlConnection(connString);
SqlCommand sqlCmd = new SqlCommand();
sqlCmd.CommandText = "SELECT UnitPrice FROM Products " +
"WHERE ProductName = '" + productName + "'";
sqlCmd.Connection = sqlConn;
sqlConn.Open();
decimal price = (decimal)sqlCmd.ExecuteScalar();
return price * howMany;
}
catch (Exception e)
{
// Handle the exception
handleWebException(e);
throw new Exception();
}
finally
{
if (sqlConn != null)
sqlConn.Close();
}
}
}
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Configuration;
using System.Data.SqlClient;
using System.Diagnostics;
[WebService(Namespace = "http://www.contentmaster.com/NorthwindServices")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{
public Service () {
//如果使用设计的组件,请取消注释以下行
//InitializeComponent();
}
/*
[WebMethod]
public string HelloWorld() {
return "Hello World";
}
*/
private void handleWebException(Exception e)
{
EventLog log = new EventLog("Application");
log.Source = "NorthwindServices";
log.WriteEntry(e.Message, EventLogEntryType.Error);
}
[WebMethod]
public decimal HowMuchWillItCost(string productName, int howMany)
{
SqlConnection sqlConn = null;
try
{
ConnectionStringSettings cs =
ConfigurationManager.ConnectionStrings["NorthwindConnectionString"];
string connString = cs.ConnectionString;
sqlConn = new SqlConnection(connString);
SqlCommand sqlCmd = new SqlCommand();
sqlCmd.CommandText = "SELECT UnitPrice FROM Products " +
"WHERE ProductName = '" + productName + "'";
sqlCmd.Connection = sqlConn;
sqlConn.Open();
decimal price = (decimal)sqlCmd.ExecuteScalar();
return price * howMany;
}
catch (Exception e)
{
// Handle the exception
handleWebException(e);
throw new Exception();
}
finally
{
if (sqlConn != null)
sqlConn.Close();
}
}
}
...全文
相关推荐
浅析Android Service中实现弹出对话框的坑
主要介绍了Android Service中实现弹出对话框的坑,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
SQL Server Service Broker完整示例
SQL server Service Broker实战
kubernetes-service详解
kubernetes-service详解
MySQL NOT NULL字段无默认值报错解决方案
关系型数据库通过NOT NULL约束确保数据完整性,当字段被定义为NOT NULL且无默认值时,INSERT操作必须显式提供值。MySQL的sql_mode参数(如STRICT_TRANS_TABLES)会严格校验这类约束,这是生产环境推荐配置。在ORM框架如MyBatisPlus中,自动填充机制需要与数据库约束配合,常见的@TableField注解和MetaObjectHandler配置不当会导致'Field doesn't have a default value'报错。合理设置DEFAULT值、检查S
juddi配置资源问题解决
juddi连接mysql没有驱动的解决方法


Web Services
