Monday, October 19, 2009

CLR and Framework Loading...

  1. Very Good notes:http://social.msdn.microsoft.com/forums/en-US/clr/thread/e392129d-33fa-46e6-a518-2e971ce37d82
  2. What CLR version am I or me or this? http://www.devfish.net/articles/clrver/article_CLRVer.htm
  3. Determining Which Version of the Runtime to Load http://msdn.microsoft.com/en-us/library/w671swch.aspx
  4. Runtime Initialization from a COM Application http://msdn.microsoft.com/en-us/library/hz1www0a(VS.80).aspx
  5. Very Good Article:http://msmvps.com/blogs/carlosq/archive/2008/11/14/net-frameworks-clrs-and-visual-studio-add-ins.aspx

    snippet:
    We have two kinds of .NET Frameworks: -
    Side-by-side model:
    the .NET Framework is installed independently of other .NET Frameworks (it coexists with them). It uses its own CLR and it is complete. This is the case of .NET Framework 1.0 (VS.NET 2002), .NET Framework 1.1 (VS.NET 2003) and .NET Framework 2.0 (VS 2005).-
    Layer cake model:
    The .NET Framework is installed on top of other .NET Framework. It uses an existing CLR (not providing a new one) and it just supplies additional libraries. This is the case of the .NET Framework 3.0 (which introduced WPF, WF and WCF, but used CLR 2.0) and the .NET Framework 3.5 (VS 2008, it uses CLR 2.0 too). Notice that there is no CLR 3.0 or CLR 3.5.Only VS 2008 can target several .NET Frameworks (2.0, 3.0 or 3.5). Previous VS versions can only target the .NET Framework they introduced.An assembly compiled against a .NET Framework can run on ulterior .NET Frameworks (and CLRs) without problems (at least in theory, more on this later). For example, a .NET 1.0 assembly can run on a .NET 1.1 Framework. The opposite is not true for two reasons:- An assembly compiled against a given CLR can not run on a previous CLR. For example, an assembly compiled against CLR 2.0 can not run on CLR 1.0 or 1.1 (they know nothing about generics, for example).- An assembly compiled against a .NET Framework can not run on a previous .NET Framework, even if it shares the same CLR, because of missing libraries. For example, an assembly compiled against the .NET Framework 3.5 using WPF cannot run on the .NET Framework 2.0 despite both use the CLR 2.0 because a machine with only the .NET Framework 2.0 would lack the WPF libraries.

    There is an tool called clrver.exe which is shipped with the SDK for .Net 2.0 , you can find the tool under C:\Programme\Microsoft Visual Studio 8\SDK\v2.0\Bin
    If you use the clrver.exe tool without arguments you get the following output:C:\Programme\Microsoft Visual Studio 8\VC>clrver.exeVersions installed on the machine:v2.0.50727You can use all / argument to get more detailed information.-all - Displays all processes on the machine using the CLR. - Displays the version of the CLR used by the specified process.
    Thus you can get detail information about the running processes.
    3920 devenv.exe v2.0.507272084 WebDev.WebServer.EXE v2.0.507272944 Obab.UI.ProfessorenClientCab.vshost.exe v2.0.50727
    Unfortunatley, you can only get the information from running applications. There is no way to let clrver.exe determine the required/used framework version from the application file itself.
    =============Most applications will never need this config file entry. With the way the runtime version is chosen for most apps, the application gets the version of the runtime it was built against (if available on the machine). If the exe is managed it gets the described behavior. If the exe that launches the process is native but has a config file it gets the runtime specified in the config file. If the exe that launches the process is native and there is no config file then we are forced to choose the latest runtime version.
    Console.WriteLine(System.Reflection.Assembly.LoadFile(@"C:\Program Files\ Microsoft BizTalk Server 2006\ Microsoft.XLANGs.BizTalk.Engine.dll").ImageRuntimeVersion);
    The exception is being caused by the .NET framework because key parts of the framework contain version 2.0 specific code. When Visual Studio 2005 is used to create an application, the default CLR target is version 2.0. Previous versions of the framework cannot be loaded. See the More Info section on how to reproduce the issue. Visual Studio 2003 works without issue for versions previous to CLR 1.1. Visual Studio 2005 and Visual Studio 2008 fail consistently when the CLR target is less than version 2.0 of the CLR. CLR targets including 2.0 and later work as intended.
    CLR /Framework Versionshttp://blogs.msdn.com/davbr/archive/2007/12/06/versions-of-microsoft-net-framework-clr-and-your-profiler.aspx
    if your add-in is intended for VB.NET/C# a single binary can target VS.NET 2002/2003 and a different binary can target VS 2005/2008 (a single binary can't target all because VS 2005 introduced a new DLL for commandbars). First, some clarifications about .NET Framework and Common Language Runtimes (CLRs):