Build/Test Issues

Having trouble Building One of my projects

Started by ptaylor on 9,786 views

I have a project that builds successfully when I build and run in visual studio but when I use NCrunch I get the following error

NCrunch: If you are experiencing problems in getting this project to build, have a look at http://www.ncrunch.net/documentation/troubleshooting_project-build-issues
..\..\..\..\..\..\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets (4050): Cannot register assembly "C:\Users\myName\AppData\Local\NCrunch\8552\24\MyProjectFolder\bin\Debug\MyProject.dll" - access denied. Please make sure you're running the application as administrator. Access to the registry key 'HKEY_CLASSES_ROOT\MyProject.MyProjectClass' is denied.

I didn't think I was doing anything particularly odd on the build and I am not running Visual Studio as Admin to get it to build normally. Does anyone have any ideas on how I can get NCrunch to build this project?
This error is being raised by the build step responsible for registering this assembly for COM interop. When UAC is enabled on your machine, the build process needs to be granted administrator privileges in order to perform the registration.

I'm not entirely sure why Visual Studio lets you build this project without you running it as administrator, but my guess would be that the assembly has already been registered before at its normal build path, so probably the build step is being skipped in this case.

COM registration of assemblies under NCrunch workspaces is probably not something you want to do as part of an NCrunch build. There's an easy way to suppress this behaviour when working with NCrunch. Open up the project file and look for the property:

<RegisterForComInterop>true</RegisterForComInterop>

.. And replace it with:

<RegisterForComInterop Condition="$(NCrunch) != '1'">true</RegisterForComInterop>

This will allow the COM registration to happen for any normal build, but it will be skipped when working with NCrunch. This will remove the need to run VS as administrator, while also improving your build performance.
That worked fantastically. Thanks for the quick response and the great product.
Great! Thanks for confirming. Enjoy the product :)
I may have spoken too soon. The project builds...but then NCrunch seems to hang on some of the tests. Is there a log file or something I could provide you with to give you more information as to what is happening?
This means we have now discovered the next problem :)

Are you able to get a debugger into the tests that are hanging? What can you tell me about these tests?

Post a reply

Log in to reply.