关于vs2003生成dll和使用命令行工具生成的dll文件的问题
遇到一个奇怪的问题,比如我在vs2003下面建立了一个新的web工程,工程的名字123,默认名空间为:namespace 456,那么如果生成项目的话,目录下面的所有以vb结尾或者cs结尾的源码都应该被编辑成123.dll放在bin目录下面。现在我在程序目录下面有一个vb文件叫做author.vb程序代码如下:
'------------------------------------------------------------------------------
' <autogenerated>
' This code was generated by a tool.
' Runtime Version: 1.0.3512.0
'
' Changes to this file may cause incorrect behavior and will be lost if
' the code is regenerated.
' </autogenerated>
'------------------------------------------------------------------------------
Option Strict Off
Option Explicit On
Imports System
Imports System.ComponentModel
Imports System.Diagnostics
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Xml.Serialization
Namespace 456
'<remarks/>
<System.Diagnostics.DebuggerStepThroughAttribute(), _
System.ComponentModel.DesignerCategoryAttribute("code"), _
System.Web.Services.WebServiceBindingAttribute(Name:="AuthorsSoap", [Namespace]:="http://www.aspnetsbs.com/webservices/")> _
Public Class Authors
Inherits System.Web.Services.Protocols.SoapHttpClientProtocol
'<remarks/>
Public Sub New()
MyBase.New
Me.Url = "http://localhost/aspnetsbs/Chapter13/AuthorsService.asmx"
End Sub
'<remarks/>
<System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://www.aspnetsbs.com/webservices/GetAuthors", RequestNamespace:="http://www.aspnetsbs.com/webservices/", ResponseNamespace:="http://www.aspnetsbs.com/webservices/", Use:=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle:=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)> _
Public Function GetAuthors() As System.Data.DataSet
Dim results() As Object = Me.Invoke("GetAuthors", New Object(-1) {})
Return CType(results(0),System.Data.DataSet)
End Function
'<remarks/>
Public Function BeginGetAuthors(ByVal callback As System.AsyncCallback, ByVal asyncState As Object) As System.IAsyncResult
Return Me.BeginInvoke("GetAuthors", New Object(-1) {}, callback, asyncState)
End Function
'<remarks/>
Public Function EndGetAuthors(ByVal asyncResult As System.IAsyncResult) As System.Data.DataSet
Dim results() As Object = Me.EndInvoke(asyncResult)
Return CType(results(0),System.Data.DataSet)
End Function
End Class
End Namespace
那么我如果在aspx文件中调用author的话代码如下:
<%@ Page Language="VB" %>
<%@ Import Namespace="456" %>
<html>
<head>
<script runat="server">
Sub Page_Load()
Dim Authors As New Authors()
myGrid.DataSource = Authors.GetAuthors()
DataBind()
End Sub
</script>
</head>
<body>
<asp:datagrid id="myGrid" runat="server"/>
</body>
</html>
总是提示我找不到authors:BC30002: Type 'Authors' is not defined.
可是如果我使用命令行的方式编译author.vb就没有问题
代码如下:
vbc /t:library /r:System.Web.dll /r:System.dll /r:System.Web.Services.dll /r:System.Xml.dll /r:System.Data.dll /out:bin\123.dll Authors.vb Hello.vb
pause
很奇怪,因为我不知道vs2003生成的时候是不是还要在加一次名空间456,因为在项目属性里面有这个设置,为了试验我把author.vb中的namespace 和end namespace去掉,也是找不到。
大家知道vs生成的dll文件是怎么养的命名空间呢?
比如说项目里面设置程序名为123,默认命名空间为456,然后项目文件为author.vb,里面的代码如上,这个时候生成的123.dll中的author类怎么调用??