Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PowerShell Internal Host Fails with Mixed Mode #640

Open
ferventcoder opened this issue Feb 19, 2016 · 14 comments
Open

PowerShell Internal Host Fails with Mixed Mode #640

ferventcoder opened this issue Feb 19, 2016 · 14 comments

Comments

@ferventcoder
Copy link
Member

ferventcoder commented Feb 19, 2016

https://gist.github.com/anonymous/0791bb8be637bb20205a#file-output-log-L188-L194

VERBOSE: Loading module from path 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\BitsTransfer\BitsTransfer.psd1'.
VERBOSE: Loading 'Assembly' from path 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\BitsTransfer\Microsoft.BackgrundIntelligentTransfer.Management.Interop.dll'.
VERBOSE: Loading 'FormatsToProcess' from path 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\BitsTransfer\BitsTranfer.Format.ps1xml'.
ERROR: Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.

Workaround

Use the switch --use-system-powershell until this issue is resolved.

@ferventcoder
Copy link
Member Author

Oh no - https://technet.microsoft.com/en-us/library/hh849725.aspx :

  • If you attempt to import a module that contains mixed-mode assemblies that are not compatible with Windows PowerShell 3.0, Import-Module returns an error message like the following one.

Import-Module : Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.

This error occurs when a module that is designed for Windows PowerShell 2.0 contains at least one mixed-module assembly, that is, an assembly that includes both managed and non-managed code, such as C++ and C#.

To import a module that contains mixed-mode assemblies, start Windows PowerShell 2.0 by using the following command, and then try the Import-Module command again.

PowerShell.exe -Version 2.0

@ferventcoder
Copy link
Member Author

This is exactly the issue - http://stackoverflow.com/q/9164260/18475

@ferventcoder ferventcoder modified the milestones: 0.10.3, 0.10.2 Sep 20, 2016
@ferventcoder ferventcoder modified the milestones: 0.10.3, 0.10.4 Oct 3, 2016
@ferventcoder ferventcoder modified the milestones: 0.10.4, 0.10.5 Jan 6, 2017
@ferventcoder ferventcoder modified the milestones: 0.10.5, 0.10.6, 0.10.7 Mar 30, 2017
@ferventcoder ferventcoder modified the milestones: 0.10.7, 0.10.8 Jun 6, 2017
@MichaelGerhart
Copy link

Good Afternoon,

I also just encountered this issue while trying to use Invoke-SqlCmd within a package. Is there any ETA on when a fix will be issued? I am currently using the workaround above by temporarily creating choco.exe.config during runtime and deleting it at the end of the install script.

@mattheyan
Copy link

@michaelgg13 I created a package for it as recommended by Rob, which just creates a minimal config for choco. The down-side of course is that you have to remember to install it everywhere or add it as a dependency of packages that need it, which isn't always obvious. (This actually caused a lot of pain for us). I can provide the package if you want.

@ferventcoder If there are no immediate plans to fix the issue, would it be appropriate to publish a package for the fix as a workaround in the meantime?

@ferventcoder ferventcoder added this to the 0.10.x milestone Aug 17, 2017
@ferventcoder
Copy link
Member Author

@mattheyan @michaelgg13 A package to fix this would be fine for now. It would also allow folks on older versions of choco to benefit once this is fixed. It's hard to determine the right way to fix this - there are some more secure things when we are in the .NET 4.x runtime that may be lost in .Net 2.x runtime (IIRC from my initial research).

@aledeniz
Copy link

Just to let you know I have experienced this in choco v0.10.15 on Windows 2012 R2 when running

choco install sp2013prereqs

2019-08-13 19:18:03,610 5908 [INFO ] - Downloading SharePoint 2013 prerequisite to folder:[C:\ProgramData\chocolatey\lib\SP2013PreReqs\download]
2019-08-13 19:18:03,610 5908 [INFO ] - VERBOSE: Loading module from path 'C:\windows\system32\WindowsPowerShell\v1.0\Modules\BitsTransfer\BitsTransfer.psd1'.
2019-08-13 19:18:03,626 5908 [INFO ] - VERBOSE: Loading 'Assembly' from path 'C:\windows\system32\WindowsPowerShell\v1.0\Modules\BitsTransfer\Microsoft.BackgroundIntelligentTransfer.Management.Interop.dll'.
2019-08-13 19:18:03,626 5908 [INFO ] - VERBOSE: Loading 'Assembly' from path 'C:\windows\system32\WindowsPowerShell\v1.0\Modules\BitsTransfer\Microsoft.BackgroundIntelligentTransfer.Management.Interop.dll'.
2019-08-13 19:18:03,641 5908 [INFO ] - VERBOSE: Loading 'FormatsToProcess' from path 'C:\windows\system32\WindowsPowerShell\v1.0\Modules\BitsTransfer\BitsTransfer.Format.ps1xml'.
2019-08-13 19:18:03,673 5908 [DEBUG] - Running Write-ChocolateyFailure -packageName 'SP2013PreReqsOnline' -failureMessage 'Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.' 
2019-08-13 19:18:03,688 5908 [WARN ] - WARNING: Write-ChocolateyFailure is deprecated and will be removed in v2. If you are the package maintainer, please use 'throw $_.Exception' instead.
2019-08-13 19:18:03,688 5908 [ERROR] - ERROR: Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.

The suggested work around did work:

choco install sp2013prereqs --verbose --log-file=C:\ProgramData\chocolatey\logs\sp2013prereqs.log --use-system-powershell

Weirdly, I didn't need the work around on Windows 2019.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants