Infralution Support Forum Index Infralution Support
Support groups for Infralution products
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Using RichText with .NET 4

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Infralution Support Forum Index -> Virtual Tree FAQ
View previous topic :: View next topic  
Author Message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Tue Jan 25, 2011 10:46 pm    Post subject: Using RichText with .NET 4 Reply with quote

This FAQ applies to Virtual Tree versions prior to 4.2. If you compile an application against the .NET 4 Framework and are using RichText with Virtual Tree versions prior to 4.2 then you may encounter a FileLoadException when the application is run with the following message:

Quote:
Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information


The problem is that in .NET 4 Microsoft decided (by default) to not keep backward compatibility for loading mixed mode assemblies compiled using C++ against .NET 2. The Infralution.RichText assembly is compiled against .NET 2 to allow for backward compatibility and so cannot by default be used in a .NET 4 application.

In Version 4.2 (and later) of Virtual Tree Rich Text rendering is implemented entirely in managed code eliminating the need for the Infralution.RichText assembly and avoiding this problem.

If you need to use RichText in a .NET 4 application you can fix this issue by adding a configuration file for your application with the following Startup attribute:

Code:
<configuration>
  <startup useLegacyV2RuntimeActivationPolicy="true">
  </startup>
</configuration>


This enables backward compatible loading of mixed mode assemblies. Mixed mode assemblies compiled against .NET 4 will still load OK as well.

It is also possible to set this configuration programmatically by adding the following method (EnableCLR2Binding) to your application and calling it before your application loads any assemblies:

Code:
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("BD39D1D2-BA2F-486A-89B0-B4B0CB466891")]
interface ICLRRuntimeInfo
{
    void xGetVersionString();
    void xGetRuntimeDirectory();
    void xIsLoaded();
    void xIsLoadable();
    void xLoadErrorString();
    void xLoadLibrary();
    void xGetProcAddress();
    void xGetInterface();
    void xSetDefaultStartupFlags();
    void xGetDefaultStartupFlags();
    [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
    void BindAsLegacyV2Runtime();
}

private static void EnableCLR2Binding()
{
    ICLRRuntimeInfo rtInfo = (ICLRRuntimeInfo)RuntimeEnvironment.GetRuntimeInterfaceAsObject(Guid.Empty, typeof(ICLRRuntimeInfo).GUID);
    rtInfo.BindAsLegacyV2Runtime();
}

_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Infralution Support Forum Index -> Virtual Tree FAQ All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group