{"id":1703,"date":"2009-06-07T13:36:00","date_gmt":"2009-06-07T13:36:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/dotnet\/2009\/06\/07\/in-process-side-by-side-part-2-common-in-proc-sxs-scenarios\/"},"modified":"2021-10-04T15:15:43","modified_gmt":"2021-10-04T22:15:43","slug":"in-process-side-by-side-part-2-common-in-proc-sxs-scenarios","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/dotnet\/in-process-side-by-side-part-2-common-in-proc-sxs-scenarios\/","title":{"rendered":"In-Process Side by Side Part 2 &#8211; Common in-proc SxS scenarios"},"content":{"rendered":"<p><font color=\"red\"><b>Update: The information in this blog post applies to pre beta-1 behavior and is not applicable to beta 2 and RTM. We will have more posts and documentation on this subject as we get closer to RTM. <\/b><\/font><\/p>\n<p><font color=\"red\"><strong><\/strong>&nbsp;<\/font><\/p>\n<p>This section covers the most common&nbsp;in-process side by side scenarios. The scenarios cover which CLR is used to run the specific code, given a particular machine configuration.&nbsp;<\/p>\n<h3><font color=\"#4f81bd\"><font face=\"Cambria\"><font size=\"3\">Native Application calling Managed COM Components<span><\/p>\n<p><\/span><\/font><\/font><\/font><\/h3>\n<p class=\"MsoBodyText\"><font size=\"3\"><strong><span>Machine Configuration<\/span><\/strong><font face=\"Calibri\">:<span>&nbsp; <\/span>Both CLR 2.0 (.NET v2.0, v3.5 or v3.5) and CLR 4 installed<span><\/p>\n<p><\/span><\/font><\/font><\/p>\n<p class=\"MsoBodyText\"><font face=\"Calibri\"><font size=\"3\">In this scenario, all Legacy Managed COM Components will execute against CLR 2.0 and any call to the Global Hosting APIs, in the whole process (in the application or any assembly activated through COM or legacy API), will return CLR 2.0 results.<span>&nbsp; <\/span>Also, any activated Managed COM Components compiled against CLR 4 will execute against CLR 4, in-process side by side&nbsp;with others, compiled against CLR 2.0 (executed against CLR 2.0).<span><\/p>\n<p><\/span><\/font><\/font><\/p>\n<h3><font color=\"#4f81bd\"><font face=\"Cambria\"><font size=\"3\">Native Application calling the legacy Global Hosting APIs<span><\/p>\n<p><\/span><\/font><\/font><\/font><\/h3>\n<p class=\"MsoBodyText\"><font size=\"3\"><strong><span>Machine Configuration<\/span><\/strong><font face=\"Calibri\">:<span>&nbsp; <\/span>Both CLR 2.0 (.NET v2.0, v3.5 or v3.5)&nbsp; and CLR 4 installed<span><\/p>\n<p><\/span><\/font><\/font><\/p>\n<p class=\"MsoBodyText\"><font size=\"3\" face=\"Calibri\">In this scenario, any call to these functions, in the whole process (in the application or any assembly activated through COM or legacy API), will return CLR 2.0 results.<\/font><\/p>\n<h3><font color=\"#4f81bd\"><font face=\"Cambria\"><font size=\"3\">Managed Application compiled against v4 calling Managed COM components<span><\/p>\n<p><\/span><\/font><\/font><\/font><\/h3>\n<p class=\"MsoBodyText\"><font size=\"3\"><strong><span>Machine Configuration<\/span><\/strong><font face=\"Calibri\">:<span>&nbsp; <\/span>Both CLR 2.0 (.NET v2.0, v3.5 or v3.5)&nbsp; and CLR 4 installed<span><\/p>\n<p><\/span><\/font><\/font><\/p>\n<p class=\"MsoBodyText\"><font size=\"3\" face=\"Calibri\">In this scenario, a managed application compiled against CLR 4 calls a managed COM component compiled against CLR v1.x, CLR v2.0 or CLR 4.<span>&nbsp; <\/span>In this situation, any call to the Global Hosting APIs, in the whole process (in the application or any assembly activated through COM or legacy API), will return CLR 4 results. <span>&nbsp;<\/span>Also, any activated legacy Managed COM Components will execute against CLR 4.<\/font><\/p>\n<h3><font color=\"#4f81bd\"><font face=\"Cambria\"><font size=\"3\">Managed Application compiled against v4 using P\/Invokes to call the legacy Global Hosting APIs<span><\/p>\n<p><\/span><\/font><\/font><\/font><\/h3>\n<p class=\"MsoBodyText\"><font size=\"3\"><strong><span>Machine Configuration<\/span><\/strong><font face=\"Calibri\">:<span>&nbsp; <\/span>Both CLR 2.0 (.NET v2.0, v3 or v3.5) and CLR 4 installed<span><\/p>\n<p><\/span><\/font><\/font><\/p>\n<p class=\"MsoBodyText\"><font size=\"3\" face=\"Calibri\">In this scenario, a managed application compiled against v4 uses P\/Invoke to call the existing legacy Global Hosting APIs.<span>&nbsp; <\/span>In this situation, any call to these functions, in the whole process (in the application or any assembly activated through COM or legacy API), will return CLR 4 results.<\/font><\/p>\n<h3><font color=\"#4f81bd\" size=\"3\" face=\"Cambria\">Managed Application compiled against v2 calling Managed COM components compiled against CLR 4<\/font><\/h3>\n<p class=\"MsoBodyText\"><font size=\"3\"><strong><span>Machine Configuration<\/span><\/strong><font face=\"Calibri\">:<span>&nbsp; <\/span>Both CLR 2.0 (.NET v2.0, v3.0 or v3.5) and CLR 4 installed<span><\/p>\n<p><\/span><\/font><\/font><\/p>\n<p class=\"MsoBodyText\"><font size=\"3\" face=\"Calibri\">In this scenario, a managed application compiled against CLR 2.0 calls a managed COM component compiled against CLR 4. <span>&nbsp;<\/span>In this scenario, any activated Managed COM Components will execute against CLR 4 in-process side by side with CLR 2.0.<\/font><\/p>\n<h2><font color=\"#4f81bd\" size=\"4\" face=\"Cambria\">What are the most common non-default scenarios?<\/font><\/h2>\n<p class=\"MsoBodyText\"><font face=\"Calibri\"><font size=\"3\"><span>This section illustrates some common scenarios and the corresponding configuration file entries in order to get the right results.<\/span><span><\/p>\n<p><\/span><\/font><\/font><\/p>\n<h3><font color=\"#4f81bd\"><font face=\"Cambria\"><font size=\"3\">Native Application rolling forward all its Managed COM Components to CLR 4<span><\/p>\n<p><\/span><\/font><\/font><\/font><\/h3>\n<p class=\"MsoBodyText\"><font size=\"3\"><strong><span>Machine Configuration<\/span><\/strong><font face=\"Calibri\"><span>:<span>&nbsp; <\/span>CLR 4 installed (other CLRs can be installed also, but in this case, this is irrelevant)<\/span><span><\/p>\n<p><\/span><\/font><\/font><\/p>\n<p class=\"MsoBodyText\"><font size=\"3\"><font face=\"Calibri\">In this scenario, a native application needs to activate all its managed COM components (independently of the CLR version they were compiled against) using CLR 4. <span>&nbsp;<\/span>In this situation, an APP.CONFIG file needs to be included in the same directory of the native application (EXE) with the following entry:<span><\/p>\n<p><\/span><\/font><\/font><\/p>\n<p class=\"MsoBodyText\"><span><font face=\"Calibri\">&lt;startup&gt;<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"MsoBodyText\"><span><font face=\"Calibri\">&lt;process&gt;<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"MsoBodyText\"><span><font face=\"Calibri\">&lt;rollForward enabled=&#8221;true&#8221; \/&gt;<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"MsoBodyText\"><span><font face=\"Calibri\">&lt;\/process&gt;<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"MsoBodyText\"><span><font face=\"Calibri\">&lt;\/startup&gt;<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"MsoBodyText\"><font size=\"3\" face=\"Calibri\">This configuration will force all Managed COM Components to execute against CLR 4.<\/font><\/p>\n<h3><font color=\"#4f81bd\"><font face=\"Cambria\"><font size=\"3\">Native Application using legacy Global Hosting APIs to return CLR 4 results<span><\/p>\n<p><\/span><\/font><\/font><\/font><\/h3>\n<p class=\"MsoBodyText\"><font size=\"3\"><strong><span>Machine Configuration<\/span><\/strong><font face=\"Calibri\">: <span>&nbsp;<\/span>.NET 4 installed (other CLRs can be installed also, but in this case, this is irrelevant)<\/font><\/font><\/p>\n<p class=\"MsoBodyText\"><font size=\"3\"><font face=\"Calibri\"><span>In this scenario, a native application uses the existing Global Hosting APIs to return CLR 4 results.<span>&nbsp; <\/span>To accomplish that, an APP.CONFIG file needs to be included in the same directory of the native application with the following entry:<\/span><span><\/p>\n<p><\/span><\/font><\/font><\/p>\n<p class=\"MsoBodyText\"><span><font face=\"Calibri\">&lt;startup&gt;<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"MsoBodyText\"><span><font face=\"Calibri\">&lt;process&gt;<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"MsoBodyText\"><span><font face=\"Calibri\">&lt;rollForward enabled=&#8221;true&#8221; \/&gt;<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"MsoBodyText\"><span><font face=\"Calibri\">&lt;\/process&gt;<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"MsoBodyText\"><span><font face=\"Calibri\">&lt;\/startup&gt;<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"MsoBodyText\"><font face=\"Calibri\"><font size=\"3\">This configuration will force all Managed COM Components to execute against CLR 4.<span>&nbsp; <\/span>It&#8217;s important to note that some Global Hosting APIs may not be affected by the APP.CONFIG file above.<span><\/p>\n<p><\/span><\/font><\/font><\/p>\n<h3><font color=\"#4f81bd\" size=\"3\" face=\"Cambria\">Managed Application compiled against v2 rolling forward to execute against CLR 4<\/font><\/h3>\n<p class=\"MsoBodyText\"><font size=\"3\"><strong><span>Machine Configuration<\/span><\/strong><font face=\"Calibri\">: <span>&nbsp;<\/span>.NET 4 installed (other CLRs can be installed also, but in this case, this is irrelevant)<\/font><\/font><\/p>\n<p class=\"MsoBodyText\"><font size=\"3\" face=\"Calibri\">In this scenario, a managed application compiled against v2.0 needs to execute against CLR 4.<span>&nbsp; <\/span>In this situation, an APP.CONFIG file needs to be included in the same directory of the managed application (EXE) with the following entry.<\/font><\/p>\n<p class=\"MsoBodyText\"><span><font face=\"Calibri\">&lt;startup&gt;<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"MsoBodyText\"><span><font face=\"Calibri\">&lt;supportedRuntime version=&#8221;v4.0.XXXX&#8221; \/&gt;<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"MsoBodyText\"><span><font face=\"Calibri\">&lt;\/startup&gt;<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"MsoBodyText\"><font size=\"3\" face=\"Calibri\">Where XXXXX is the CLR build number. <span>&nbsp;<\/span>In this situation, any Managed COM Component activated by this application will also roll forward to CLR 4. <span>&nbsp;<\/span>Also, any Global Hosting API call in the whole process (in the application or in any of the Managed COM components) will return CLR 4 results (for example, <b><span>CorBindToRuntime(pwszVersion=NULL)<\/span><\/b><span> or <b>GetCORSystemDirectory<\/b><\/span>).<\/font><\/p>\n<h3><font color=\"#4f81bd\" size=\"3\" face=\"Cambria\">Managed Application compiled against v4 turning on In-process Side By Side<\/font><\/h3>\n<p class=\"MsoBodyText\"><font size=\"3\"><strong><span>Machine Configuration<\/span><\/strong><font face=\"Calibri\">:<span>&nbsp; <\/span>Both CLR 2.0 (.NET v2.0, v3.0 or v3.5) and CLR 4 installed<\/font><\/font><\/p>\n<p class=\"MsoBodyText\"><font size=\"3\" face=\"Calibri\">In this scenario, a managed application compiled against CLR 4 needs to activate Managed COM Components compiled against CLR 4 side by side with Managed COM Components compiled against CLR 2.0 (or previous version).<span>&nbsp; <\/span>In this situation, an APP.CONFIG file needs to be included in the same directory of the managed application (EXE) with the following entry.<\/font><\/p>\n<p class=\"MsoBodyText\"><span><font face=\"Calibri\">&lt;startup&gt;<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"MsoBodyText\"><span><font face=\"Calibri\">&lt;process&gt;<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"MsoBodyText\"><span><font face=\"Calibri\">&lt;rollForward enabled=&#8221;false&#8221; \/&gt;<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"MsoBodyText\"><span><font face=\"Calibri\">&lt;\/process&gt;<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"MsoBodyText\"><span><font face=\"Calibri\">&lt;\/startup&gt;<\/p>\n<p><\/font><\/span><\/p>\n<h3><font color=\"#4f81bd\"><font face=\"Cambria\"><font size=\"3\">Managed Application compiled against v2 running against v4 and turning on In-process Side By Side<span><\/p>\n<p><\/span><\/font><\/font><\/font><\/h3>\n<p class=\"MsoBodyText\"><font size=\"3\"><strong><span>Machine Configuration<\/span><\/strong><font face=\"Calibri\">: <span>&nbsp;<\/span>Both CLR 2.0 (.NET v2.0, v3.5 or v3.5) and CLR 4 installed<\/font><\/font><\/p>\n<p class=\"MsoBodyText\"><font size=\"3\"><font face=\"Calibri\"><span>In this scenario, a managed application compiled against CLR 2.0 needs to run against CLR 4 and also needs to activate Managed COM Components compiled against CLR 4 side by side with Managed COM Components compiled against CLR 2.0 (or previous version).<span>&nbsp; <\/span>In this situation, an APP.CONFIG file needs to be included in the same directory of the managed application (EXE) with the following entry.<\/span><span><\/p>\n<p><\/span><\/font><\/font><\/p>\n<p class=\"MsoBodyText\"><span><font face=\"Calibri\">&lt;startup&gt;<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"MsoBodyText\"><span><font face=\"Calibri\">&lt;supportedRuntime version=&#8221;v4.0.XXXXX&#8221; \/&gt;<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"MsoBodyText\"><span><font face=\"Calibri\">&lt;supportedRuntime version=&#8221;v2.0.50727&#8243; \/&gt;<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"MsoBodyText\"><span><font face=\"Calibri\">&lt;process&gt;<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"MsoBodyText\"><span><font face=\"Calibri\">&lt;rollForward enabled=&#8221;false&#8221; \/&gt;<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"MsoBodyText\"><span><font face=\"Calibri\">&lt;\/process&gt;<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"MsoBodyText\"><span><font face=\"Calibri\">&lt;\/startup&gt;<\/p>\n<p><\/font><\/span><\/p>\n<p class=\"MsoNormal\"><font size=\"3\" face=\"Calibri\">&nbsp;<\/font><\/p>\n<p>&nbsp;<\/p>\n<p><strike><\/strike>&nbsp;<\/p>\n<p>Luiz Fernando Santos,<\/p>\n<p>PM, CLR<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Update: The information in this blog post applies to pre beta-1 behavior and is not applicable to beta 2 and RTM. We will have more posts and documentation on this subject as we get closer to RTM. &nbsp; This section covers the most common&nbsp;in-process side by side scenarios. The scenarios cover which CLR is used [&hellip;]<\/p>\n","protected":false},"author":342,"featured_media":58792,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[685],"tags":[],"class_list":["post-1703","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dotnet"],"acf":[],"blog_post_summary":"<p>Update: The information in this blog post applies to pre beta-1 behavior and is not applicable to beta 2 and RTM. We will have more posts and documentation on this subject as we get closer to RTM. &nbsp; This section covers the most common&nbsp;in-process side by side scenarios. The scenarios cover which CLR is used [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/1703","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/users\/342"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/comments?post=1703"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/1703\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media\/58792"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media?parent=1703"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/categories?post=1703"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/tags?post=1703"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}