Working hard with VB.Net, hard work, as I find C# much cleaner, but VB.NET does have the advantage of be able to edit code while debugging. And it compiles while you are working, but I have found that with 64 projects in my solution that the automatic compiler sometimes, quite a lot of the times hogs the machines resources, it would be nice to be able to turn the auto compiler off.
There comes a time when you are using LINQ to SQL that you just have to find out what SQL is being generated, for what ever reason that is, here a a few ways to get the SQL you are looking for:
You can use SQL Server Profile to see the traffic going to and from the database
But if you are like me you want more control over your processes, so you can use the DataContext.Log, and output the log to a window, or in the case below the console window
One last method is to just write out an objects SQL, using the GetCommand, as seen below
I need to generate a Windows Service application, I've done this before, but could I remember how to do it. In my searching I found this code sample very useful Creating a Basic Windows Service in C# on The Code Project
WindowsService_Src.zip (3.78 kb)
Another useful article I found was from Microsoft Windows Services: New Base Classes in .NET Make Writing a Windows Service Easy
Go! Quickly! Stop reading this and register now! Registration for DDD South West is now open. Be able to tell your grandchildren that you were there at the very beginning. Remember, there can be only one first time.
DDD South West is a free one day technical event on Saturday 23rd May 2009 at Queens College, Taunton with 13 of the countries' best speakers providing 19 technical presentations.
Just found a great LINQ tool for quering any database LINQPad, is so useful I almost fell off my chair when I found it.
If you're using LINQ then this is a must on a list of tool you need to have.
When I was using it I thought it would be nice to have Autocompletion, and it does, so long as you register the product.
If you are like me, when you have generated your website you'll need to make sure it works in all the Web Browsers.
My normal approach would be to fire up all my different Virtual Machines, each with a virgin copy of each web browser. This process works fine and it is a very good way of making sure all your site works in different browsers.
However I came across a site today, Browser Shots, with thanks to Guy, that will run your website in a host of different browsers, and return back a screen shot of what it looks like, this is the fastest way to see if your site works in a lot of Browsers. Just enter your website and let it do all the work for you.
The problem is you have a number of PlugIns in your application, however how do you know which plugins have implemented an interface for a task you need to perform?
Following on from my last article, Plugin Model, I will create a new interface, implement that interface and then find the Plugin that implments that interface.
First lets create a simple Interface
Next implement the interface to a plugin controller class
You can see it here as HelloWorld()
Okay now we need to find which plugins inplement that interface
As you can see above we go over the collection of plugins and check to see if the plugs has a TypeOf IInterface1, if it does then the plugin supports that interface.
So we can now convert the plugin in to the Interface type and use its interfaces.
I then took this a little further and implemented a Generic method that gets a list of support objects that support a given interface
I've been working with a Plugin model for a few weeks now and I thought it was time I should document the model.
Task is to build an application that you can plugin models via the .config file, and provide a level of configuration for each plugin via the .config file.
This example is for the purposes of example and you should perform more checks to perform validation to ensure that the application is more rebust. Oh, and you can now do all of this using IoC containers, which I may cover another day. But I have found serious issues with IoC containers and VB.NET, as VB.NET does not support implicit interface implementation whereas C# does, but that is another issue for another day.
First lets create the interfaces that will be required for a Plugin to work
The PlugInName and Version are just so we can hold general information about the Plugins.
The Initialise method will be called to start the plugin up and when you are finished you must call the Finalise method.
I have included InstalledPlugInElement, which will hold all the configuration information for the plugin that can be stored in the .config file.
Lets have a quick look at the InstalledPlugInElement class
Here are hold the assembly name and a configuration parameter for to enable the Cache for the plugin
Next we need to handle the .config file and the section where the plugs are to be configured, this will be held in the InstalledPlugInSectionHandler, this inherits the ConfigurationSection, as seen below
Okay that's it for now with what we need for the plugins, next we need to be able to load the plugins, with the help of a PlugInLoader
Okay this is quite a lot of code for one method.
What we are going to do in this method is get a list of plugins that are supplied in the .config file, and when we create a new instance of the plugin we'll pass in the Installed plugin Elements that are in the .config file.
The section of the .config that holds the plugin information is "plug_ins", and we get a list of said plugins from the .config file.
You will also require InstalledPlugInCollection, which you'll find in the source at the bottom of this article.
Of now lets create our PlugIn, generate a new project and add a controller class
Of course this controller class implments the IPlugIn interface we created earlier.
We set the Plugin Name and Version number.
What you will also see is we can set the Cache Enabled, which is pulled in from the .config file
Now we can load the plugins in to a collection of plugins
That's it for plugins, in another article I will go over how the determine if a plugin implements an interface that you may wish to use.
PlugInExample.zip (42.28 kb)
Finally found a link to enable you to be able to use Google fully on your iPhone
I've been having a play with Picasa API, and come up with this Extension for BlogEngine.
All you have to do is pake the picture.cs file and place it in "\App_Code\Extensions" folder, and it takes care of everything for you.
Picture.zip (1.92 kb)
How it works
First the extension will use the admin email address and then add all the newletter e-mail address to a user list, then check with Picasa to see if they have an account. The extension then has a list of user with valid Picasa Albums.
When you open an article the extension will go over all the Tags and see if any of the Picasa Albums in your user list has the same tags, if it does then the photos will be added to the article.
I do Cache the objects, so once the initial load of the article has taken place it is stored in Cache, as it can take some time to compile the list of photos depending how many active user Picasa Albums you have.
One enhancement I would like to include is for the loading of the photos to happen behind the scenes and show a wait icon while the extension goes and gets the photos from Picasa. But I'm not sure how to do this in an Extension, if you know please let me know too.
I've got it working on my Village Website