Server.CreateObject 的替代方案

发布于 2024-08-27 18:14:22 字数 1160 浏览 7 评论 0原文

我正在用经典 ASP(在 Windows CE 上)编写一个导航系统。 我需要一种根据调用脚本动态包含导航文件的方法。 我提出了以下代码,其中包含位于调用脚本的文件夹中的 nav.inc,以允许不同的文件夹具有不同的导航功能。

这在我的 Windows 测试机上运行良好,但在我部署到 Windows CE 时则不然。代码和错误如下所示。如果有人可以提供解决方法或任何反馈,那就太好了。感谢

代码:

<% 
   'Get path name
   Dim i
   fullname = Request.ServerVariables("SCRIPT_NAME")
   my_array=split(fullname,"/")
   fname=my_array(ubound(my_array))
   fname = ""

   For i = 0 to ubound(my_array) - 1
    fname = fname & my_array(i) & "/"
   Next

   fname = fname & "nav.inc"

   Set fs=Server.CreateObject("Scripting.FileSystemObject")

   If (fs.FileExists(Server.MapPath(fname)))=true Then
    Server.Execute(fname)
   End If
  %>

错误:

Microsoft VBScript 运行时错误: '800a01b6'

描述:对象不支持 这个属性或方法: '服务器.CreateObject'

如果我将代码更改为仅显示 Set fs=CreateObject("Scripting.FileSystemObject") 我收到以下错误:

Microsoft VBScript 运行时错误: '800a01ad'

描述:ActiveX组件不能 创建对象: '脚本.FileSystemObject'

更新 我刚刚尝试直接运行 Server.Execute,但也失败了。看来我无权访问服务器对象。有没有解决这个问题的方法?

I am writing a navigation system in classic ASP (on Windows CE).
I require a way to dynamically include navigation files based on the calling script.
I have come up with the following code that includes nav.inc that is located in the folder of the calling script to allow different folders to have different navigational features.

This works fine on my Windows test machine but NOT when I deploy to Windows CE. The code and error is shown below. If anyone can provide a work around or any feedback that would be great. Thanks

Code:

<% 
   'Get path name
   Dim i
   fullname = Request.ServerVariables("SCRIPT_NAME")
   my_array=split(fullname,"/")
   fname=my_array(ubound(my_array))
   fname = ""

   For i = 0 to ubound(my_array) - 1
    fname = fname & my_array(i) & "/"
   Next

   fname = fname & "nav.inc"

   Set fs=Server.CreateObject("Scripting.FileSystemObject")

   If (fs.FileExists(Server.MapPath(fname)))=true Then
    Server.Execute(fname)
   End If
  %>

Error:

Microsoft VBScript runtime error:
'800a01b6'

Description: Object doesn't support
this property or method:
'Server.CreateObject'

If I alter the code to just say Set fs=CreateObject("Scripting.FileSystemObject") I get the following error:

Microsoft VBScript runtime error:
'800a01ad'

Description: ActiveX component can't
create object:
'Scripting.FileSystemObject'

Update I have just tried running Server.Execute directly and this fails too. It looks like I do not have any access to the Server object. Is there any work around for this as well?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

dawn曙光 2024-09-03 18:14:22

Windows CE 不支持 CreateObjectExecute
也不支持 标签,所以,抱歉,您运气不好。

Server Object Implementation
---------------------------

The Server object provides access to methods and properties on the server. 
Most of these methods and properties serve as utility functions.

Server method  Windows CE implementation
-----------------------------------------
CreateObject   Not supported
Execute        Not supported
GetLastError   Not supported
HTMLEncode     Not supported
MapPath        Fully supported
ScriptTimeout  Not supported
Transfer       Not supported
URLEncode      Fully supported

来源

CreateObject and Execute are not supported in Windows CE.
The <OBJECT> tag is not supported also, so, you are out of luck, sorry.

Server Object Implementation
---------------------------

The Server object provides access to methods and properties on the server. 
Most of these methods and properties serve as utility functions.

Server method  Windows CE implementation
-----------------------------------------
CreateObject   Not supported
Execute        Not supported
GetLastError   Not supported
HTMLEncode     Not supported
MapPath        Fully supported
ScriptTimeout  Not supported
Transfer       Not supported
URLEncode      Fully supported

Source

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文