Add-Type : Could not load file or assembly 'System.Web.Extensions, Version=3.5.0.0, ..."

Hi,

I’m running into the following mysterious error in my “Deploy package to IIS” step.

16:09:44   Verbose  |       Creating 'd:\inetpub\ibe\Octopus.Features.IISWebSite_BeforePostDeploy.ps1' from embedded resource
16:09:44   Verbose  |       Executing 'd:\inetpub\ibe\Octopus.Features.IISWebSite_BeforePostDeploy.ps1'
16:09:45   Verbose  |       Name                           Value
16:09:45   Verbose  |       ----                           -----
16:09:45   Verbose  |       CLRVersion                     2.0.50727.5485
16:09:45   Verbose  |       BuildVersion                   6.1.7601.17514
16:09:45   Verbose  |       PSVersion                      2.0
16:09:45   Verbose  |       WSManStackVersion              2.0
16:09:45   Verbose  |       PSCompatibleVersions           {1.0, 2.0}
16:09:45   Verbose  |       SerializationVersion           1.1.0.1
16:09:45   Verbose  |       PSRemotingProtocolVersion      2.1
16:09:45   Verbose  |       Could not load AesCryptoServiceProvider, falling back to RijndaelManaged (.NET 2.0).
16:09:45   Verbose  |       Could not load AesCryptoServiceProvider, falling back to RijndaelManaged (.NET 2.0).
16:09:45   Error    |       Add-Type : Could not load file or assembly 'System.Web.Extensions, Version=3.5.
16:09:45   Error    |       0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependenci
16:09:45   Error    |       es. The system cannot find the file specified.
16:09:45   Error    |       At D:\inetpub\ibe\Octopus.Features.IISWebSite_BeforePostDeploy.ps1:89 char:11
16:09:45   Error    |       +         add-type <<<<  -assembly system.web.extensions
16:09:45   Error    |       + CategoryInfo          : NotSpecified: (:) [Add-Type], FileNotFoundExcept
16:09:45   Error    |       ion
16:09:45   Error    |       + FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.PowerS
16:09:45   Error    |       hell.Commands.AddTypeCommand
16:09:45   Verbose  |       Deleting 'd:\inetpub\ibe\Octopus.Features.IISWebSite_BeforePostDeploy.ps1'
16:09:45   Error    |       Script 'd:\inetpub\ibe\Octopus.Features.IISWebSite_BeforePostDeploy.ps1' returned non-zero exit code: 1
16:09:45   Error    |       Running rollback conventions...
16:09:45   Verbose  |       Adding journal entry:
16:09:45   Verbose  |       <Deployment Id="427e8cf6-55bb-4e7a-a925-7a0881e5f94d" EnvironmentId="Environments-6" ProjectId="Projects-3" PackageId="Airtrade.IBEA.Web" PackageVersion="8.0.0.31" InstalledOn="2015-12-01 15:09:43" ExtractedFrom="D:\Octopus\Files\Airtrade.IBEA.Web.8.0.0.31.nupkg-6efe34aa-5a6b-4a32-8e4f-57d978970066" ExtractedTo="D:\Octopus\Applications\Production A\Airtrade.IBEA.Web\8.0.0.31_7" RetentionPolicySet="Environments-6/Projects-3/Step-Deploy application in IIS/Machines-41/&lt;default&gt;" CustomInstallationDirectory="d:\inetpub\ibe" WasSuccessful="False" />
16:09:45   Error    |       Script 'd:\inetpub\ibe\Octopus.Features.IISWebSite_BeforePostDeploy.ps1' returned non-zero exit code: 1
16:09:45   Fatal    |       The remote script failed with exit code 1

I’m on 3.2.7, but have tried 3.2.5 too and both fail with the same error.

I’ve attached the log file. Is it something I’m doing wrong…?

Thanks, Pascal

ServerTasks-5598.log.txt (154 KB)

Hi Pascal,

It looks like a problem finding .NET assemblies. What version of Windows is your Tentacle running on?

Do you know which versions of .NET framework are installed on that Tentacle?

Cheers,
Shane

Hi Shane,

I doubt it has anything to do with the versions of Windows or the .NET assemblies, since I’ve been able to successfully deploy to a number of these servers last week.

But anyhow: this is Windows Server 2008 R2 Standard 64 bit. See the attached screenshot for the versions of the frameworks installed.

Thanks, Pascal.

BTW, the difference with the servers on which the deployment does work, is that they have the System.Web.Extensions, Version=3.5.0.0 installed in the C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5 folder. I don’t know with what software that got installed, but there is not .NET Framework 3.5 installed explicitly.

Anyhow: on the servers that don’t have this package installed in this folder, Octopus deployments worked before, so it seems strange that this needs to be a prerequisite now…

Pascal.

Hi Pascal,

I think the issue is the incompatibility between CLR and .NET version on those Tentacles. You are running CLR 2.0 with .NET 4.5.2 which are incompatible. You have (somehow) .NET 3.5 on the Tentacles that work. See here for .NET framework CLR versions: https://msdn.microsoft.com/en-us/library/bb822049(v=vs.110).aspx

