分析器错误:无法创建类型 [英] Parser Error : Could not create type

查看:301
本文介绍了分析器错误:无法创建类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建Web服务,并将其发布在本地计算机上。然后,我已经上传它的服务器。

I have created webservice and published it on local machine. Then I have uploaded it on server.

现在当我试图访问web服务它提供了以下错误:

Now while I tried to access webservice it gives following error :

分析器错误信息:无法创建类型webservice.myservice

源错误: 1号线:其中,%@ WebService的语言=C#codeBehind =myservice.asmx.cs级=webservice.myservice%>

Source Error: Line 1: <%@ WebService Language="C#" CodeBehind="myservice.asmx.cs" Class="webservice.myservice" %>

我试过<一个href="http://stackoverflow.com/questions/3304214/parser-error-could-not-create-type-webservice1-service1">This链接,但未能解决我的问题。

I tried This link but unable to solve my problem.

我应该怎么办?

推荐答案

说不上来,如果这是拖着东西从朦胧和遥远的过去。但是我有这个问题..固定它..所以我想我会分享

Dunno if this is dragging something up from the dim and distant past.. but I had this problem.. fixed it.. so i thought I'd share

当您创建在Visual Studio的Web服务(我使用的是2010年,但我想像它是相同的其他人),它会创建一个名为 Service1.asmx的

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

您会被(不管或)诱惑,它重命名为 MyService.asmx

You'll 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

那么,当您试图运行它,你得到错误

then when you try running it you get the error

未能创建类型MyProject.MyService

因为这一切仍然认为该类称为服务1。

cos it still thinks the class is called Service1..

如果你右键点击的.asmx 文件,并选择视图的标记,你会看到它还是说

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" %>

将其更改为

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

保存..试试吧..

save it.. try it..

为我工作。

这篇关于分析器错误:无法创建类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