02 May 2009

Why you need Fiddler if you're publishing web sites

I'm publishing a new web site today (this is my new project that's using Silverlight, SQLite, LINQ via DbLinq and WCF). Well I tried to publish it on Monday but ran into a snag with the service I used to talk to the database. I thought it was a url problem, so I spent maybe an hour or two messing around with web.config and the service references in my Silverlight project. I've learned a couple of valuable lessons here.

Changing service references around can be a real hassle. There's two solutions to this. First, you can just have two references to the service in your Silverlight project, just changing the using statement at the top of your files to the one you want. However this might mean changing your code in more than one place, which will get old. Second, you can use a ServiceHostFactory (I read about this here):

public class MySiteHostFactory : ServiceHostFactory
{
protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses)
{
// Specify the exact URL of your web service
Uri webServiceAddress = new Uri(ConfigurationManager.AppSettings["ServiceUri_MySite"]);
ServiceHost webServiceHost = new ServiceHost(serviceType, webServiceAddress);
return webServiceHost;
}
}

And then add a key/value pair to your web.config. I did try this approach and it worked, but still didn't get to the root of my problem.

Get your policies straight. When you're deployed you'll probably want to lock down who can access your service. But in the meantime, open that policy right up. You'll need two files, clientaccesspolicy.xml and crossdomain.xml.

clientaccesspolicy.xml:
<?xml version="1.0" encoding="utf-8"?>
<access-policy>
<cross-domain-access>
<policy>
<allow-from http-request-headers="*" >
<domain uri="*"/>
</allow-from>
<grant-to>
<resource path="/" include-subpaths="true"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>

And crossdomain.xml:
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-http-request-headers-from domain="*" headers="*"/>
</cross-domain-policy>
NotFound can mean a lot of things. I kept getting a NotFound error out of my service. This was where I spent most of my time. Publishing the service? No prob. Opening up cross domain access? No prob. NotFound? What the heck does that mean. I could browse to the service. I could build a proxy using svcutil.exe. I was running my Silverlight app locally so I knew everything else was running right. So what the heck was going on? Well, a lot of messing around went by and still I didn't get anywhere until I did this:

Use Fiddler and add this to your web.config: <serviceDebug includeExceptionDetailInFaults="true" />. Using these two I found the issue in 10 minutes. Keep in mind that I was running the Silverlight app locally but I was pointing to the remote server. Turned out I was missing a dll (System.Data.SQLite). So I added it from my local dblinq directory. Still got the NotFound error. What?? Back to Fiddler. Go to the line that has the error (a 500 in my case) then Inspectors, TextView in the bottom pane. "The located assembly's manifest definition does not match the assembly reference": ah hah, wrong dll. Uploaded the correct one and away we went. All done.

Update: seetha asked what you need to do to get SQLite running on discountasp.net. The answer: not much. It's all about the trust level that your host let's you run .net apps under. Discountasp.net lets you run at Full Trust so there's no tweaking needed to get it going. Just make sure your app can find the .s3db file regardless of directory structure (I put mine in App_Data) and make sure you have the right version of your SQLite dll in your bin.

14 April 2009

outlook r dumb

Why can't Outlook figure out that when I hit "Reply All" on an email that I sent out, I don't really need to send a copy *to myself*!? I miss gmail every time I use Outlook.

01 March 2009

Expression Blend 2

Been messing around with Expression Blend 2 tonight as I build my latest Silverlight project. Right now I have IE7, FF3, VS 2008 and Exp Blend 2 open. The XAML that I'm working on looks the same in IE and FF but doesn't match what VS 2008 and Expression Blend are showing me. I guess Blend is nice to have if you want to do animation but it's so crippled because there's no autocomplete. I find myself using VS 2008 for XAML editing because of that. Lacking autocomplete would be fine if all the language features were there in the properties pane. But for the life of me I can't find a MaxHeight property for an Image. Seems like that's pretty important for a designer to have. And since it's preview doesn't match what the browser is showing me, it's value is even more dubious.

Oh wait there it is, there's a little grayed out arrow at the bottom of that pane. You expand that and you get the advanced properties. Here's the image. Wow that thing is hard to see.


Still, lacking autocomplete is a deal breaker for me. Also, so far I see no way to change key bindings. Build solution in my VS is F6 but in EB it's Ctrl+Shift+B (while Run is F5). Lame.

