我有一个代码,但无法让它工作。 我有一个带有命名空间的一个.vb站点,一个Class和一个Sub。 然后在我的index.aspx网站上我不能称这个子 这2个站点位于我的项目的根目录中,项目的名称是CalendarWeek
我的WeekController.vb是
Imports System
Imports System.Web.UI.WebControls.Calendar
Imports System.Globalization
Namespace CalendarWeekController
Public Class WeekShow
Shared Sub Main()
' Gets the Calendar instance associated with a CultureInfo.
Dim myCI As New CultureInfo("da-DK")
Dim myCal As Calendar = myCI.Calendar
' Gets the DTFI properties required by GetWeekOfYear.
Dim myCWR As CalendarWeekRule = myCI.DateTimeFormat.CalendarWeekRule
Dim myFirstDOW As DayOfWeek = myCI.DateTimeFormat.FirstDayOfWeek
' Displays the number of the current week relative to the beginning of the year.
Console.WriteLine("The CalendarWeekRule used for the en-US culture is {0}.", myCWR)
Console.WriteLine("The FirstDayOfWeek used for the en-US culture is {0}.", myFirstDOW)
Console.WriteLine("Therefore, the current week is Week {0} of the current year.", myCal.GetWeekOfYear(DateTime.Now, myCWR, myFirstDOW))
' Displays the total number of weeks in the current year.
Dim LastDay = New System.DateTime(DateTime.Now.Year, 12, 31)
Console.WriteLine("There are {0} weeks in the current year ({1}).", myCal.GetWeekOfYear(LastDay, myCWR, myFirstDOW), LastDay.Year)
End Sub 'Main
End Class
结束命名空间
我的index.aspx是
<%@ Import Namespace="CalendarWeekController" %>
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="index.aspx.vb" Inherits="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<%
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Me.IsPostBack = False Then
Call WeekShow(Sub Main)
End If
End Sub
%>
</div>
</form>
</body>
</html>
运行网站时出现此错误。 说明:解析为此请求提供服务所需的资源时发生错误。请查看以下特定的解析错误详细信息并相应地修改源文件。
分析程序错误消息:无法加载类型“CalendarWeek.CalendarWeekController”。
来源错误:
第1行:&lt;%@ Import Namespace =“CalendarWeekController”%&gt; 第2行:&lt;%@ Page Language =“vb”AutoEventWireup =“false”Inherits =“CalendarWeek.CalendarWeekController”%&gt; 第3行: 第4行:
答案 0 :(得分:0)
您必须使用Classname.Subname
调用共享潜水艇。
在你的情况下:
WeekShow.Main()