同一个目录下三个文件与一个bin文件夹.
test.aspx文件内容如下:<%@ Page Language="C#" Inherits="ClassTest.UI"%>
<html>
<body>
<asp:Label id="Msg" runat="server"/>
</body>
</html>
__________________________________________________
UI.cs文件内容如下:using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;
//同一namespace不需要using
namespace ClassTest
{
public class UI : Page
{
protected Label Msg;
private void Page_Load(object sender,EventArgs e){
Config c = new Config();
Msg.Text = c.ConnString();
}
}
}
____________________________________________
Configuration.cs文件内容如下:using System;
using System.Configuration;
using System.Collections;
namespace ClassTest
{
public class Config
{
public string ConnString()
{
return ConfigurationSettings.AppSettings["ConnectionString"];
}
}
}
_________________________________________________
web.config文件内容如下:<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="ConnectionString"
value="test success" />
</appSettings>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>
_________________________________________
bin文件夹中test.dll文件是这样编译的:csc /t:library /out:bin/test.dll /r:system.dll,system.web.dll,system.data.dll,system.xml.dll Configuration.cs UI.cs___________________________________________问题出现如下:没有装VS.NET,出现 访问test.aspx时出现未能加载类型“test.UI" ;装了VS后,运行正常.请问这是什么原因呀?
test.aspx文件内容如下:<%@ Page Language="C#" Inherits="ClassTest.UI"%>
<html>
<body>
<asp:Label id="Msg" runat="server"/>
</body>
</html>
__________________________________________________
UI.cs文件内容如下:using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;
//同一namespace不需要using
namespace ClassTest
{
public class UI : Page
{
protected Label Msg;
private void Page_Load(object sender,EventArgs e){
Config c = new Config();
Msg.Text = c.ConnString();
}
}
}
____________________________________________
Configuration.cs文件内容如下:using System;
using System.Configuration;
using System.Collections;
namespace ClassTest
{
public class Config
{
public string ConnString()
{
return ConfigurationSettings.AppSettings["ConnectionString"];
}
}
}
_________________________________________________
web.config文件内容如下:<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="ConnectionString"
value="test success" />
</appSettings>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>
_________________________________________
bin文件夹中test.dll文件是这样编译的:csc /t:library /out:bin/test.dll /r:system.dll,system.web.dll,system.data.dll,system.xml.dll Configuration.cs UI.cs___________________________________________问题出现如下:没有装VS.NET,出现 访问test.aspx时出现未能加载类型“test.UI" ;装了VS后,运行正常.请问这是什么原因呀?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货