aspnet / Testing

[Archived] Testing infrastructure, including support for xUnit.net and StyleCop. Project moved to https://github.com/aspnet/Extensions
66 stars 40 forks source link

XUnit.KRunner throws TypeLoadException #18

Closed Alxandr closed 10 years ago

Alxandr commented 10 years ago

I'm getting a typeload exception trying to run tests with the XUnit.KRunner (tried on the Mvc repo too just to check it wasn't my code). It can't load XUnit.Sdk.TestFramework.

Error-message:
image

Kvm list:
image

davidfowl commented 10 years ago

What project re you testing?

Alxandr commented 10 years ago

Well, I just downloaded the Mvc repo (https://github.com/aspnet/Mvc) and ran build. It builds fine, and crashes when it comes to the testing stage. But I started with trying to run unit-tests on my own project (it has 1 class in the main project with a property, and a test in the test project which tests the property value, just to test the K build system), and it gives me the same error.

davidfowl commented 10 years ago

Did you copy over the project.json from mvc or did you see what it had in it to enable testing?

Alxandr commented 10 years ago

As said, I ran build on Mvc. So no copying at all. On my local project I copied over the bits required:

{
  "version": "0.1-alpha-*",
  "compilationOptions": {
    "warningsAsErrors": true
  },
  "dependencies": {
    "AppVisum.Core": "",
    "Xunit.KRunner": "0.1-alpha-*",
    "xunit.abstractions": "2.0.0-aspnet-*",
    "xunit.assert": "2.0.0-aspnet-*",
    "xunit.core": "2.0.0-aspnet-*",
    "xunit.execution": "2.0.0-aspnet-*"
  },
  "commands": {
    "test": "Xunit.KRunner"
  },
  "configurations": {
    "net45": {}
  }
}
Alxandr commented 10 years ago

Basically, I did:

git fork https://github.com/aspnet/Mvc.git
cd Mvc
build.bat

And it crashed.

Alxandr commented 10 years ago

Ok, so I took a peek down in fuslogwv-land, and there's obviously something weird going on:

*** Assembly Binder Log Entry  (21-May-14 @ 19:10:55) ***

The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable  C:\Users\alxan_000\.kre\packages\KRE-svr50-x86.0.1-alpha-build-0446\bin\klr.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: DisplayName = xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c
 (Fully-specified)
LOG: Appbase = file:///C:/Users/alxan_000/Documents/GitHub/Mvc/test/Microsoft.AspNet.Mvc.Core.Test
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = klr.exe
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using host configuration file: C:\Users\alxan_000\.kre\packages\KRE-svr50-x86.0.1-alpha-build-0446\bin\klr.net45.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/Users/alxan_000/Documents/GitHub/Mvc/test/Microsoft.AspNet.Mvc.Core.Test/xunit.abstractions.DLL.
LOG: Attempting download of new URL file:///C:/Users/alxan_000/Documents/GitHub/Mvc/test/Microsoft.AspNet.Mvc.Core.Test/xunit.abstractions/xunit.abstractions.DLL.
LOG: Attempting download of new URL file:///C:/Users/alxan_000/Documents/GitHub/Mvc/test/Microsoft.AspNet.Mvc.Core.Test/xunit.abstractions.EXE.
LOG: Attempting download of new URL file:///C:/Users/alxan_000/Documents/GitHub/Mvc/test/Microsoft.AspNet.Mvc.Core.Test/xunit.abstractions/xunit.abstractions.EXE.
LOG: All probing URLs attempted and failed.

The solution path is C:\Users\alxan_000\Documents\GitHub\Mvc (that's where global.json is located), yet it's looking for xunit.abstractions under test\Microsoft.AspNet.Mvc.Core.Test. Not only that, klr.exe generates a whole bunch of bind errors, including one for XUnit.KRunner which it still manages to run somehow.

*** Assembly Binder Log Entry  (21-May-14 @ 19:10:55) ***

The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable  C:\Users\alxan_000\.kre\packages\KRE-svr50-x86.0.1-alpha-build-0446\bin\klr.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: DisplayName = Xunit.KRunner
 (Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: Xunit.KRunner | 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:/Users/alxan_000/Documents/GitHub/Mvc/test/Microsoft.AspNet.Mvc.Core.Test
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = klr.exe
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
LOG: Using host configuration file: C:\Users\alxan_000\.kre\packages\KRE-svr50-x86.0.1-alpha-build-0446\bin\klr.net45.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\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:/Users/alxan_000/Documents/GitHub/Mvc/test/Microsoft.AspNet.Mvc.Core.Test/Xunit.KRunner.DLL.
LOG: Attempting download of new URL file:///C:/Users/alxan_000/Documents/GitHub/Mvc/test/Microsoft.AspNet.Mvc.Core.Test/Xunit.KRunner/Xunit.KRunner.DLL.
LOG: Attempting download of new URL file:///C:/Users/alxan_000/Documents/GitHub/Mvc/test/Microsoft.AspNet.Mvc.Core.Test/Xunit.KRunner.EXE.
LOG: Attempting download of new URL file:///C:/Users/alxan_000/Documents/GitHub/Mvc/test/Microsoft.AspNet.Mvc.Core.Test/Xunit.KRunner/Xunit.KRunner.EXE.
LOG: All probing URLs attempted and failed.

I cleared the fuslogvw errors, and ran build.bat anew, and this is the result (note, it's only set to log errors):
image

davidfowl commented 10 years ago

The bind errors are normal, assemblies aren't where they normally are when using vNext

Alxandr commented 10 years ago

Shouldn't klr probe first then, to not generate so much error-logs? Anyways, that's sort of besides the point, if the bind-errors aren't a symptom of the problem I have no idea how to debug a TypeLoadException. I can upload my sources, but given that I used Mvc directly, I have a feeling the problem is local, and I need to fix it myself, I just have to figure out what it is.

davidfowl commented 10 years ago

I wouldnt worry too much about the fusion log, it's desktop doing what it does. I see the issue locally as well so it's not your box.

Alxandr commented 10 years ago

Ah, that's good. I was afraid I broke something fundamental (again) -.-

bricelam commented 10 years ago

This may be fixed now that coherence-signed has passed. Xunit.KRuntime was built against a version of xunit newer than the one published on myget.

Alxandr commented 10 years ago

@bricelam Yes. The problem seems to have been resolved.