I think the solution would be to install .NET 3.5.1 or update the PowerShell version on the Tentacle. It does seem odd that the deployments were working before and is certainly frustrating when they suddenly stop working.

I hope this helps.

Cheers,
Shane

Shane,

I see what you mean. The $PSVersion says it’s using CLRVersion 2.0.50727.5485. But then I’m wondering: how does the correct CLRVersion get used “out of the box”? Your tentacle requirements state that I need .NET 4.5+ and Powershell 2.0, which (as you state) “is automatically installed on 2008 R2”. That is exactly what we have, but still it does not work. Is there something you need to add to this requirement then?

Since you put me on path that the Powershell CLRVersion was wrong, I did some searching and found that I can explicitly set Powershell to use CLRVersion 4 by creating the following config file:

<?xml version="1.0"?>
<configuration>
    <startup useLegacyV2RuntimeActivationPolicy="true">
         <supportedRuntime version="v4.0.30319"/>        
         <supportedRuntime version="v2.0.50727"/>        
    </startup>
</configuration>

This config file needs to be added as wsmprovhost.exe.config to C:\Windows\SysWOW64 and C:\Windows\system32 and as powershell.exe.config to C:\Windows\system32\WindowsPowerShell\v1.0 and C:\Windows\SysWOW64\WindowsPowerShell\v1.0.

This forces Powershell to use the CLRVersion 4 and then it works!

But still, I’m curious how I could have gotten this to work with your base requirements of having .NET 4.5+ and out-of-the-box Powershell 2.0 on 2008R2.

Thanks,

Pascal

Hi Pascal,

You are correct, we need to re-think our requirements. Either we need to bump the PowerShell version or explicitly check .NET versions when running on CLR 2.

I’m glad you found a way to set the PowerShell CLR version and it is working for you. Although I can’t find much documentation around wsmprovhost.exe.config one of my colleagues has a few scars and recalls explicitly setting the PowerShell CLR version also affecting other applications. That’s something you may need to be wary of.

Glad to hear you are back deploying and we will review our requirements.

Cheers,
Shane

Hi Shane,

Thanks for the clarification. I guess that the most fail-safe way forward for us is then to upgrade to Powershell 4 anyway. I guess we’ll take that route.

Pascal.

I am having an almost identical problem 8 months after OP posted this problem.

I am running on octopus 3.3.6. And I have two tentacle machines (one Dev machine and one Production machine) which are both Windows Server 2008 R2.

The dev machine works well but the production machine doesn’t. So far the only difference is that the dev machine has Visual Studio 2013 installed.

The most important piece of the log reads:

21:34:49   Verbose  |       Name                           Value
21:34:49   Verbose  |       ----                           -----
21:34:49   Verbose  |       CLRVersion                     2.0.50727.5485
21:34:49   Verbose  |       BuildVersion                   6.1.7601.17514
21:34:49   Verbose  |       PSVersion                      2.0
21:34:49   Verbose  |       WSManStackVersion              2.0
21:34:49   Verbose  |       PSCompatibleVersions           {1.0, 2.0}
21:34:49   Verbose  |       SerializationVersion           1.1.0.1
21:34:49   Verbose  |       PSRemotingProtocolVersion      2.1
21:34:49   Error    |       Add-Type : 未能加载文件或程序集“System.Web.Extensions, Version=3.5.0.0, Culture
21:34:49   Error    |       =neutral, PublicKeyToken=31bf3856ad364e35”或它的某一个依赖项。系统找不到指定的文
21:34:49   Error    |       件。
21:34:49   Error    |       所在位置 E:\Octopus\Applications\Production\FHT.Web\1.0.680\Octopus.Features.II
21:34:49   Error    |       SWebSite_BeforePostDeploy.ps1:110 字符: 11
21:34:49   Error    |       +         add-type <<<<  -assembly system.web.extensions
21:34:49   Error    |       + CategoryInfo          : NotSpecified: (:) [Add-Type], FileNotFoundExcept
21:34:49   Error    |       ion
21:34:49   Error    |       + FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.PowerS
21:34:49   Error    |       hell.Commands.AddTypeCommand
21:34:49   Verbose  |       Deleting 'E:\Octopus\Applications\Production\FHT.Web\1.0.680\Octopus.Features.IISWebSite_BeforePostDeploy.ps1'
21:34:49   Error    |       Script 'E:\Octopus\Applications\Production\FHT.Web\1.0.680\Octopus.Features.IISWebSite_BeforePostDeploy.ps1' returned non-zero exit code: 1
21:34:49   Error    |       Running rollback conventions...

Both of the machines have powershell version of:

Major  Minor  Build  Revision
-----  -----  -----  --------
2      0      -1     -1

So far I have tried:

  1. installing .net 4.6.2
  2. installing ASPAJAXExtSetup.msi

I haven’t tried to install visual studio on it yet coz I think it is rather weird to install visual studio in a production machine.

What else can I try except for trying a different machine?

Attached is the log file.

Thanks for any hints.

ServerTasks-699.log.txt (31 KB)

HI,

Thanks for getting in touch.

You could try installing .NET 3.5.1 or upgrading to PowerShell 4. This error can be caused by an incompatibility between your .NET and PowerShell versions.

Cheers,
Shane