Why System.Core fails to load when adding Coded UI support for Silverlight 5 application?
Asked Answered
I

1

26

I'm having the following problem:

Trying to add support for creating coded UI test for Silverlight 5 application ([MSDN][1]). First step is to reference assembly Microsoft.VisualStudio.TestTools.UITest.Extension.SilverlightUIAutomationHelper.dll in Silverlight 5 project. Unfortunately, after the reference has been added, projects stops to compile with a number of similar errors:

>

 Error  25  Cannot resolve reference assemblies. Please check the reference assemblies. Could not load file or assembly 'System.Core, Version=5.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) ....\ErrorReportDialog.xaml


Looks like System.Core 5.0.5.0 fails to load, okay, debugging assemblies loading with Fuslogw produces two interesting logs:

First log:

> Assembly Binder Log Entry  (04.03.2013 @ 14:07:49)
The operation was successful.
Bind result: hr = 0x0. The operation completed successfully.
Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable  C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
A detailed error log follows. 
=== Pre-bind state information ===
LOG: DisplayName = System.Core, Version=5.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
 (Fully-specified)
LOG: Appbase = file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = MSBuild.exe
Calling assembly : System.Windows, Version=5.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e.
LOG: This bind starts in LoadFrom load context.
WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().
LOG: Using application configuration file: C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe.Config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.Core, Version=5.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
LOG: Binding succeeds. Returns assembly from C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v5.0\System.Core.dll.
LOG: Assembly is loaded in LoadFrom load context.

Looks like System.Core, Version=5.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e loads succesfully.

But second log entry produces the following error:

> Assembly Binder Log Entry  (04.03.2013 @ 14:07:49)
The operation failed.
Bind result: hr = 0x80131040. No description available.
Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable  C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
A detailed error log follows. 
Pre-bind state information
LOG: DisplayName = System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
 (Fully-specified)
LOG: Appbase = file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = MSBuild.exe
Calling assembly : Microsoft.VisualStudio.TestTools.UITest.Extension.SilverlightUIAutomationHelper, Version=10.0.30319.381, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a.
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe.Config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Redirect found in application configuration file: 2.0.5.0 redirected to 5.0.5.0.
LOG: Post-policy reference: System.Core, Version=5.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
LOG: The same bind was seen before, and was failed with hr = 0x80131040.
ERR: Unrecoverable error occurred during pre-download check (hr = 0x80131040).

Looks like Microsoft.VisualStudio.TestTools.UITest.Extension.SilverlightUIAutomationHelper.dll tries to load System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, but is being redirected to System.Core, Version=5.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e (already loaded from 1st log) and still fails to load.

Can anyone provide some insight on how to further debug this problem? I'm compiling Silverlight projects for AnyCpu platform.


  [1]: http://msdn.microsoft.com/en-us/library/gg413374.aspx
Ine answered 4/3, 2013 at 12:4 Comment(3)
System.Core, Version=2.0.5.0 is of course the problem. An older version of the assembly, used in previous versions of Silverlight. They didn't get it done for VS2012, check this blog post.Newlin
I've checked it with VS2010 - redirect from machine.config does not work there. It produces an error failing to find System.Core 2.0.5.0, since project references 5.0.5.0. Strange, since we use the same version of .Net Framework itself.Ine
@HansPassant: Do you think it would be a good idea to post that link as an answer? I know it's not a perfect solution, but I'm thinking it may be the best option.Bisayas
D
1

To confirm version of System.Core required by SilverlightUIAuthomationHelper do the following:

  1. find the referenced SilverlightUIAuthomationHelper dll on disk.
  2. load it up in any disassembler/reflector - for example dotPeek or Reflector.
  3. check versions of referenced assemblies - System.Core must be 2.0.5.0 in your version of SilverlightUIAuthomationHelper

Possible solutions:

  1. update SilverlightUIAuthomationHelper to the new version (link in the Hans Passant comment) that references new System.Core dll (version 5.0.5.0)
  2. Because fuslogvw says that redirect from 2.0.5.0 to 5.0.5.0 is located in the APPLICATION configuration file - try to find and remove this redirect (details here). But it is very possible that something else will break.
Diuresis answered 5/6, 2013 at 14:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.