logo
vbRad Home
Source Code
Book Reviews
Forum
Links
About Us
Contribute

Compare Databases with SQL Effects Clarity
 
 IIS and COM Components: troubleshooting guide & tutorial.

Posted on
9/9/2002
Author:
Robert Gelb
Email:
Not Shown
Applies To OS:
NT, 2k, 2003, XP
Product:
6



See also:
How to create ASP applications without writing ASP code


Ok, so you want to stop being a wannabe programmer punk and decided to move into real development by making a couple of COM/VB components that you could use in your ASP development. Congratulations, it's a scary move but rewards are great. The best reward: you can debug the components straight from your VB IDE - no more Response.Write insanity.

So now you've created your first component, you clicked Run (btw, calling the Run button 'Play' is a dead giveaway that you are fresh from the ASP refugee camp), and went to your URL. And this is where the troubles start.

Access is denied to this object.
The most common problem developers encounters is as follows: you press F5 on your VB component, crank up the URL and get this: The call to Server.CreateObject failed while checking permissions. Access is denied to this object.. If you compile your code into a DLL, and run it as a DLL, everything will work OK, but not in the IDE. Why? The problem usually is that the web application is running under IUSR_MACHINE user name, which has no permissions to access the DCOM Server (VB6.exe in this case). Microsoft actually has a solution for you (Q259725), but it is too complicated and dumb. I have a better solution: Open Internet Service Manager. Right-click on your virtual directory and select Properties. Then go to the Directory Security tab, click the first Edit button you see on the dialog box, then click the first Edit button again. Now click Browse and select a user account that has Administrator rights. OKay your way out of it and the problem should go away. Some people might grumble that you shouldn't run your web app with an Admin account, but this is your development PC, so who cares.

I can't recompile my DLL/code.
This behaviour also affects newbie COM junkies. It happens under following circumstances: You compile your code and test it out by going to your URL. Then you attempt to change and recompile your code but VB says Permission Denied. No amount of restarting your VB project will allow you to recompile your code. Why? Because when IIS executes your DLL, it never lets go of it. Never. So what can you do? The immediate solution is to restart IIS. Fear not, it's easy. Executing this batch file will properly restart IIS and all its child services. You might want to edit it and customize, if necessary.

The long term solution is not to compile your code into a DLL, unless you really need it. Simply run the code in IDE. When you do compile it, for deployment to a production server or some such, simply delete it afterwards.

I pressed F5, but IIS is still running the DLL instead of my code.
This is the same problem as #2. Once IIS has got your DLL, it never lets go. Starting your VB project will not change that. So simply restart IIS using a batch file provided in #2.

How do I know whether IIS is running the code in my DLL or the IDE?
Place a breakpoint in the path of the code. If it breaks, obviously it is running in the IDE.

The code works on my machine, but fails on the production server.
Many scenarios yield these results but let's take a look at the most common ones.

  • Permission Denied. Most likely you are running under IUSR_MACHINE user, which probably has limited rights. You are probably trying to access some resource to which the user has no access, such as a folder or file. If you are doing anything with ADO, always give your user read/write control over your TEMP directory. ADO and many other components use it to store temporary files.
  • Cannot Create Object. Register the DLL using regsvr32.exe utility. Make sure (very important) that the DLL is registered by a user with Admin status. If it wasn't, you are probably in a world of hurt. Track down that user and have him/her unregister the component. Then find a user with admin rights and register it. If this is not done, not only will you not be able to create the object, you won't be able to register appropriately it in the future. If it were already registered properly, but you are still getting the error, make sure ISR_MACHINE user has read access to the HKEY_CLASSES_ROT branch of the registry. With all the security scares, corporations often wipe all the permissions and give them on a need-to-have-it basis.
  • Data Source Name Not Found or Default Driver not specified. ODBC DSNs must be created by Admins. If they were not, then delete them and recreate using an Admin account. In addition, your IUSR_MACHINE user must have read access to the HKEY_LOCAL_MACHINE/Software/ODBC branch. If you are using Crystal Reports 8.x, get their latest update, because the boxed installation creates a supreme registry mess.
Good Luck!



Add Your Comment  

Name: Email Address: all fields optional
Notify me via email when someone responds to this message (valid email required).

Enter the word:
 



Comments
#1. By carlos. Posted on 7/24/2006 4:36:45 AM
hi, thanks for sharing your knownledge. I am stuck trying to get a reference to an already running object thru GetObject(,"LibName.ClassName") within an in-proc dll class instaniated via global.asa. It fails consisntently althought the code runs fine within vb debuggin and run time (win32 client not web-iis5.1 client)

Any ideas?

Thanks

Carlos

#2. By auxOff. Posted on 4/2/2007 12:09:46 AM
Thank you for your work very, very interesting on top of that for me.

#3. By stan. Posted on 5/6/2007 9:14:27 PM
I have found out the useful information for me, thanks a lot.

#4. By Sanjoy. Posted on 9/24/2007 6:54:00 PM
Good response. Thank you

#5. By Kumar. Posted on 7/4/2008 9:12:07 AM
That's a pretty good detail. I was searching for work-around of "Access denied to this object" and the above information, really helped me. Thanks to the Author. Much appreciated.

#6. By Gokhan. Posted on 11/17/2008 7:23:56 AM
thanks! good job.

#7. By Angel Parjus. Posted on 1/29/2009 9:05:11 PM
Great ideas for some of these issues. I'm having an issue with IIS 6 that has everyone puzzled!!! I'm getting "The specified procedure could not be found. " trying to access a user control on a c# class using UserControl class.
It works in DEV and QA but not in production.

#8. By Ahmad. Posted on 3/16/2009 10:57:08 AM
Robert
u r my hero, u wont imagin how this page helped, its posted on 2002 and it helped me on 2009
c how great is the intrnet!!
forgive my english

thanks alot

#9. By nikpap. Posted on 2/3/2010 3:51:14 PM
I have a dll (.net 3.5) that have registered as com+. Every time I restart my IIS or PC, when I try to call it from my asp page (via Server.CreateObject(MyLib.ObjectName)) I get the error 'Cannot Create Object invalid class string'...
When I call it from other page (localhost) in another IIS site it works fine!!!
Any ideas??

#10. By palani. Posted on 2/24/2010 7:51:49 AM
very bad

#11. By palani. Posted on 2/24/2010 7:51:57 AM
very bad

#12. By Angel Parjus. Posted on 3/2/2010 8:44:34 PM
Make sure you have iis folder to allow execute script

#13. By Anonymous. Posted on 3/3/2010 8:45:06 AM
it allows, perhaps it has to do with the OS (Microsoft XP), because when deployed to Windows 2003 everything worked fine...

#14. By nikpap. Posted on 3/3/2010 8:45:57 AM
t allows, perhaps it has to do with the OS (Microsoft XP), because when deployed to Windows 2003 everything worked fine...