I have struggled with a couple of issues with some fairly old classic asp sites that we still look after but the client is in no mood to upgrade because of the time and cost element (fair enough). However technology moves on and one big issue I discovered to my peril is that the SOAP toolkit I had been using in classic ASP to consume remote web services was thrown out by microsoft in windows 2008 (and Windows 7) - great!!
It's not the end of the world of course as you can use direct http requests to send and receive SOAP requests but you have to go to all the lengths of building a soap envelope and decoding the results. Now I have been programming in .NET for sometime now and because of the ease of including web services into any application I looked into using .net as the solution. But how to use .NET code in classic ASP. Well COM of course. So I went off and built my .NET class that cosumed the web service all well and good, next to turn this into a COM object so that classic ASP can access it!
Now, none of the steps below are undocumented but it's quite a trawl to find this information so I have put it down (mostly to remind myself) in simple steps to make it easy to follow;
- Create a standard Class project in visual studio (I have done this in 2008 and 2010 but can't comment on 2005)
- In the properties tab of your project click on the "Compile" tab and make sure you tick the "Register for COM interop" flag
- Under the "Signing" tab click the "Sign the assembly" tick and follow the instructions to create a signing key for the project. You will need this if you want to install your dll on production server (which you probably will do!)
- Build you .NET project. In the location that you built your project you should have a .dll, .tlb and .dll.config file. You will need these if you want to make the dll available on any other machine, which I did to the rest of the instructions are about making this COM library availble on another machine
- Copy the .dll, .tlb and .dll.config files over to the production machine.
- Find the regasm.exe file in order to register this file on your production machine (NOTE: your production machine will need to have the matching .NET assembly installed and the regasm.exe will need to be appropriate for the OS - 32-bit of 64-bit). You can find the regasm.exe in your .NET Framework root (on you dev machine) - something like C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\regasm.exe
- Copy the regasm.exe over to the production machine in the same dir as the .dll file
- Open a cmd prompt window and navigate to the directory with you dll in and register the code in the assembly as follows:
regasm /tlb /codebase somename.dll
- That's it. You .Net library should be ready to use with the classic asp code
server.createobject("somename.someclass")
I hope this information is helpful to someone out there!!