我正在尝试在powershell中以编程方式注册soap扩展,就像这里描述的那样,但是我对这个特定的方法有疑问:
[System.Type]::GetType("System.Configuration.ConfigurationElementCollection, System.Configuration", $true)
Exception calling "GetType" with "2" argument(s): "Could not load file or assembly 'System.Configuration' or one of its dependencies. The system cannot find the file specified."
这是直接在 powershell.exe 中运行此行时 Fusion Log Viewer 的输出:
*** Assembly Binder Log Entry (9/20/2013 @ 10:42:57 AM) ***
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
Running under executable C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = xxx
LOG: DisplayName = System.Configuration
(Partial)
LOG: Appbase = file:///C:/WINDOWS/system32/WindowsPowerShell/v1.0/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = NULL
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v2.0.50727\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: The same bind was seen before, and was failed with hr = 0x80070002.
ERR: Unrecoverable error occurred during pre-download check (hr = 0x80070002).
这是运行此 PowerGUI 脚本编辑器时 Fusion Log Viewer 的输出:
*** Assembly Binder Log Entry (9/20/2013 @ 10:43:38 AM) ***
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable C:\Program Files (x86)\PowerGUI\ScriptEditor.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = xxx
LOG: DisplayName = System.Configuration
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: System.Configuration | Domain ID: 1
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/Program Files (x86)/PowerGUI/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = ScriptEditor.exe
Calling assembly : System.Management.Automation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Program Files (x86)\PowerGUI\ScriptEditor.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Program Files (x86)/PowerGUI/System.Configuration.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/PowerGUI/System.Configuration/System.Configuration.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/PowerGUI/System.Configuration.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/PowerGUI/System.Configuration/System.Configuration.EXE.
LOG: All probing URLs attempted and failed.
*** Assembly Binder Log Entry (9/20/2013 @ 10:43:38 AM) ***
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable C:\Program Files (x86)\PowerGUI\ScriptEditor.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = xxx
LOG: DisplayName = System.Configuration
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: System.Configuration | Domain ID: 1
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/Program Files (x86)/PowerGUI/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = ScriptEditor.exe
Calling assembly : System.Management.Automation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Program Files (x86)\PowerGUI\ScriptEditor.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Program Files (x86)/PowerGUI/System.Configuration.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/PowerGUI/System.Configuration/System.Configuration.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/PowerGUI/System.Configuration.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/PowerGUI/System.Configuration/System.Configuration.EXE.
LOG: All probing URLs attempted and failed.
当然,GAC 中存在汇编:
The Global Assembly Cache contains the following assemblies:
System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL
System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL
如果我在上面的 powershell 行中使用程序集全名,也会出现同样的问题。