Monday 15 August 2011

.net - Powershell - Assembly binding redirect NOT found in application configuration file -



.net - Powershell - Assembly binding redirect NOT found in application configuration file -

got problem here...

i have got powershell cmdlet works when running in 32-bit mode , fails in 64-bit mode. question cause , how can fixed.

situation

powershell cmdlet references 'outlookhelper.common.dll'. newest version 2.0.0.0 cmdlet uses logging , references 'logging.dll'. logging.dll references 'outlookhelper.common.dll', compiled against version 1.0.0.0.

how made work, works partially

using assembly binding redirect in application configuration file of powershell:

<?xml version="1.0" encoding="utf-8" ?> <configuration> <startup uselegacyv2runtimeactivationpolicy="true"> <supportedruntime version="v4.0.30319"/> <supportedruntime version="v2.0.50727"/> </startup> <runtime> <assemblybinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentassembly> <assemblyidentity name="outlookhelper.common" publickeytoken="5e4553dc0df45306"/> <bindingredirect oldversion="1.0.0.0" newversion="2.0.0.0"/> </dependentassembly> </assemblybinding> </runtime> </configuration> powershell 32-bits works fine

when running on 64-bits machine, using 'windows powershell (x86)' works. assembly manager finds assembly binding redirect:

the operation successful. bind result: hr = 0x0. operation completed successfully. assembly manager loaded from: c:\windows\microsoft.net\framework\v4.0.30319\clr.dll running under executable c:\windows\syswow64\windowspowershell\v1.0\powershell.exe --- detailed error log follows. === pre-bind state info === log: user = mydomain\testuser log: displayname = outlookhelper.common, version=1.0.0.0, culture=neutral, publickeytoken=5e4553dc0df45306 (fully-specified) log: appbase = file:///c:/windows/syswow64/windowspowershell/v1.0/ log: initial privatepath = null log: dynamic base of operations = null log: cache base of operations = null log: appname = powershell.exe calling assembly : outlookhelper.data.common, version=1.0.5295.26925, culture=neutral, publickeytoken=null. === log: bind starts in loadfrom load context. wrn: native image not probed in loadfrom context. native image probed in default load context, assembly.load(). log: using application configuration file: c:\windows\syswow64\windowspowershell\v1.0\powershell.exe.config log: using host configuration file: log: using machine configuration file c:\windows\microsoft.net\framework\v4.0.30319\config\machine.config. log: redirect found in application configuration file: 1.0.0.0 redirected 2.0.0.0. log: post-policy reference: outlookhelper.common, version=2.0.0.0, culture=neutral, publickeytoken=5e4553dc0df45306 log: gac lookup unsuccessful. log: attempting download of new url file:///c:/windows/syswow64/windowspowershell/v1.0/outlookhelper.common.dll. log: attempting download of new url file:///c:/windows/syswow64/windowspowershell/v1.0/outlookhelper.common/outlookhelper.common.dll. log: attempting download of new url file:///c:/windows/syswow64/windowspowershell/v1.0/outlookhelper.common.exe. log: attempting download of new url file:///c:/windows/syswow64/windowspowershell/v1.0/outlookhelper.common/outlookhelper.common.exe. log: attempting download of new url file:///d:/sampleapps/_common/bin/outlook.extensions.sample/outlookhelper.common.dll. log: assembly download successful. attempting setup of file: d:\sampleapps\_common\bin\outlook.extensions.sample\outlookhelper.common.dll log: entering run-from-source setup phase. log: assembly name is: outlookhelper.common, version=2.0.0.0, culture=neutral, publickeytoken=5e4553dc0df45306 log: where-ref bind codebase not match found in default context. maintain result in loadfrom context. log: binding succeeds. returns assembly d:\sampleapps\_common\bin\outlook.extensions.sample\outlookhelper.common.dll. log: assembly loaded in loadfrom load context.

here powershell says assembly identity:

windows powershell (x86) copyright (c) 2009 microsoft corporation. rights reserved. ps c:\users\testuser> ([xml](gc $([system.appdomain]::currentdomain.setupinformation.configurationfile))).configuratio n.runtime.assemblybinding.dependentassembly.assemblyidentity name publickeytoken ---- -------------- outlookhelper.common 5e4553dc0df45306 ps c:\users\testuser> this problem starts...

when running on 64-bits machine, using 'windows powershell' not work. assembly manager not find assembly binding redirect:

the operation failed. bind result: hr = 0x80070002. scheme cannot find file specified. assembly manager loaded from: c:\windows\microsoft.net\framework64\v4.0.30319\clr.dll running under executable c:\windows\system32\windowspowershell\v1.0\powershell.exe --- detailed error log follows. === pre-bind state info === log: user = mydomain\testuser log: displayname = outlookhelper.common, version=1.0.0.0, culture=neutral, publickeytoken=5e4553dc0df45306 (fully-specified) log: appbase = file:///c:/windows/system32/windowspowershell/v1.0/ log: initial privatepath = null log: dynamic base of operations = null log: cache base of operations = null log: appname = powershell.exe calling assembly : outlookhelper.data.common, version=1.0.5295.26925, culture=neutral, publickeytoken=null. === log: bind starts in loadfrom load context. wrn: native image not probed in loadfrom context. native image probed in default load context, assembly.load(). log: using application configuration file: c:\windows\system32\windowspowershell\v1.0\powershell.exe.config log: using host configuration file: log: using machine configuration file c:\windows\microsoft.net\framework64\v4.0.30319\config\machine.config. log: post-policy reference: outlookhelper.common, version=1.0.0.0, culture=neutral, publickeytoken=5e4553dc0df45306 log: same bind seen before, , failed hr = 0x80070002. err: unrecoverable error occurred during pre-download check (hr = 0x80070002).

here powershell says assembly identity:

windows powershell copyright (c) 2009 microsoft corporation. rights reserved. ps c:\users\testuser> ([xml](gc $([system.appdomain]::currentdomain.setupinformation.configurationfile))).configuratio n.runtime.assemblybinding.dependentassembly.assemblyidentity ps c:\users\ccontent01>

when allow powershell contents of own application configuration file next output:

windows powershell copyright (c) 2009 microsoft corporation. rights reserved. ps c:\users\testuser> gc c:\windows\system32\windowspowershell\v1.0\powershell.exe.config <?xml version="1.0"?> <configuration> <startup uselegacyv2runtimeactivationpolicy="true"> <supportedruntime version="v4.0.30319"/> <supportedruntime version="v2.0.50727"/> </startup> </configuration> ps c:\users\testuser> what tried... check whether 'specific version' set 'false' -> case. deleted , re-added application configuration file -> did not prepare it. started new application configuration file in syswow64 folder -> did not prepare it. double checked contents of files loaded (powershell.exe.config , machine.config) -> same. my guess assembly manager cannot find assembly redirect binding. any solutions? why fusion log 64-bits instance not mention 'redirect found in application configuration file: 1.0.0.0 redirected 2.0.0.0.'? what can cause of this? can think of solutions?

on 64-bit machine there 2 configuration files:

c:\windows\system32\windowspowershell\v1.0\powershell.exe.config c:\windows\syswow64\windowspowershell\v1.0\powershell.exe.config

have edited both of them on 64-bit machine?

on 64-bit versions of windows. 32 bit processes (like notepad++) transparently redirected c:\windows\system32 c:\windows\syswow64 os.

you need create sure edit both files using 64-bit text editor builtin notepad.exe. guarantee not suffer subtle issue, can cause confusion.

.net powershell 32bit-64bit assembly-binding-redirect

No comments:

Post a Comment