vb.net ASP.net 中的错误:BC30037:字符无效

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24115131/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 17:40:31  来源:igfitidea点击:

Error in ASP.net : BC30037: Character is not valid

asp.netvb.net

提问by Anjum

I have started learning asp.net. I went through basics and now i am started to build small application. I am using VS 2012 and created Empty Web Application Project with VB.

我已经开始学习asp.net。我完成了基础知识,现在我开始构建小型应用程序。我正在使用 VS 2012 并使用 VB 创建了 Empty Web Application Project。

I can see web.config created automatically and following are the line written in it :

我可以看到 web.config 自动创建,以下是其中写的行:

<?xml version="1.0"?>

<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->

<configuration>
    <system.web>
      <compilation debug="true" strict="false" explicit="true" targetFramework="4.5" />
      <httpRuntime targetFramework="4.5"  />
    </system.web>

</configuration>

I created Default.aspx file and wrote following lines of code :

我创建了 Default.aspx 文件并编写了以下代码行:

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" %>

<%
    HelloWorldLabel.Text = "Hello, world!";
%>


<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Label runat="server" id="HelloWorldLabel"></asp:Label>
    </div>
    </form>
</body>
</html>

When I am running this application on browsers, I am getting following error that page :

当我在浏览器上运行此应用程序时,该页面出现以下错误:

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

Compiler Error Message: BC30037: Character is not valid.

Source Error:


Line 2:  
Line 3:  <%
Line 4:      HelloWorldLabel.Text = "Hello, world!";
Line 5:  %>
Line 6:  

Source File: c:\users\anjum.banaras\documents\visual studio 2012\Projects\Students\Students\Default.aspx    Line: 4 

Can any one help me on this ? I am just beginner on asp.net. Your help can save lots of my time.

谁可以帮我这个事 ?我只是asp.net 的初学者。你的帮助可以节省我很多时间。

Thanking you in advance !!

提前谢谢你!!

回答by Anders Abel

You've set the programming language of the page to VB (Visual Basic), but the line it is complaining about is written in C# syntax. Either change the line to be valid VB code:

您已将页面的编程语言设置为 VB (Visual Basic),但它所抱怨的行是用 C# 语法编写的。要么将该行更改为有效的 VB 代码:

HelloWorldLabel.Text = "Hello, world!"

(I think that removing the ;is all that's needed, but I never code VB so I'm not sure)

(我认为只需要删除;,但我从不编写 VB 代码,所以我不确定)

or change the page language to C#:

或将页面语言更改为 C#:

<%@ Page Language="c#" AutoEventWireup="false" CodeBehind="Default.aspx.vb" %>

回答by Abhishek

I was getting this error since my designer file was missing from the solution (I don't know how,seriously). So try adding a designer file for the aspx file in the solution; it worked for me.

我收到此错误,因为我的设计器文件从解决方案中丢失(我不知道是怎么回事,说真的)。所以尝试在解决方案中为aspx文件添加一个设计器文件;它对我有用。