You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am not able to load the module, which has System.ServiceModel.Primitives dependency.
Simply load the module in the powershell 7.
Example:-
[System.Reflection.Assembly]::LoadFrom('< path to the folder contains System.ServiceModel.Primitives.dll>')
Add-Type -Path "< path to the folder contains System.ServiceModel.Primitives.dll>"
Both the commands results in Could not load file or assembly 'System.ServiceModel.Primitives, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Expected behavior
PS C:\Users\Administrator> [System.Reflection.Assembly]::LoadFrom('C:\_RajRepo\Master\orion\cliffhanger\Bin\Debug\net8.0\publish\win-x64\System.ServiceModel.Primitives.dll')PS C:\Users\Administrator> Add-Type -Path "C:\_RajRepo\Master\orion\cliffhanger\Bin\Debug\net8.0\publish\win-x64\System.ServiceModel.Primitives.dll"Expectation - should load the dll
Actual behavior
PS C:\Users\Administrator> [System.Reflection.Assembly]::LoadFrom('C:\_RajRepo\Master\orion\cliffhanger\Bin\Debug\net8.0\publish\win-x64\System.ServiceModel.Primitives.dll')MethodInvocationException: Exception calling "LoadFrom" with "1" argument(s): "Could not load file or assembly 'System.ServiceModel.Primitives, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'."PS C:\Users\Administrator> Add-Type -Path "C:\_RajRepo\Master\orion\cliffhanger\Bin\Debug\net8.0\publish\win-x64\System.ServiceModel.Primitives.dll"Add-Type: Could not load file or assembly 'System.ServiceModel.Primitives, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Error details
Could not load file or assembly 'System.ServiceModel.Primitives, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Environment data
PS C:\Users\Administrator>$PSVersionTable
Name Value
---------
PSVersion 7.4.1
PSEdition Core
GitCommitId 7.4.1
OS Microsoft Windows 10.0.20348
Platform Win32NT
PSCompatibleVersions {1.0,2.0,3.0,4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visuals
No response
The text was updated successfully, but these errors were encountered:
If you are just writing a script then you have a major challenge, but if you are writing a C #cmdlet then you can set up an Assembly Load Context.
The problem is a single load context can only load one version of a named shared assembly. So you can create a child load context and load your conflicting assemblies into that.
I have just just gone through this process with one of my modules, where I load the Postgres Database Connection into the child Assembly Load Context but can share objects created within that load context through my cmdlet, the Alc module is the bridging assembly that allows objects to be shared across the divide.
The assemblies within the lib directory run in the child Alc.
Prerequisites
Steps to reproduce
I am not able to load the module, which has System.ServiceModel.Primitives dependency.
Simply load the module in the powershell 7.
Example:-
[System.Reflection.Assembly]::LoadFrom('< path to the folder contains System.ServiceModel.Primitives.dll>')
Add-Type -Path "< path to the folder contains System.ServiceModel.Primitives.dll>"
Both the commands results in Could not load file or assembly 'System.ServiceModel.Primitives, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Expected behavior
Actual behavior
Error details
Could not load file or assembly 'System.ServiceModel.Primitives, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Environment data
Visuals
No response
The text was updated successfully, but these errors were encountered: