2011-01-27 37 views
0

我得到下面當我嘗試usign的XmlTextWriter的在我的VB aspx頁面XmlTextWriter的在我的VB .asp頁文字

描述的錯誤不工作 來處理這個請求。請查看 以下具體錯誤詳情 並適當修改您的源代碼 。

編譯器錯誤消息:BC30002:類型 'XmlTextWriter'未定義。

我正在使用的代碼是.aspx頁內的<%%內部>字面

昏暗瓦特作爲XmlTextWriter的=新 的XmlTextWriter( 「myxmlfile.xml」)

我的頁面標題也是這樣

<%@頁面語言= 「VB」 AutoEventWireup = 「假」 跡= 「真」 的EnableViewState = 「真」 %> <%@導入 命名空間= 「System.Data」 %> <%@導入 命名空間= 「的System.Xml」 %>

任何人都可以解釋爲什麼嗎?

回答

2

正如MSDN提到,XmlTextWriter類是System.Xml命名空間中定義:

XmlTextWriter

所以,你應該添加

進口的System.Xml

指令到文件後面的代碼的頭部,並確保System.xml.dll被您的Web應用程序引用。

+0

嗨DevExpress團隊,我沒有使用代碼背後,這是一個避免代碼背後的框架的一部分。我在頁面中添加命名空間爲「<%@ Import Namespace =」System.Xml「%>」,它仍然無法正常工作,爲什麼? – 2011-02-07 14:39:19

0

的XmlTextWriter其實需要兩個值,試試這個...

<%@ Page Language="vb" AutoEventWireup="false" Trace="True" EnableViewState="True" %> 
<%@ Import Namespace="System.Data" %> 
<%@ Import Namespace="System.Xml" %> 
<% Dim w As New XmlTextWriter("myxmlfile.xml", System.Text.Encoding.ASCII)%> 

如果不工作,也許您有overriting對System.Xml類的全局XML命名空間,在這種情況下,嘗試

<%@ Page Language="vb" AutoEventWireup="false" Trace="True" EnableViewState="True" %> 
<% Dim w As New System.Xml.XmlTextWriter("myxmlfile.xml", System.Text.Encoding.ASCII)%>