How To Use a .NET 4 Based DLL From .NET 2 Based Application?

Monday, May 30, 2011

Introduction The official answer is you can’t. Even with the In-Process Side by Side execution (SxS) feature, introduced in .NET 4. The SxS feature was intended to be used when COM is involved. For example, if you got an application that loads plugins, like outlook, and it loads 2 COM plugins, one is using .NET 4 and the other is using .NET 2.0 then it will load two versions of the CLR into the process using the new SxS feature. What if I simply have a .NET 2 application or DLL that needs to access a...
13 comments

Fix Error: An attempt was made to load a program with an incorrect format

Thursday, September 16, 2010

While trying to run the sample project ShellObjectWatcherSampleWPF from the latest version of Windows API Code Pack, I came across the following problem, both in Visual Studio 2008 and 2010: Or in a search-engine friendly way: “Cannot create instance of ‘MainWindow’ defined in assembly, ‘ShellObjectWatcherSampleWPF, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null’. Exception has been thrown by the target of an invocation.  Error in markup file ‘MainWindow.xaml’ Line 1 Position 9.” Checking the internal exception, revealed the following: "Could not load file or assembly 'Microsoft.WindowsAPICodePack.Shell, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An...

Windows API Code Pack v1.1 Released!

Monday, September 13, 2010

Last Tuesday (31.08.2010) Microsoft released a new version for the excellent managed library, Windows API Code Pack. For those who don’t know, this library serves as a managed wrapper for many Windows APIs which are not included in .NET framework, especially new features from Windows Vista and Windows 7. I’ve been working with this library for quite some time now and I must say it is “.NET missing piece”. Most of Windows features which doesn’t exists in .NET are at your fingertips =, without handling all the Interop stuff yourself. With the coming of .NET Framework...

Windows Ribbon for WinForms, Part 13 – DropDownColorPicker

Wednesday, November 11, 2009

Windows Ribbon for WinForms library now supports DropDownColorPicker control. The result of this post is a yet another sample, “11-DropDownColorPicker”, found on the project site. DropDownColorPicker Control The drop down color picker looks like this:   DropDownColorPicker Properties Following is the list of properties which are unique for DropDownColorPicker control. The rest of the properties have been reviewed in previous posts. Color – The selected color. Property Identifier: UI_PKEY_Color...

Setting Decimal value on PropVariant

Friday, October 16, 2009

PROPVARIANT is Important PROPVARIANT is an important COM structure that is used in many windows shell features like: Shell Namespace Extensions, Taskbar Jump List, Sensors and Windows Ribbon Framework, just to name a few. In order to use these shell features in managed code, one must provide a .NET wrapper for this struct. Now, you might have expected that if this struct is so important, there would be good .NET wrappers for it.. Unfortunately, this is not the case. The problem with this struct is that it is pretty...