Reputation:
I'm trying to register soap extension programatically in powershell, like it is described here, but I have problem with this one particular method:
[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."
This is output from Fusion Log Viewer when running this line directly in powershell.exe:
*** 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).
This is output from Fusion Log Viewer when running this PowerGUI Script Editor:
*** 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.
Of course assembly is present in 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
The same problem occurs if I use assembly full name in powershell line above.
Upvotes: 1
Views: 2050
Reputation: 40818
You need to specify the assembly-qualified type name, unless the type is in the current assembly or mscorlib.dll. This should work:
[System.Type]::GetType("System.Configuration.ConfigurationElementCollection, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", $true)
Upvotes: 2