Top Tips for Developing Components for ASP
If you ever used Visual Interdev, youll probably think that its great for writing ASP. IntelliSense object models popup even for custom components and the debugging tools look almost as good as the ones in VB. The reality of this is far from great. Every time you open a page that makes an instance of your DLL, Visual Interdev loads that DLL into memory to get its object model. So if you want to recompile your DLL you have to close down your page.
Thats not too much of a problem, but when you actually run the page in your browser it appears that however much you try you cant get ASP to release your DLL! This either means a complete reboot or a stop and start of IIS. Windows 2000 adds a well needed restart feature but for those of you running IIS 4 heres a little DOS batch file that will take care of restarting IIS:
@echo offNET STOP iisadmin /yMTXSTOPNET START W3SVC
Simply run that each time and IIS will be restarted, flushing all components out of memory.
The next problem that I came up against was passing parameters into my DLL. As VBScript does not support variable types, every variables is a Variant. This cause lots of problems when you pass it as a parameter to a DLL which expects a string. Instead of converting it to a string (which would be expected) it throws up a Type Mismatch error so ensure all parameters coming in are declared as Variants. This is not the case when you return, so you dont need to worry about that.
When developing the DLL, I suggest that you keep it as a standard EXE project and debug it like that. Then, when youre ready to test it with ASP, compile it as an ActiveX DLL. This way you can cut out a lot of restarting IIS.
However bad Visual Interdevs debugging features may be for components, make sure that you use whats available. Turn debugging on for your web site by loading Internet Service Manager, right clicking on your web site and selecting properties. Choose the Home Directory tab and select Configuration (under the Application Settings frame). Now select the App Debugging tab and make sure that Enable Server Side ASP Script Debugging and Enable Client Side ASP Script Debugging are checked. This will allow you to use Visual Interdev to hook onto the IIS process.
OK so youve built your nifty DLL and ASP script, but how do you know how well it will perform? Lets find out
Page 3 of 4