Product and Development Musings

ImageMan.Net and Visual Studio 2010

15. April 2010 08:26

With the release of Visual Studio 2010, some of you are probably eager to start developing new applications on (or porting existing applications to) the .NET Framework 4 and the new IDE.  You can use ImageMan.Net components in Visual Studio 2010 projects that target .Net Framework 4 but you'll need to be aware of one issue. 

According to Microsoft:

The .NET Framework 4 works side-by-side with older Framework versions.  Applications that are based on older versions of the Framework will continue to run on the version targeted by default.

However, the above statement does not hold true when the older versions involve mixed mode assemblies.  ImageMan.Net was developed on .NET Framework 2 and one of the components, DTI.ImageMan.Codecs.dll, is a mixed-mode assembly which does not get properly loaded into the .NET Framework 4 runtime without additional configuration.

Until the ImageMan.Net source is built in .NET Framework 4, you are going to have to apply a slight workaround to get the components to work properly in a .NET Framework 4 assembly.  Here's an example of the type of exception you can expect to see when you do not apply this workaround:


To cause this exception, I created a simple Windows application in Visual Studio 2010.  I dropped ImageMan.Net ThumbnailViewer, Viewer, Annotation and AnnotationToolSrip controls onto the form's design surface.  Then I built and ran the application which displayed the exception dialog above.

To fix this problem, you'll simply need to add the useLegacyV2RuntimeActivationPolicy attribute to the application's config file (app.config) like so:

    <startup useLegacyV2RuntimeActivationPolicy="true">
        <supportedRuntime version="v4.0"/>

Setting this attribute to true will allow a pre-.NET Framework 4 mixed-mode assembly to load in a .NET Framework 4 process.  With this workaround in place, you'll be able to integrate the ImageMan.Net components in your Visual Studio/.NET Framework 4 projects.  We will soon release .NET Framework 4 targeted ImageMan.Net assemblies which will not require you to modify your app.config files.

Log in