Build/Test Issues

NCrunch Console Invalid Cast

Started by simongh on 5,968 views

I've just upgraded our Teamcity to use the 3.21 release of the console tool and we're getting the below error:

System.InvalidCastException: [A] cannot be cast to . Type A originates from 'nCrunch.VSAddIn, Version=3.21.0.6, Culture=neutral, PublicKeyToken=01d101bf6f3e0aea' in the context 'Default' at location 'C:\BuildAgent\tools\NCrunch_Console_3.21.0.6\nCrunch.VSAddIn.dll'. Type B originates from 'NCrunch, Version=3.21.0.6, Culture=neutral, PublicKeyToken=null' in the context 'Default' at location 'C:\BuildAgent\tools\NCrunch_Console_3.21.0.6\ncrunch.exe'.
at nCrunch.Common.ServiceLocator.FetchInstance[T](Boolean throwOnMissingService)
at ..ctor()
at ..ctor(Boolean )
at . ( , ILogWriter , , String , Nullable`1 )
at . (String[] )

I've had to roll back to 3.20 release. Thought this might be helpful.

We use the zip file release pushed out to the build agents automatically by the build server.
Hi, thanks for sharing this problem.

I've just double-checked the ZIP download for v3.21 of the NCrunch Console tool. I could not reproduce this problem.

By chance, do you have a directory comparison tool like Kdiff3 available? It would be interesting to perform a comparison of the ZIP file from the NCrunch download page with the contents of your C:\BuildAgent\tools\NCrunch_Console_3.21.0.6 directory. I wonder if there is a difference there somewhere.
Using winmerge. Everything comes back as identical. We're using TeamCity Professional 2018.1.1 (build 58406) triggering ncrunch from a commandline
I have a feeling there is an environmental component to this. Can you check if you can use the same version of the console tool on the same solution on any of the other machines in your network? (i.e. a dev machine).

v3.21 of NCrunch was very limited in its functional changes. It includes no new assemblies or referencing changes over v3.20. If you haven't already, I do also recommend rebooting your build server to see if this makes any difference.
We are experiencing the same problem.
The problem can only be reproduced when running Ncrunch Console from TeamCity.

Running locally on buildserver either using cmd or powershell does not reproduce the error.
Thanks, we'll try digging a bit more to see if we can get this to happen on our end. We'll let you know as soon as we have more information.

Edited

We have tried running the command as a run on the build server:
C:\Windows\system32\cmd.exe /c ""C:\Program Files (x86)\Remco Software\NCrunch Console Tool\NCrunch.exe" C:\TeamCity\buildAgent\work\89f512a38888334a\master.sln /c C:\TeamCity\buildAgent\work\89f512a38888334a\teamcity.crunch.v3.xml /e "TeamCity Continues Int"
Thanks, can you confirm if you installed the console tool using the MSI or the ZIP?
We have confirmed that the error occurred both for the zip and msi.
We use just zip deployment. We're currently using 15.7.5 of the build tools
Also running NCrunch using TeamCity powershell step also reproduces the error:
& 'C:\Program Files (x86)\Remco Software\NCrunch Console Tool\NCrunch.exe' .\master.sln /c .\teamcity.crunch.v3.xml /e "TeamCity Continues Integration" /o NCrunchResults /TeamCityDisableTestNotRunFailureReporting -LogVerbosity Summary

Post a reply

Log in to reply.