开发者

Create Page Scope Object in WinCE ASP

I have to create a page scope COM object in ASP for WIN CE device. The Win CE device supports only httpd server.

I tried to create the com object with the statement Server.CreateObject to give it page sco开发者_JAVA百科pe. But I am getting the following error

Parse error in script 
Microsoft VBScript runtime error: '800a01b6' 
Description: Object doesn't support this property or method: 'Server.CreateObject' 
In file: /Polycold_WebGUI/PolyCold_system_home.asp 
On line: 13 

How can I correct this problems?

Can I give Page Scope for COM object in Win CE ASP?

Result The method GetUnitModelNumber increments a member variable and returns the result. Initially the value is 0. Each time GetUnitModelNumber is executed the value will increment. As the default object life time is page scope, My expectation is that the second CreateObject call will return the object already created and the value will increment. But I am getting 0 when I executed the following piece of code. What is wrong with the following code?

Dim objAd1,man
 Set objAd1 = CreateObject("PolyColdDeviceCmds.SystemCmds")
 man1 = objAd1.GetUnitModelNumber()
 Set objAd1 = CreateObject("PolyColdDeviceCmds.SystemCmds")
 man2 = objAd1.GetUnitModelNumber()
 Response.Write(man2)
 Response.Write("<script language='javascript'> alert("""&man2&""");</script>")


How can I correct these problems?

As I mentioned here, you cannot use Server.CreateObject in asp-WinCE, you should use just CreateObject instead. Only MapPath and URLEncode are supported by the Server object in asp-WinCE. See this page in MSDN for details. From this page:

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

Server method - Windows CE implementation

ScriptTimeout: Not supported.
CreateObject: Not supported.
Execute: Not supported.
GetLastError: Not supported.
HTMLEncode: Not supported.
MapPath: Fully supported.
Transfer: Not supported.
URLEncode: Fully supported.

Can I give Page Scope for COM object in Win CE ASP?

Page Scope is the default behaviour for any COM object created within an asp page. See this MSDN reference for details. From this page:

An object that you create by using Server.CreateObject or the HTML tag on an ASP page exists for the duration of that page.

This page talks about classic asp in Windows (desktop), not Windows CE. So for Windows CE just replace Server.CreateObject by CreateObject and you should get the same results.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