Alternative to Server.CreateObject - asp-classic

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?

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

Related

Server.MapPath() on IIS8.5 in Windows 2012 Server giving Object Doesnt Support this Property or method

I am trying to implement a Classic ASP Project on II8.5 on Windows Server 2012 R2.
While launching the DashBoard.asp, Getting error
Object Doesnt Support Property or method : Server.MapPath("\")
The Project is working fine on IIS7.5 on Windows 2008 Server R2. But Failing on II8.5. Have Done all the respective setting Required for Classic ASP to execute on IIS8.5 server, Still getting the same issue.
Can Anybody Guide, Why Server Object Methods are not getting recognized on IIS8.5?
Edit: New approach
looking at the code, you have following line that fails in global.asa Application_OnStart:
Call setXDefInApplicationScope(Server.MapPath("fb/infra/server/XDef"))
Maybe setXDefInApplicationScope is not defined in this context, but resides in an included file that does not apply in Application_OnStart
Edit: second option (ruled out by comments)
I would guess, you have created a variable named "server" in the context, that overwrites the Server object you think you are using.
class clsServer
public foo
end class
dim server
set server = new clsServer
Response.Write Server.MapPath("/") ' will raise the error
I guess, it may not be that obvious in your setup, could be in any included file. More importantly, if you did not specify option explicit as you should, there must not even exist a dim.

Locating the source DLL behind a COM+ ProgId

I've never really had to debug Classic ASP, so this is a little rough and most likely a poor question, but I have done as much research as I could before asking.
I have a request to identify what code prints to a printer, and re-use that code in a new page that someone has built.
While trying to identify that, I've stumbled on a few things that I don't understand, but namely one big one.
The gist is, people can order cookies from the cafeteria, and when they submit, it shows a confirmation page and that order is sent to a printer.
To get a list of cookie options, there's a Server Object created, and from there a method exists, but I cannot identify where it is or where I should be looking. Here's the code:
<%
On error resume next
Const CATAGORY_COOKIE = 1
Dim cookieNames
Dim objCookie
Dim Count
Set objCookie = Server.CreateObject("CookieOrder.CookieRequest")
if objCookie Is Nothing then
Response.Write "Error"
Response.End
End if
cookieNames = objCookie.getAvailable_Item_Names(CATAGORY_COOKIE)
Count = objCookie.Count
Dim sz
sz = Split(cookieNames, ";")
Set objCookie = Nothing
%>
How do I identify what the Server Object is? There's a .dll file that contains binary, but I'm not familiar with how that could be utilized.
I have tried to follow the browser dev tools, but they really haven't been too helpful in this aspect.
I am hoping that learning how this code is executing or where it's being executed I will figure out my other problems.
Bit of background
The project is using a COM+ component. These are defined in Classic ASP using the syntax;
Set obj = Server.CreateObject("[insert COM+ ProgId]")
In this project you are using a component registered with the ProgId
CookieOrder.CookieRequest
There are many out of the box COM+ components available to Classic ASP that provide a lot of common functionality such as;
Visual Basic Scripting Runtime
ActiveX Data Objects
There is also the ability to create COM+ components for use with Classic ASP using languages common to the time like Visual Basic, Visual C++ and more recently using the .NET Framework (C#, VB.NET).
How to locate COM+ libraries
NOTE: Please be careful when accessing the registry as modifying or deleting keys could lead to a corrupt operating system.
Also for the purposes of this guide will use the Scripting.Dictionary ProgId.
The key is using the ProgId to find an elusive COM+ library.
Start %SystemRoot%\system32\regedit.exe (will work in most Windows Operating Systems)
Navigate to the HKEY_CLASS_ROOT hive and select it, then press Ctrl + F to open the Find dialog box.
In Find what type the ProgId in this case Scripting.Dictionary and make sure in look at only Key is checked then press Find or Find Next.
If a ProgId key is found expand to the key and locate the CLSID key which contains a (Default) REG_SZ with the value of the CLSID in the case of this example {EE09B103-97E0-11CF-978F-00A02463E06F}. Double click this value to bring up the Edit String dialog copy the value into your clipboard.
Return to the HKEY_CLASS_ROOT key and use Find to search for the CLSID value which in this example is {EE09B103-97E0-11CF-978F-00A02463E06F} and again make sure Look at has only Key checked then press Find or Find Next.
If the key is found expand and locate the InprocServer32 key in it you will find the location of DLL in the (Default) REG_SZ value. In this example that is C:\Windows\System32\scrrun.dll (this will be different depending on installation location and OS)
What about decompiling?
There's a lot of assumption in the comments about the compiler used to compile the DLL (mainly .NET), but the best way to check is to use one of the many programs out there in the public domain designed for this purpose.
There is a specific question on SO that deals with this;
Answer by #simon-mᶜkenzie to Identifying the origin of a DLL

ActiveX cannot create Object: Object required 424 error

In classic ASP, I am trying to create an ActiveX object. Basically, I am trying to create a Crystsal Reports Runtime object.
Dim oCR = CreateObject("CrystalDesignRunTime.Application")
I am getting "ActiveX cannot create object" error.
This works fine on another developer machine. And both developer machines have Windows 7 VB 6 EE with SP 6 and Crystal Reports Developer edition 13.0.
Help needed :-(
If this is classic ASP, with VBScript, then:
Dim oCR = CreateObject("CrystalDesignRunTime.Application")
... is definitely not going to work. This should be:
Dim oCR
Set oCR = CreateObject("CrystalDesignRunTime.Application")
As for the "ActiveX cannot create object" error, this is due to an installation failure of the Crystal Reports component. I would recommend you first try reinstalling the component. Failing that, look in the installation folder, and work out which file implements the ActiveX component (crtslv.dll ?). Then go to a command line and type:
regsvr32.exe "<component DLL file>"

using asp.net dll in classic asp

I've followed this: http://www.codeproject.com/Articles/19535/NET-COM-Interop-Component-with-Classic-ASP-Part-I & http://bruceburge.com/2009/06/11/sharing-net-libary-dlls-between-asp-classic-and-aspnet/ to use asp.net dll in classic asp.
Step 7 listed in first URL didn't work me hence I followed steps given in second URL to to create installation. It works & can see URL in GAC. Unfortunately, it is not working in classic asp.
I tried "regsvcs" at command prompt but didn't work. have developed using C#
Anybody knows what I'm missing?
Update: I could see component under Component Services. I don't see method name under Interfaces & creating object of component is not working. am getting this error:
Expected end of statement on line:
set obj= server.CreateObject("my_dll_New.Class1");

Server.CreateObject Failed in Classic ASP

I created the ASP.NET dll with one function that i need to use in Classic ASP page.
I used the below code for creating object in classic asp page
set PeopleSoft = server.createobject("OPS.PSL")
I am getting the below error while executing
Server object error 'ASP 0177 : 80070002'
Server.CreateObject Failed
I searched in stackoverflow i saw some solution. By enabling the "Make assembly COM-visible" and "Register for COM interop".
Please Help me to come out from this issue
You have to register your DLL first, and if the problem persists, do this:
Locate and then click the following registry subkey:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\
FeatureControl\FEATURE_IGNORE_ZONES_INITIALIZATION_FAILURE_KB945701
Note If the FEATURE_IGNORE_ZONES_INITIALIZATION_FAILURE_KB945701 subkey does not exist, you must manually create it. If you're using a 64 bit OS, you may need to use HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\ FeatureControl\FEATURE_IGNORE_ZONES_INITIALIZATION_FAILURE_KB945701 instead
Right-click FEATURE_IGNORE_ZONES_INITIALIZATION_FAILURE_KB945701,
point to New, and then click DWORD Value
Type w3wp.exe to name the new registry entry, and then press ENTER.
Right-click w3wp.exe, and then click Modify.
In the Value data box, type 1, and then click OK.
After setting this registry key, a simple app pool restart will apply the change. No longer will your .NET COM components randomly stop working with no real solution except shuffling application pools!
Did you register your dll with regasm.exe on your server ?
http://msdn.microsoft.com/en-us/library/tzat5yw6%28VS.71%29.aspx
I had this problem. When you register .NET COM modules you must use regasm and if you want to call them from applications like IIS you must use /codebase with this command:
regasm yourfilename.dll /codebase
I just had this error appear on a site that had been running perfectly for years. It seems a DLL had somehow become unregistered. It was an unmanaged DLL so I was able to re-register it using regsvr32:
%SystemRoot%\Microsoft.NET\Framework\v2.0.50727\regsvr32 "C:\path\to\myAssembly.dll"
(Also see the difference between regasm and regsvr32)
On this website :
http://connect.microsoft.com/VisualStudio/feedback/details/294241/kb937143-breaks-asp-to-net-com-interop
They fix the problem with giving read access to IUSR on HKEY_USERS\S-1-5-20\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones.
Run this from the command prompt (replace myassembly.dll with your assembly path):
%SystemRoot%\Microsoft.NET\Framework\v2.0.50727\regasm.exe myassembly.dll /codebase
I faced a similar issue and after much research i found the solution ,check if its working for you.
Remote scripting causes tons of errors with different IE versions. If your are passing control from one page to another and creating a new object from there you will get this kind of unable to create object error.
Example:
page x.asp--
function1call()
function2call()
further in page x.asp--
function1call(){
var rs_obj = RSGetASPObject("some-object");
----some other things---
frmPost.action = "someplace.asp";
frmPost.submit();
}
function2call(){
var rs_obj = RSGetASPObject("some-object1"); //you wont be able to create
//this object
----some other things---
}
It seems like the remoteScripting object is not getting initiated . As function1call() calls frmPost.submit().
If you combine these 2 functions it will start to work. I.E
page x.asp--
function1call(){
var rs_obj = RSGetASPObject("some-object");
var rs_obj = RSGetASPObject("some-object1");
----some other things---
frmPost.action = "someplace.asp";
frmPost.submit();
}
There is another reason you might get the error "Server.CreateObject Failed". A COM Visible DLL does not behave the same as a regular .NET DLL when it is being loaded by COM. You can't expect it to load other DLLs that are sitting in the same directory as your DLL, or downloaded through the Nuget package manager. If you want to load other DLLs you have to register them in the global assembly cache (GAC).
see: https://stackoverflow.com/a/23902131/2616170
If the assembly doesn't have a strong name then you won't be able to register it in the GAC.

Resources