Automatic assembly versioning solution - MSBuild Versioning -
Nice small project for automatic build versioning. It was always a problem for me, but now the problem is solved once and for all! It supports nicely both Mercurial and SVN repositories to retrieve revision number and/or ID. Check Tokens page for more custom tags.
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 (http://code.google.com/p/mvc-mini-profiler/).
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:
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:
<system.data>
<DbProviderFactories>
<remove invariant="MvcMiniProfiler.Data.ProfiledDbProvider" />
<add description="MvcMiniProfiler.Data.ProfiledDbProvider" invariant="MvcMiniProfiler.Data.ProfiledDbProvider" type="MvcMiniProfiler.Data.ProfiledDbProviderFactory, MvcMiniProfiler" name="MvcMiniProfiler.Data.ProfiledDbProvider" />
</DbProviderFactories>
</system.data>
We just register DB provider for MvcMiniProfiler and everything keeps working. :)
List of the canonical introductory textbooks covering the major branches of computer science
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.
Quick post to not forget :)
Article (mentions x86 WinDbg installation under x64 OS): http://dotnetspeak.com/index.php/2010/09/using-windbg-to-find-memory-leaks-in-silverlight-applications/
Also quick cheatsheet:
.load C:\Program Files (x86)\Microsoft Silverlight\4.0.60129.0\sos.dll
!dumpheap -stat
!dumpheap -MT <mt>
!gcroot <addr>
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 StackOverflow.com: Visual Studio Optimizations.
mercurial with ssh setup on windows -
Mercurial setting up for serious work under Windows :)
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:
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 - tcp.net 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 tcp.net 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:
[video]