07 February 2009

Mitochondrial DNA uses Encapsulation

I read this on the PZ Myers's blog (link):

"They also have a peculiar evolutionary history, arising as endosymbionts; their ancestors were independent organisms that took up residence inside eukaryotic cells in a mutually happy and long-lasting relationship. They exhibit some interesting relics of that prior history, as mitochondria have their own private strand of DNA which encodes some of the genes needed for the chemical processes they execute."

Sounds to me like mitochondrial DNA are practicing a little bit of encapsulation. Cell evolutionary biology as an example of "Favor object composition over class inheritance" [GOF]. How's that for a little mind-bending intersection of computer science and real science?

01 February 2009

Lightweight databases (SQL Server alternatives)

Portions of this post will read like some Bukowski stream of consciousness thing. Apologies.

As part of my new project (more to come on that later) I'm interviewing lightweight databases. What I'm really looking for is:
  • will work in a shared hosting environment with no additional software installs
  • xcopy deployable
  • has a decent IDE
  • will work well with LINQ
The list so far (thanks to the people on StackOverflow for helping me here):
  • SQL Server Compact Edition
  • SQLite
  • VistaDB
  • Firebird
Next step, evaluation:

SQLite:
I already knew a little bit about SQLite because of my exposure to Android. It's the db that's used on Android and iPhone OS by default. So it's already in the lead because I'll need to know about it for those two platforms.

Installation: easy. Go to sqlite.org and hit the download page. There's 4 files for windows but it's pretty easy to see what's what. Download the dll, put it in a place that's easy to find. There's no install. Just a dll. Done, in 1 minute.

GUI: I read about SQLite administrator on mikeduncan.com so I tried that. Easy, quick, light. Some bugs, but no killers so far. All fine, but get this, it has AutoComplete! It was like a choir of angels singing when I saw that one. AutoComplete in a free SQL tool. Whoda thunk. I wanted to find a clip of a choir of angels singing and a light from heaven from a movie but couldn't find it or think of one. Damn.

Downsides:
No FKs. Damn, I really hate this one. FKs seem mandatory for a relational db for me. You can enforce them with triggers but that seems like a lot of work for FK enforcement.
Entire database is locked for a write. Versus row or table locking on more sophisticated dbs. So if your db is going to see a lot of writes then this will hurt your performance. Since my project is for a public-facing website the R/W ratio will be so high it won't matter. The SQLite FAQ says it's appropriate for sites that see up to 100k hits per day. Which is 90% of them?


Next up: SQL Server Compact

Disclaimer: I wrote about this in real time as I was installing, so I may look like I could've done this better.

Upon going to the download page, I'm hit with the dreaded Wall of Text. There's 3 versions on there, with 5 download links each. But if it's a simple database, it seems like it should be simple to install. SSC is failing there. "SQL Server Compact 3.5 Service Pack 1 for Windows Desktop (includes Synchronization Services for ADO.NET version 1.0 Service Pack 1)" seems like my best option. Then I go to the download page and it's the same thing, wall of text. 4/5th of the way down the page is "SSCERuntime-ENU-x86.msi" that's probably what I need. Then I hit install and I get the option of Repair or Remove. No install. OK great I downloaded the Service Pack version, I need to download the non-service pack version then install the service pack I guess? Ugh. I want a big button that says "Get the latest version!!" So I go back in the browser and hit the link for version 3.5 (without the Service Pack). It asks me to register, I say no. Then it sends me to the download page for 3.5 SP1. Arrrrgh. I'm ready to give up on Compact Edition right here. Done, over, finito. I've blown 10 mins on just the freakin installation. I wonder at this point if I already have Compact installed because I have SQL Server 2005 installed? I don't remember actually installing it, but the options in the installer are "Repair" or "Remove" so maybe... Is SQL Server (Full) installed? Don't see any management tools in my Programs list. Go to add/remove programs. Wait. Update blog post. Yep, sure enough, it's installed.

This is the point where I'm giving up on SQL Server Compact. I want a database solution that can exist totally independently of SQL Server and that's not clear from what I've done so far. I suspect that it can operate without SQL Server, but I don't want to uninstall SQL Server just so I can be sure. And I want management tools that are free and good (I already know this is possible with SQLite).

TLDR edition: Too much work to install, especially compared to SQLite.

