BadImageFormatException: … This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded


For Visual Studio 2010, after we upgraded some of the assembly to target .Net Framework 4.0 from .Net Framework 3.5, we could no longer install using the setup project.

The installation error is:

“System.BadImageFormatException: Could not load file or assembly ‘file:///C:\Program Files (x86)\xxxx.exe’ or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded..”

When we build the setup project, we get the following error:

“WARNING: The target version of the .NET Framework in the project does not match the .NET Framework launch condition version ‘3.5.30729   ‘. Update the version of the .NET Framework launch condition to match the target version of the.NET Framework in the Advanced Compile Options Dialog Box (VB) or the Application Page (C#, F#).”


1. Right click on the setup project, View –> “Launch Conditions”.

2. Click on “.NET Framework”.  It is properly red flag with an exclamation mark and red underline.

3. On the Properties section, change Version from 3.5.30729 to .NET Framework 4.


I upgraded to jQuery 2.0.3 and I am see this error in Google Chrome Developer Tools Console.

GET http://localhost:2627/js/jquery/ 404 (Not Found) 

There are a couple of ways to get rid of the error:

  1. Get the map files from (see reference)
  2. Disable JS source maps in Developer Tools setting. (see reference)
  3. Edit jquery-2.0.3.min.js and remove the line “//@”. 



Dropbox Tricks


To share folders between Mac and Windows using Dropbox.  We want to share folders outside of dropbox folder in each platform.

Mac side

The actual folder we want to share: /Users/Henry/Documents/ProjectXXXX

The dropbox folder: /Users/Henry/Dropbox

To achieve our objective, we make sure of symbolic links.  Note that symbolic links are not the same as alias and alias won’t work for our purpose.  We use Terminal app and go the dropbox folder and create a symbolic link, pointing to the folder we want to share.

ln -s /Users/Henry/Documents/ProjectXXXX /Users/Henry/Dropbox/dbProjectXXXX


We will find a dropbox folder /Users/Henry/Dropbox/dbProjectXXXX, ready to be shared with Windows.

Windows side

The actual folder we want to share: C:\Henry\Documents\ProjectXXXX

The dropbox folder: C:\Henry\Dropbox

We will create a directory symbolic link using “mklink”. 

Open a command prompt (run as administrator).

mklink /d "C:\Henry\Dropbox\dbProjectXXXX" "C:\Henry\Documents\ProjectXXXX"

We will find a dropbox folder C:\Henry\Dropbox/dbProjectXXXX, ready to be shared with Mac.


It may be a good idea to stop Dropbox running on your machine before you do these.


JayData & Knockout & HTML 5: Date

Say you want to store an input type=”date” with knock out.

<input data-bind="value: HearDate" type="date" />

The HTML5 datepicker may not set the date even if you select a date.

It could be caused by the fact that you have define the field with type “date” or “datetime”.

$data.define('XXXX', {

    HearDate: { type: "date" }


If you switch it to “string”, then the HTML5 datepicker will work.

$data.define('XXXX', {

    HearDate: { type: "string" }


note: tried in Google Chrome only.

MS SQL Server ELMAH with Web API

  1. For your WebApi project, Nuget the following 3 packages:
    1. ELMAH
    2. ELMAH Core Library
    3. ELMAH on MS SQL Server
  2. Create a new database on the SQL server.
  3. Run the script “Elmah.SqlServer.sql” under App_Readme folder. The script will create the necessary table and stored procs in the database.
  4. Modify your web.config connection string for “elmah-sqlserver”
  5. Modify Global.asax.cs


public class WebApiApplication : System.Web.HttpApplication


    protected void Application_Start()









        GlobalConfiguration.Configuration.Filters.Add(new MyExceptionFilter());




public class MyExceptionFilter : ExceptionFilterAttribute


    public override void OnException(HttpActionExecutedContext context)


        Elmah.ErrorLog.GetDefault(HttpContext.Current).Log(new Elmah.Error(context.Exception));