Then install your application on the target machine. Now you should be able to create an instance of your class from VBScript with a command like this:
CreateObject("Namespace.ClassName").(Put that command in a file called MyTest.vbs and invoke it from the command line.) If your class has a method that accepts and returns simple parameters, you can show a message box by doing something like this:
MsgBox CreateObject("Namespace.ClassName").DoIt("p1","p2")Now CreateObject should work similarly from your ASP page:
Dim myobj
Set myobj=Server.CreateObject("Namespace.ClassName")But maybe you get "CreateObject failed" errors that indicate that the ASP page can't find your class. In that case, you can try unregistering your library, removing it from the GAC, adding it back to the GAC and re-registering it, like this:
1. regasm /unregister YourProject.dll
2. gacutil /u YourProject
3. gacutil /i YourProject.dll
4. regasm YourProject.dll
5. Restart the World Wide Web Publishing Service
(That's not a typo in number two: when you remove your assembly from the GAC, you refer to it by its name, not its filename.)
Regasm.exe is part of the .Net Framework (you should probably use the .Net 2.0 version in /Windows/Microsoft.NET/Framework/v2.0.50727). GACUtil.exe is also part of the .Net Framework, but it doesn't seem to ship with .Net 2.0. But you'll run into trouble if you use the .Net 1.1 version! I only got good results by using the GACUtil.exe that comes with VS2005! (/Program Files/Microsoft Visual Studio 8/SDK/v2.0/Bin/gacutil.exe).
The above procedure works pretty reliably for me. Once it didn't and I got around the problem by removing references to YourProject.dll from the registry. But that's really risky and dangerous and I shouldn't have done it and neither should you.
No comments:
Post a Comment