Next up: VistaDB

Again, a recommendation from StackOverflow. VistaDB has an unfortunate naming collision with the most hated of all OS's, so I felt bad for em. They were probably there first.

The features look great. But then there's the license. No free license. There's a single dev distribution license, but it's pricey. I can get 3 years of SQL access on shared hosting for the price of that license. Gonna have to take a pass, the math just doesn't work. It's possible that I don't understand the licensing. But I already know SQLite is totally free and easy to use, so I'm not inclined to dig into the particulars of the licensing here.

Next up: Firebird

The specs look good. Requires an install, which is a con already. But maybe it'll be OK. I install, pause briefly when I see the option for installing as an Application or a Service. Really I don't want either, but I pick Application. Then there's "Start Firebird automatically every time you boot up." Rut-roh, does this mean that any host I put this my site's db on will have to have Firebird installed? Hmmm. I complete the install. CPU usage seems pretty extreme for an install. Then I hit "Finish" and get an exception: "Firebird server failure: Missing configuration file [Program Files]\Firebird\Firebird_2_1\firebird.conf". So it failed to bring in a file that it needed when it installed. Great. Now I have to track down whether that file exists and what it's supposed to do. I'm tempted to dump Firebird right here. Can't make an installer correctly? I don't have time to deal with your software.

Actually, I'm passing on Firebird. The installation makes me think that whatever host I pick would have to support it; my target host (discountasp.net) doesn't support it. I don't like restricting hosting options for my clients. Plus, it has a *nix smell about it; the first paragraph in the install guide says "Please study this chapter before attempting to install any servers." In other words, RTFM, which feels *nixy to my ears. I want a quickstart guide (which I did find, but after the install guide).

Wait, what's this, there's an embedded version. OK, that might work. I look around for an install link and find this in the Firebird documentation: "It's typically named Firebird-n.n.n.xxxx_embed_win32.zip, with n.n.n.xxxx the Firebird version and build number". At least give me a link to the page! Blerg. Here's the link for win32. Before I install Firebird Embedded I should uninstall Firebird (to make sure Embedded doesn't require the full version). Programs->Firebird->Uninstall. It fails, missing shortcut. Great. So I go through "Add / Remove Programs" and when I uninstall, I get an error; it tells me it "may already have been uninstalled." Man. Maybe I uninstalled and the uninstaller didn't clean up the Programs menu? Or the Add/Remove Programs list? Again, *nixy. I'm gonna give it 10 more mins at this point. Got to budget time.

The big question about Firebird Embedded is: can I use a GUI with it? I'm of the opinion that command lines should be easy to get, but rarely needed, it's the Roe v. Wade opinion of GUIs. I found a blog post, but his suggestion involves renaming a dll and providing a nonexistent password so FlameRobin can connect to the embedded server. I think if the GUI wasn't intended to do something you're asking for trouble when you trick it into doing that thing. We'll see. Here's the blog post.

I'm using Firebird 2.0 instead of 1.5 so that's a red flag already. I try what he suggests and get: "A fatal error has occurred. If you know how to reproduce..." Well that's the end of that. Firebird might be fine, but it's best GUI tool won't work with the embedded version.

And The Winner: SQLite. I can live without foreign keys. I'll be doing the whole data access layer in LINQ, so no sprocs will be fine. I need to know it for Android programming. The whole-db-is-locked-for-a-write issue won't affect this project very much. It's incredibly easy to get going. The GUI tool that I'm using has autocomplete. Auto. Freakin. Complete.

On a related note, I found the dbml project which is aimed at providing LINQ access to a variety of databases. Looks great, they've got a bazillion unit tests in every project. Not all of them are passing though; it's still Alpha.

05 January 2009

Microsoft Marketing

Sometimes I wonder what is going on in Microsoft's Marketing division. Or how many divisions there are. Today, I saw somewhere that the Windows 7 logo has a 7 in the middle: Windows Se7en. Like Tr2n - I think the producers of Tron 2 bagged that though, and wisely so). I'm thinking that the logo with the 7 in the middle is bogus. So no further comments.

This is the one I found on Microsoft.com:


OK, that's nice, I can deal with that.

But. Windows 7? Let's look at the name history.

Windows 1
Windows 2
Windows 3
Windows 95
Windows 98 (shudder)
Windows NT (was in here somewhere)
Windows ME (yeah, I went there)
Windows XP
Windows Vista
Windows 7

