FreeBSD hi-res console

Starting from FreeBSD 9.1 GENERIC kernel is built with everything we need, so it’s really easy. Everything should be done under root.

To see all available video modes:

vidcontrol -i mode

Suppose we are interested in mode 325 (1280x1024x32). To check if it is OK to set it:

vidcontrol MODE_325

If console switched to desired mode without any problems, then edit /boot/device.hint to do the following diff:


That’s all, after reboot as soon as kernel will be loaded, the console will switch to selected video mode, so boot log will be printed in hi-res mode, without waiting for rc.conf loading.

MVC Mini Profiler with Entity Framework and SQL Server CE 4.0

Recently I was trying to use MVC Mini Profiler released by Stack Overflow folks with my site on ASP.NET MVC 3 framework and had some problems to use its all features, because I had a little specific setup (more on that a bit later).

It was a piece of cake to use it for profiling usual code with:

using (MiniProfiler.Current.Step("Some profiling step description"))

Everything worked like a charm with just following a step-by-step guide on project’s site (

Problems started when I got to DB profiling support. I should point out that the specific situation I was in includes using SQL Server CE 4.0 with Entity Framework 4 with DB first approach.

As you can read from their instructions, you have to substitute their profiled connection for the real connection you usually use. But as it turned out not everything is so simple and after some experimenting and searching through Stack Overflow and generally Internet I arrived at the following solution to get Entity Framework’s ObjectContext for you DB Model.

public static T GetDb<T>(string connectionStringName) where T: ObjectContext
    var connectionString = ConfigurationManager.ConnectionStrings[connectionStringName].ConnectionString;
    var entityConnStr = new EntityConnectionStringBuilder(connectionString);
    var realConnection = new SqlCeConnection(entityConnStr.ProviderConnectionString);
    var profiledConnection = ProfiledDbConnection.Get(realConnection, MiniProfiler.Current);
    return profiledConnection.CreateObjectContext<T>();

Here connectionStringName is the name of connection string in your web.config (or app.config) file, T specifies the type of your ObjectContext.

So what do we do here is the following:

  1. We get connection string for web.config (or app.config). If you are using Entity Framework, this connection string will contain not only connection string per se, but also some metadata, which in my case was causing throwing exception by SqlCeConnection constructor.
  2. So we need to get rid of this metadata. We create EntityConnectionStringBuilder which parses nicely our long connection string and provides us with separate parts of it.
  3. For the bare connection to SQL Server CE 4.0 we need just a provider connection string part, which we extract with ProviderConnectionString property.
  4. After that we use ProfiledDbConnection.Get helper method provided by MVC Mini Profiler to create a profiled version of that connection, which we should use instead of standard one.
  5. We use another helper method (which is extension method and is contained within a static class ObjectContextUtils which is also provided by MVC Mini Profiler) to create our DB model object context.

And that’s all. Works very well for me. If you are using not CE edition of SQL Server, you have to change the SqlCeConnection class to SqlConnection.

I suppose you’ll create one more method for your specific application to not provide connection string name throughout all your application:

public static MyObjectContext GetDb() 
    return GetDb<MyObjectContext>("MyObjectContextConnStr");

Hope it helps not only for me next time you’ll try to use MVC Mini Profiler which is a really awesome project. Thanks to Stack Overflow guys for this thing! :)

Update (2011-08-02):

The original post was written while using MvcMiniProfiler 1.4. After updating today to version 1.7, DB profiling stopped working giving the following error message: “Unable to find the requested .Net Framework Data Provider. It may not be installed.” After quick googling, it appears that the following addition to web.config is enough to overcome this problem:

        <remove invariant="MvcMiniProfiler.Data.ProfiledDbProvider" />
        <add description="MvcMiniProfiler.Data.ProfiledDbProvider" invariant="MvcMiniProfiler.Data.ProfiledDbProvider" type="MvcMiniProfiler.Data.ProfiledDbProviderFactory, MvcMiniProfiler" name="MvcMiniProfiler.Data.ProfiledDbProvider" />

We just register DB provider for MvcMiniProfiler and everything keeps working. :)

Could not load file or assembly ‘<some assembly name>’ or one of its dependencies. An attempt was made to load a program with an incorrect format.

Today I stuck with the following problem: when I run my web project through local dev server or IIS Express — everything is fine, but when I host it through IIS, I get “Could not load file or assembly ‘<some assembly name>’ or one of its dependencies. An attempt was made to load a program with an incorrect format.”

One crucial detail: my server is 64-bit.

The solution is in application pool settings: in advanced settings of AppPool, set Enable 32-bit applications to true.

Silverlight memory leaks finding

Quick post to not forget :)

Article (mentions x86 WinDbg installation under x64 OS):

Also quick cheatsheet:

.load C:\Program Files (x86)\Microsoft Silverlight\4.0.60129.0\sos.dll
!dumpheap -stat
!dumpheap -MT <mt>
!gcroot <addr>

Slow Visual Studio 2010 tab closing

If you experience this issue try to add your project’s folder to your antivirus location exception. I have Microsoft Security Essentials and this slowness irritated me for quite some time until I accidentally found on some forum this advice. And it really helped me (after reboot, actually, but I think it depends on antivirus).

Hope it helps you as well.

Update: just found interesting discussion on VS performanve optimizations on Visual Studio Optimizations.

Kubuntu stuff

I recently decided to completely switch to Kubuntu as my main OS and while it is really user-friendly comparing to the dark times when I first tried *nixes, still it lacks tiny bits and some tuning, so I’ll gather different useful links to posts, tutorials and how-to’s that helped me to make work and “living” in Kubuntu more pleasant.

Update from 16 Aug 2010:

Recently I updated to KDE SC 4.5. I won’t describe changes as they are described in a lot places, but I had some regular crashes from Nepomuk service, so I have disabled it… It’s not hard :)

Also there were troubles with KPackageKit: it saw all the new KDE SC 4.5 version packages, but categorized them as Blocked updates. I wonder what it is. Still, I wanted to update my system quite badly, so Google to the rescue! :) Here is a comfortable two-command line to install all available updates:

  • sudo apt-get update && sudo apt-get dist-upgrade 

Silverlight and bindings for WCF

I’m working with Silverlight 4 on my work for quite some time (from early betas).

And I was wondering about new cool feature of the Silverlight 4 - binding. But it seems using it is quite more involved than BasicHttpBinding, but still - I want to understand it and use on my Silverlight project. Here I’ll post some useful links I’ve found - they are for me, just to not google for them one more time. I plan to come back here after IIS Express is out for beta testing (because one can’t use with integrated in VisualStudio ASP.NET web-server, but I don’t want to install heavy-weight IIS7 on my working machine).

So, here are those links: