Geeks With Blogs
Brian Biales because blogging is just the easiest way to remember things

[Update: 4/21/09]
I did get this to work finally.  This article clued me in:

It turns out the server.CreateObject() method takes only one parameter, the name of the object.  But the global CreateObject function takes two parameters.  The second parameter being the server on which the object should be run.  So not only did I need to add the server name as a second parameter, but I also had to use the global CreateObject() function to create the object. 

In addition, I mention below the need to change the "metabase" to allow out of proc servers.  This is no longer necessary, and was not part of the problem...

What you do need to do, though, is make sure that this is added to IIS as an "application" not simply a virtual directory.  Otherwise the global.asa file will not be run, and so the code below that creates this object when a new session starts won't be run.

Oh, and one other thing :-)  If IIS 7 is running on a 64bit machine, and you use 32 bit OCX's, you'll need to change the application pool parameter to allow 32bit code to run.

[End of Update: 4/21/09]

I have some old ASP pages that utilize a COM object, which it initializes in the global.asa file as follows:


Sub Session_OnStart

Set Session("MyObject") = server.createobject("MyComServer.MyObject")
End Sub


The web server (IIS) happens to run on the same machine as MyComServer.  But now I want to move the IIS to another machine.  So I tried to use DCOMCNFG on the new IIS server to specify that this COM server should be run on the machine "XYZ".  And I made sure the IIS user this app runs as is allowed to instantiate and call it.  It keeps trying to execute it locally, though...

So then I tried the following (you can do this in VB, why not ASP?).  I added a second parameter to the createobject call, to specify the server I want to connect to.  See below:

Sub Session_OnStart
Set Session("MyObject") = server.createobject("MyComServer.MyObject", "") 'this is the address of my COM Server...
End Sub

This, though, causes an http 500 error to be displayed.

Does anyone have any suggestions?  I know IIS 6 needed to have the metabase altered first, by running the following, can you even do this with IIS 7?  Is there somewhere else to set this option?:

<%@ Language=VBScript %>
' Get the IIsWebVirtualDir Admin Object
set vDirObj = GetObject("IIS://LocalHost/W3svc/1/Root/vdir_name")

'Enable the AspAllowOutOfProcComponenents Parameter
VDirObj.Put "AspAllowOutOfProcComponents", True

'Save the Changed value to the metabase


Any comments that might help would be greatly appreciated!

Posted on Tuesday, April 21, 2009 4:19 PM | Back to top

Comments on this post: DCOM and ASP - How to specify the server?

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Brian Biales | Powered by: