{"id":1713,"date":"2009-06-03T21:52:15","date_gmt":"2009-06-03T21:52:15","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/dotnet\/2009\/06\/03\/in-process-side-by-side-part1\/"},"modified":"2021-10-04T15:15:48","modified_gmt":"2021-10-04T22:15:48","slug":"in-process-side-by-side-part1","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/dotnet\/in-process-side-by-side-part1\/","title":{"rendered":"In-Process Side by Side (Part1)"},"content":{"rendered":"<p>One of the new features in CLR 4 is In-Process Side-by-side (Inproc SxS) \u2013 a feature that lets you use multiple versions of .NET in the same process. For applications that use add-ins (particularly COM add-ins), in-proc SxS lets us provide a level of compatibility never before possible. If you write applications that use an add-in model (for Office or other hosts), you\u2019ll want to understand the details of in-proc SxS, so that you can make use of the new hosting APIs that provide this compatibility. If you are thinking about using .NET 4, but worried about the impact of installing .NET 4 on end user machines, then you\u2019ll want at least a high level understanding of in-proc SxS \u2013 it\u2019s the feature that makes installing a new version of .NET less impactful than ever before. Finally, even if none of the above apply to you, you still might find this interesting \u2013 it\u2019s probably the most complex change to the CLR in .NET 4.<\/p>\n<p>This is a multi-part series dedicated to in-proc side-by-side, how it works, and all it\u2019s nitty-gritty details. <\/p>\n<p>&#160;<\/p>\n<p><b>What is In-Process Side by Side? <\/b><\/p>\n<p>In-process side by side (Inproc SxS) is the ability to run multiple versions of the CLR in a single process.<\/p>\n<p>Consider the following example from years ago. John was in the IT group of a Fortune 500 company. Some of his users had a .NET 1.1 Excel add-in from a company called DevelopersRUs (not their real name). The add-in had been working well for John\u2019s users for years. When .NET 2 released, John wrote a new Excel add-in, which included a pre-requisite for the .NET 2 Framework which was then installed on their machines, and deployed it to his users.<\/p>\n<p>In most cases, Office and other applications that host managed code will use the most recent version of .NET installed on a machine. That way, the host application can run both new add-ins (like John\u2019s) and old add-ins (like the one from DevelopersRUs \u2013 keep in mind that until now you can only have one CLR loaded in the process.) The old add-ins will <i>usually <\/i>work just fine with the new runtime. When John installed his .NET 2.0 managed application on the machine, Excel started to use .NET 2.0 for <i>all<\/i> add-ins, including the DevelopersRUs one, which used to run against .NET 1.1. Now, as it happened, the DevelopersRUs application was bug-ridden in all sorts of ways \u2013 it had race conditions, depended on the internal layout of runtime data structures, and many other very bad things \u2013 all of which caused it to break when it started to run on .NET 2.0. There was nothing wrong with .NET 2.0, and nothing wrong with John\u2019s application \u2013 but installing .NET 2 on the machine caused that existing application to stop working!<\/p>\n<p>You can imagine John\u2019s users were pretty upset when this happened. John explained to them that <i>his<\/i> application was just fine, and that .NET 2 was just fine \u2013 it was a problem with this third party product. Some of them understood, but none of them were very happy.<\/p>\n<p>In fact, John would have the same problem even if he hadn\u2019t been writing an add-in for Excel \u2013 if he just wrote, say, a simple console application that pre-required .NET 2.0, he could cause the same problem, since installing his application would cause Office and other hosts to use the newest runtime!<\/p>\n<p>Fortunately, when .NET 4 comes out, John won\u2019t have this kind of problem, because of in-process side-by-side. With in-proc SxS, add-in hosts get to use the version of .NET that each add-in was built and tested with. Installing .NET 4 on a machine won\u2019t cause add-ins or applications to start using it, by default. That means that .NET 4 will be one of our least impactful new versions ever, and John can safely take a dependency on it.<\/p>\n<p>It\u2019s helpful to remember that we haven\u2019t had to deal with the full-blown version of this kind of problem for several years now. .NET 2.0, 3.0, and 3.5 were built with what we refer to as the \u201clayercake\u201d model \u2013 in which version 3.0 added functionality on top of version 2.0, and version 3.5 on top of 3.0, without changing much functionality underneath. Adding functionality is almost always non-impactful. However, .NET 4 is a major new release, and we\u2019ve made all sorts of improvements under the covers. While we\u2019ve worked very hard to keep .NET 4 as compatible as possible, 100% compatibility is impossible, so in-proc SxS is an important part of keeping compatibility as the new versions change to support evolutionary needs, though we would try our best to keep new versions highly compatible.<\/p>\n<p>The main scenario schema is shown below. A host can activate more than one CLR in its process. Each instance can load and execute as many add-ins as needed.<\/p>\n<p><a href=\"UsersaarthirAppDataLocalTempWindowsLiveWriter-429641856supfiles43F5843image%5b8%5d.png\"><img decoding=\"async\" style=\"border-bottom: 0px;border-left: 0px;border-top: 0px;border-right: 0px\" title=\"clip_image002\" border=\"0\" alt=\"clip_image002\" src=\"https:\/\/devblogs.microsoft.com\/dotnet\/wp-content\/uploads\/sites\/10\/2009\/06\/clip_image002_16e18d3b-a82d-482f-984d-e1c40153100e.gif\" width=\"396\" height=\"255\" \/><\/a><\/p>\n<p>This post provides an introduction to in-process side by side. Stay tuned for the rest of the posts on this topic. If you have any questions on this functionality, please leave a note in the comments section of this post. <\/p>\n<p>&#160;<\/p>\n<p>Luiz Fernando Santos,<\/p>\n<p>PM, CLR<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the new features in CLR 4 is In-Process Side-by-side (Inproc SxS) \u2013 a feature that lets you use multiple versions of .NET in the same process. For applications that use add-ins (particularly COM add-ins), in-proc SxS lets us provide a level of compatibility never before possible. If you write applications that use an [&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-1713","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dotnet"],"acf":[],"blog_post_summary":"<p>One of the new features in CLR 4 is In-Process Side-by-side (Inproc SxS) \u2013 a feature that lets you use multiple versions of .NET in the same process. For applications that use add-ins (particularly COM add-ins), in-proc SxS lets us provide a level of compatibility never before possible. If you write applications that use an [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/1713","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=1713"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/1713\/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=1713"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/categories?post=1713"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/tags?post=1713"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}