SubSonic will be your friend

Subsonic claims to have a solution when you have better things to do than worry about Data Access. I, for one, am not very fond of the datalayer in my apps. I rather spend my time on the code instead of stored procedures and SQL queries. So, let’s go ahead and see if SubSonic lives up to its promise.

Let’s open the FrotMachine project from a few posts earlier.
Dowload SubSonic 3.0.0 and add a reference to the SubSonic.Core.dll in the Binaries folder:

reference

Next, create a database. I usually fire up SQL Studio Management Express and create a database by typing:

Oh well, that’s almost too simple to mention.

Anyway, after that I go back to Visual Studio and add a new App.Config item and make sure it looks like this:

appconfig

Let’s create an instance of a Frot right now and see if a table and a record in the database are being made. But wait, we need to add the using statement for Subsonic first:

Now we can add to our Main method:

Let’s check out the database now:

table

Isn’t that nice.. it worked. SubSonic created a table and a record in my database. Quite good, isn’t it? It sure is a lot easier than NHibernate. And twice as cool at that.

This may be a trivial example. I’m sure I’ve got my point accross though.

Vista Hack “Requested registry access is not allowed” in Visual Studio projects.

How to hack Vista to get your Visual Studio installation to work on Windows Vista.

As we all know Vista can sometimes be a pain in the ass when it comes to permissions, on my journey for the installation of Visual studio I encountered the problem:”Requested registry access is not allowed”. Visual Studio can’t create any new projects because of restrictions in the registry.

How can we beat Vista security? well, once you have figured it out, it’s quite easy, although it took me 2 days and 3 system restores, the power is in the order of altering.

First you need to alter the authorization settings in your registry, make sure you are comfortable working in your registry, since you can cause a lot of damage to your pc if you do not know what you are doing.
select HKEY_CLASSES_ROOT right click ‘permissions’, this part of the registry doesn’t have any assigned users, so we will add ‘Administrators’ and ‘Users’ and assign them the privilege ‘ full control’ and click Ok. Now sit back, for this can take a while.

NOTE: make sure you have a back up of your registry and a system restore available, just to be safe!

hkeyclassrootmod

After this you can close the registry.

The second step will be to download a program called SubInAcl.exe and install this little program to your computer.
http://www.microsoft.com/downloads/en/confirmation.aspx?familyId=e8ba3e56-d8fe-4a91-93cf-ed6985e3927b&displayLang=en

next we’ll need to make a script to be able to hack our registry to alter the security settings:

open a notepad and insert the following lines:

save the textfile as fix_registry_permissions.cmd

You can run the file by double clicking it, this is the part where you can leave the house and do some groceries shopping and start making dinner. Don’t worry, just sit it out.

registry_perVS

When the modifications are done, the cmd screen will disappear and you can restart your computer.

Now you will be able to successfully start Visual Studio. Good Luck!