Guest User

Untitled

a guest
Mar 14th, 2016
92
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <sup>*TLDR; - Work in progress*</sup>
  2.  
  3. ###What Causes This error?###
  4.  
  5. >Server.CreateObject Failed
  6.  
  7. is caused most commonly when Web Applications are moved from one Web Server to another without an understanding on external COM components that are in use and registered with the Web server.
  8.  
  9. ###Identifying the Source of the Error###
  10.  
  11. If you are using COM components inside a ASP Web application you will see a line like this
  12.  
  13. <!-- language-all: lang-vb -->
  14.  
  15. set g_pcmsrv=Server.CreateObject("PCMServer.PCMServer")
  16.  
  17. Usually the error will point the `Set` line which makes identifying the cause easier *(luckily you have some nice trace code in place so it's even better)*.
  18.  
  19. ###What If You Don't Know Where the DLL Is Located?###
  20.  
  21. >**Note:** Please be careful when accessing the Windows Registry as it is very easier to inadvertently make changes that have serious consequences for the Operating System and in extreme cases will require a system restore or re-install / repair.
  22.  
  23. The string inside the `CreateObject` method is known as a `ProgId` and is used as an identifier to a key inside the Windows Registry that can be found inside the
  24.  
  25. >Windows Registry can be browsed in most versions of Windows using the `regedit.exe` also known as the Registry Editor. Be very careful when using this tool to browse the Windows Registry.
  26.  
  27. KEY_CLASSES_ROOT
  28.  
  29. and by extension
  30.  
  31. HKEY_LOCAL_MACHINE\Classes
  32.  
  33. Whenever the ASP processor encountered a `ProgId` it attempts to talk to the Windows Registry and find a corresponding key that denotes the location of the registered COM accessible DLL.
  34.  
  35. HKEY_CLASSES_ROOT\PCMServer.PCMServer
  36.  
  37. A common approach to this is the key contains a subkey called `CLSID` which points to the Class GUID for the associated registered DLL. Once the GUID key is located in the
  38.  
  39. HKEY_CLASSES_ROOT
  40.  
  41. hive it can be used to find the location by looking in the subkey
  42.  
  43. HKEY_CLASSES_ROOT\{GUID from CLSID}\InprocServer32
  44.  
  45. and the location will be stored in the `default` string value.
  46.  
  47. **Example Using the `ProgId` `Scripting.FileSystemObject`**
  48.  
  49. 1. Locate `Scripting.FileSystemObject` subkey in `HKEY_CLASSES_ROOT`
  50.  
  51. HKEY_CLASSES_ROOT\Scripting.FilesystemObject
  52.  
  53. 2. Identify GUID from subkey `CLSID`
  54.  
  55. HKEY_CLASSES_ROOT\Scripting.FilesystemObject\CLSID
  56.  
  57. (default) - "{0D43FE01-F093-11CF-8940-00A0C9054228}"
  58.  
  59. 3. Use GUID to find registered DLL subkey in `HKEY_CLASSES_ROOT`
  60.  
  61. HKEY_CLASSES_ROOT\{0D43FE01-F093-11CF-8940-00A0C9054228}
  62.  
  63. 4. Check subkey `InprocServer32` for DLL location
  64.  
  65. HKEY_CLASSES_ROOT\{0D43FE01-F093-11CF-8940-00A0C9054228}\InprocServer32
  66. (default) - "C:\Windows\System32\scrrun.dll"
  67.  
  68. ###No `ProgId` for `PCMServer.PCMServer` in the Registry?###
  69.  
  70. If you cannot find the corresponding `ProgId` in the registry it is likely due to one of two reasons we will elaborate on here.
  71.  
  72. 1. The DLL is not registered.
  73. 2. The DLL is registered in the wrong area.
  74.  
  75. ###How to register COM DLL with Windows###
  76.  
  77. COM DLLs can be registered and have the corresponding Registry entries created by running the `regsvr32.exe` tool from the Windows Command Prompt using elevated permissions *(this varies from version to version of Windows)*.
  78.  
  79. Before we continue though the architecture of both the Operating System and the mode used by the ASP Web application are very important.
  80.  
  81. Most newer hardware is 64 Bit this creates a conundrum in Windows as it now has to support newer 64 bit architecture and still maintain support for 32 bit architecture. The solution Microsoft came up with was to split the OS in two, so we have 64 bit elements and 32 bit elements. The main OS programs are broken down into two folders *(only on 64 bit OS because a 32 Bit OS doesn't have to contend with 64 Bit, even if the hardware is capable of it)*.
  82.  
  83. >**Note:** On 32 Bit only systems just use the 64 Bit locations for both System Files and the Windows Registry.
  84.  
  85. On a 64 Bit OS the System Programs are located in
  86.  
  87. 1. For 64 Bit programs
  88.  
  89. %SystemRoot%\System32\
  90. 2. For 32 Bit programs
  91.  
  92. %SystemRoot%\SysWOW64\
  93.  
  94. This is also the same for the Windows Registry which on 64 Bit Windows has two locations
  95.  
  96. 1. 64 Bit
  97.  
  98. HKEY_CLASSES_ROOT</pre>
  99.  
  100. 2. 32 Bit
  101.  
  102. HKEY_CLASSES_ROOT\Wow6432Node
  103.  
  104. So for example on a 64 Bit version of Windows the following command will register the `PCMSRV32.DLL` in the 32 Bit Registry and create the associated COM DLL registry keys.
  105.  
  106.  
  107. C:\Windows\SysWOW64&gt;regsvr32 "C:\Windows\PCMSRV32.DLL"
RAW Paste Data