Title: Workarounds in loading assembly with different versions · Issue #11571 · PowerShell/PowerShell · GitHub
Open Graph Title: Workarounds in loading assembly with different versions · Issue #11571 · PowerShell/PowerShell
X Title: Workarounds in loading assembly with different versions · Issue #11571 · PowerShell/PowerShell
Description: In our particular case, we have a custom shell around ConsoleShell that upon start up loads Microsoft.WindowsAzure.Storage.dll into the current app domain. Once the shell is up, we couldn't import for example Az.Accounts module because i...
Open Graph Description: In our particular case, we have a custom shell around ConsoleShell that upon start up loads Microsoft.WindowsAzure.Storage.dll into the current app domain. Once the shell is up, we couldn't import ...
X Description: In our particular case, we have a custom shell around ConsoleShell that upon start up loads Microsoft.WindowsAzure.Storage.dll into the current app domain. Once the shell is up, we couldn't imp...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/11571
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Workarounds in loading assembly with different versions","articleBody":"In our particular case, we have a custom shell around `ConsoleShell` that upon start up loads `Microsoft.WindowsAzure.Storage.dll` into the current app domain. Once the shell is up, we couldn't import for example `Az.Accounts` module because it depends on a different version of `Microsoft.WindowsAzure.Storage.dll`. Since this is a more general problem with PowerShell Core, I posted the issue here instead of over at Azure PowerShell. Effectively, I'm looking for a workaround for issue https://github.com/PowerShell/PowerShell/issues/2083.\r\n\r\n## Attempt 1:\r\ncustom assembly resolve\r\n```\r\nusing Microsoft.PowerShell;\r\nusing System;\r\nusing System.Diagnostics;\r\nusing System.Reflection;\r\n\r\nnamespace Test\r\n{\r\n class Program\r\n {\r\n static void Main(string[] args)\r\n {\r\n AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve;\r\n\r\n ConsoleShell.Start(\"Hello\", \"\", new string[0] { });\r\n }\r\n\r\n private static Assembly OnAssemblyResolve(object sender, ResolveEventArgs args)\r\n {\r\n Debugger.Launch();\r\n return null;\r\n }\r\n }\r\n}\r\n```\r\n```\r\n\u003cProject Sdk=\"Microsoft.NET.Sdk\">\r\n\r\n \u003cPropertyGroup>\r\n \u003cOutputType>Exe\u003c/OutputType>\r\n \u003cTargetFramework>netcoreapp3.1\u003c/TargetFramework>\r\n \u003c/PropertyGroup>\r\n\r\n \u003cItemGroup>\r\n \u003cPackageReference Include=\"Microsoft.PowerShell.SDK\" Version=\"7.0.0-rc.1\" />\r\n \u003c/ItemGroup>\r\n\r\n \u003cItemGroup>\r\n \u003cReference Include=\"Microsoft.PowerShell.ConsoleHost\">\r\n \u003cHintPath>$(NuGetPackageRoot)\\microsoft.powershell.consolehost\\7.0.0-rc.1\\runtimes\\win\\lib\\netcoreapp3.1\\Microsoft.PowerShell.ConsoleHost.dll\u003c/HintPath>\r\n \u003c/Reference>\r\n \u003c/ItemGroup>\r\n\r\n\u003c/Project>\r\n```\r\n## Problem:\r\nWhen run two import (`Import-Module C:\\version1\\assembly.dll; Import-Module C:\\version2\\assembly.dll`) with different versions of the assembly, I hit error of `Import-Module: Assembly with same name is already loaded` but the `AssemblyResolve` event was not raised. \r\n\r\n## Attempt 2:\r\nbinding redirect through config file\r\n```\r\n\u003cassemblyBinding xmlns=\"urn:schemas-microsoft-com:asm.v1\">\r\n \u003cdependentAssembly>\r\n \u003cassemblyIdentity name=\"Microsoft.WindowsAzure.Storage\" publicKeyToken=\"31bf3856ad364e35\" culture=\"neutral\" />\r\n \u003cbindingRedirect oldVersion=\"0.0.0.0-9.3.3.0\" newVersion=\"9.3.3.0\" />\r\n \u003c/dependentAssembly>\r\n\u003c/assemblyBinding>\r\n```\r\n## Problem:\r\nRun into the same error above\r\n\r\n## Attempt 3:\r\nrun any external commands with Invoke-Command -Session, this basically out-sourced the command on a different app domain and avoid the version collision.\r\n## Problem:\r\nThis seems to be the only workaround I can come up with, but it's really inconvenient to jump back and forth PS sessions.\r\n\r\n## Question:\r\nAny better workaround?","author":{"url":"https://github.com/ritchxu","@type":"Person","name":"ritchxu"},"datePublished":"2020-01-13T19:13:24Z","url":"https://github.com/PowerShell/PowerShell/issues/11571"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:3a1c3536-1838-9ec9-5e9b-606efd3258a2 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E40E:238DBE:F5725:15B86B:6AFD4C78 |
| html-safe-nonce | f15d4e24914b82895c0726f8a4e3f326c83dec4789d86bc99f89149a1a786f9a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNDBFOjIzOERCRTpGNTcyNToxNUI4NkI6NkFGRDRDNzgiLCJ2aXNpdG9yX2lkIjoiMTU2MzU2MTMyMzgyMjY2NDgyNCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | a49c085bcbd039adb57d6487a33a3e418792b3b1bd47430a27e88738e6be6bdb |
| hovercard-subject-tag | issue:549126619 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/11571/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c599e4f3a2871f2e4df157f5938a2202067cd895502a3c9afc1cfcc884d21b84/PowerShell/PowerShell/issues/11571 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c599e4f3a2871f2e4df157f5938a2202067cd895502a3c9afc1cfcc884d21b84/PowerShell/PowerShell/issues/11571 |
| og:image:alt | In our particular case, we have a custom shell around ConsoleShell that upon start up loads Microsoft.WindowsAzure.Storage.dll into the current app domain. Once the shell is up, we couldn't import ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ritchxu |
| hostname | github.com |
| expected-hostname | github.com |
| None | 66653c2e55a6fff2930be1bdf07ee4f8aa137e3956d056c822563be6f878755e |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | b6f01f7cb9f35f8c09949773241a3d49dd04b340 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width