I'm probably missing some server editions in there.

For Windows 1-3 we've got a very boring naming scheme, but that's fine, a company getting off the ground and all that. Windows 95, 98, sure that works but it's really not more exciting than 1-3 for naming.

Windows NT: well really what were they trying to convey there? No idea. Next Technology?

Windows ME I'm just gonna skip. It's the one that they locked in the attic and the public heard some strange sounds coming from that direction from time to time.

Windows XP: Well it's consistently cryptic along with NT and ME. Next I want Windows SX.

Windows Vista: Wow, like a real name and everything? Seriously, of all the names this is my favorite. It conveys something. Like "Out my back window is an impressive vista." It's actually trying for something.

Windows 7: Well, we give up so we're gonna go back to numbers. Lucky numbers only though!

Once again, Apple shows they have a better PR division. Sure the first 6 versions where just System [Number]. Booorring. But then you go to Mac OS [Number]. Now they have some cat names in there for sub-versions, guess that's OK. Will they do bird names for OS XI? The important part here is that Mac has a consistent image. Microsoft is seriously lacking here.

The .NET Framework has the same issue really. When people first heard about it they assumed it was some kind of website. Not many people really know whether it's .net, .NET or .Net and their branding hasn't helped this. If it's not just for making web pages then why is it called .NET? Dropped the ball here. They're consistent at least, version 4.0 is on the way and there's no name change.

There are signs that they're turning around. Silverlight and Azure are both great names. They sound nice and won't be confused with anything else. Azure's got a decent logo:



The Silverlight logo is unclear and looks like a sea creature to me:



That's never gonna scale down well.

03 January 2009

Wii Tennis Pro

Bought my son a Wii for Christmas. He's pretty happy with it. I've been playing it a bit too; went through Metroid Prime Corruption on the days that the Portland area was in a Deep Freeze. Snowed in for 3 days makes Jack a little crazy - and bored. Fun but not much replay value, so back to Goozex it goes.

But now, I'm all about the Wii Tennis. Wii Bowling is nice and all, but it really just boils down to how consistently can you throw a strike. No change in the difficulty, just the chase for a 300 game. Best I did was 5 strikes in a row, no idea now how I did that because a double seems to be the best I can do now. The nicknames don't get better: 3rd strike is a Turkey, but 4th is just Fourth. Wii Tennis is way fun though. I broke in to the Pro ranks the other day, man that was a real struggle, seemed like I was stuck at 850 for days. Now I'm sitting at 1150. So I'm solidly in Pro territory.

Crazy thing was the other day when I won a game and lost 100 points of rank. WHAT. I was playing a solo-double game (me playing both positions) but was missing shots sometimes when I'd try to get in a late shot with the front position, miss and then be too late to get the ball with the back player (because both players swing at the same time when you're playing both). So I switch to doubles with the computer thinking it'll be better. My first computer partner is 600 points below me in rank. Ouch. But I go on to win against computer players rated at 1300; won 3-2 out of 5. Then I see the change in rank and I lost 100 points. What!? Oh well, next game. My next computer player is ranked 0. Zero. Against two computer players ranked 1500. What the hell. Went on to win, but still got a terrible point bounce considering: +50. Yeesh, so it's back to solo/double for me.

Where's the Wii Tennis League in Portland? Off to google it I goes. I'd rather be playing tennis indoors with booze in January anyway. Plus, I've tried like 3 times to sign up for real tennis lessons that aren't at 9AM and haven't been able to get in. Too much demand for the Wednesday night classes it seems.

Chrome without a Google Toolbar? No thanks

This is something that I keep coming back to every few weeks. Have they released a google toolbar for Chrome yet? No? [waits a couple weeks] How about now? No.

Chrome is nice and all; separation of pages into their own process is nice, but really how often does my browser (FF) fully crash? It's rare. So that's a minor problem that Chrome solves. The interface is nice. That's about all it's got going for it. But no google bookmarks? Deal breaker. An eyeball count says I've got 150 pages in my bookmarks. I use that toolbar all the time.

I think it's really weird that the big G released an inhouse browser and 3 months later there's still no toolbar. What's going on over there? Are those teams fighting? Do I need to pull this car over? I was really hoping to find a youtube clip of Clark Griswold saying that; no dice.