Monday, July 24, 2006

Exposing .Net Components to ASP

Assuming you're using Visual Studio, first make sure the project that holds the classes you want to expose is COM-visible (Project>Properties>Application>Assembly Information>Make assembly COM-visible in VS2005).

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.

Book 29: Touch (Leonard)

No criminals, just a guy with healing powers. Good writing, not compelling.

Friday, July 21, 2006

Book 28: Sushi Daze (Payne)

A thoroughly unlikable man leaves a boring life in Toronto to teach English in Japan.

I sometimes forget what "badly written" means, but this book reminds me. Poorly-chosen metaphors abound. For example, "his chest was a barrel of oil" instead of "barrel-chested". These things sound petty taken individually, but several per chapter makes reading unpleasant. I forced myself to finish it. A terrible, terrible book.

Monday, July 17, 2006

Book 27: The Food of Love (Capella)

Light novel about food and love. The food parts are stimulating and convincing, the love parts not so much.

Book 26: The Moonshine War (Leonard)

Good minimal gangster and moonshiner story. My cousin says she doesn't like Leonard because of the casual violence. While I agree that your average Leonard novel has violence (I was going to say "more than your average Toni Morrison novel", but I'm not sure that's true!), I think it's not so much casual as realistic. Of course this depends on my idea of realistic violence (which can't be based on much experience), but I think Leonard's fast, undramatic presentation is closer to reality than a long-build, high-drama depiction. Anyway, good book.

Sunday, July 09, 2006

Book 25: Pattern Recognition (Gibson)

Very good. I guess the future has caught up to Gibson: he can write "cyberpunk" and set it in the present day. The answer to the big mystery in the book (who's producing the footage) is satisfying and believable.

Nit-picking: his idea of a render farm is wrong.

Wednesday, July 05, 2006

Ronaldinho Statue Burned After Brasil Loss

For some reason this just strikes me as very funny. But somehow just: if you let us down, we'll destroy your statue.

Book 24: The Grey King (Cooper)

Better still than Greenwitch.

Book 23: Greenwitch (Cooper)

Better than the first two in the series. A little less kiddy, but still pretty light.

Book 22: The Trial of God (Weisel)

When Elie Weisel was in a German concentration camp, some of his fellow prisoners were rabbis. One day they held a trial to determine whether their god had treated them justly. They decided he had not. Then they all got up and went to their prayers as usual.

This is story is much better and more horrible than the play "The Trial of God", which seemed to pull its punches.