Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Build failure in remote environment - assembly already loaded
teplas
#1 Posted : Monday, August 15, 2016 7:38:22 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 8/15/2016(UTC)
Posts: 4
Location: Switzerland

This issue started a couple of months ago when we upgraded to VS2015 (from 2013), but I was too busy reporting. Would love to have NCrunch working again in the new environment.


This is the error from the NCrunch tests window:
---
System.Exception: An exception was thrown in the remote environment: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> nCrunch.Common.UserException: Errors occurred while trying to load the project file:
API restriction: The assembly '' has already loaded from a different location. It cannot be loaded from a new location within the same appdomain.
at nCrunch.Compiler.RemoteBuildRunner.(FilePath ,   , String , String , DirectoryPath , String )
at nCrunch.Compiler.RemoteBuildRunner.AnalyseComponentBuild(FilePath projectFilePath, BuildXml buildXml, String useBuildConfiguration, String useBuildPlatform, DirectoryPath solutionDir, String solutionName, List`1 importExpressionsToEvaluate, ProcessorArchitecture buildProcessProcessorArchitecture, DirectoryPath workspaceBasePath)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at nCrunch.TaskRunner.Ipc.IpcMessageProcessor.(CallMethodMessage )
at nCrunch.TaskRunner.Ipc.IpcMessageProcessor.ProcessMessageReturningResult(Byte[] data)
at nCrunch.TaskRunner.Ipc.RemoteInstance.[T](Byte[] )
at nCrunch.TaskRunner.Ipc.RemoteInstance.Invoke(IMessage msg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at nCrunch.Compiler.IRemoteBuildRunner.AnalyseComponentBuild(FilePath projectFilePath, BuildXml buildXml, String useBuildConfiguration, String useBuildPlatform, DirectoryPath solutionDir, String solutionName, List`1 importExpressionsToEvaluate, ProcessorArchitecture buildProcessProcessorArchitecture, DirectoryPath workspaceBasePath)
at nCrunch.Core.BuildManagement.BuildProcessLauncher..(IRemoteBuildRunner )
at nCrunch.Core.BuildManagement.BuildProcessLauncher.(Action`1 , IBuildableProject , ExternalProcess )
at nCrunch.Core.BuildManagement.BuildProcessLauncher.(Action`1 , ProcessorArchitecture , GridClientId , IBuildableProject , IList`1 )
at nCrunch.Core.BuildManagement.BuildProcessLauncher.AnalyseComponentBuildInExternalProcess(FilePath projectFilePath, BuildXml buildXml, String useBuildConfiguration, String useBuildPlatform, DirectoryPath solutionDir, String solutionName, List`1 importExpressionsToEvaluate, ProcessorArchitecture processorArchitecture, VisualStudioVersion vsVersion, IList`1 customEnvironmentVariables)
at nCrunch.Client.ComponentLoader.SnapshotComponentFactory.(ProcessorArchitecture )
at nCrunch.Client.ComponentLoader.SnapshotComponentFactory.CreateSnapshotComponentFromXml(FilePath projectFilePath, BuildXml projectXml, FilePath solutionFilePath, String[] additionalFilesToIncludeAtSolutionLevel, Boolean isLoadedFromFile, ISnapshotConfig snapshotConfig, VisualStudioVersion vsVersion)
---

Note: This is a 100% copy/paste from the window, I did NOT remove anythin (assembly '' is really empty).

Environment:

  • Windows Server 2012 R2
  • Visual Studio 2015 Update 3
  • NCrunch 2.25 (experience error once we upgraded to VS2015 + NCrunch 2.20. Using VS2013 + NCrunch 2.20 was working fine)


Do you have any idea how to fix this?
Or how to troubleshoot this to find better information about the root cause?

The VS/C# solution does build fine on VS2015 and also on our build server without Visual Studio (MSBuild + Windows SDK + .NET target pack).

Thanks
Remco
#2 Posted : Monday, August 15, 2016 10:14:34 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,145

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi, thanks for sharing this issue.

I haven't seen this issue before. I'll need a bit more information to help analyse it.

- Does the problem seem to affect a specific project, or is it ALL of your projects?
- Do you see this problem if you try to use NCrunch against a different solution? (you can just build a small dummy one to test it if you like)
- If the problem is specific to a project, does the project have any build customisations or custom coding done in its XML?
- Are you using any other tools in your IDE or in the build system for this project?
- Would you mind submitting a bug report? The log file may reveal additional information I can use to help troubleshoot
teplas
#3 Posted : Monday, August 15, 2016 12:01:32 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 8/15/2016(UTC)
Posts: 4
Location: Switzerland

- It is specific to the solution/projects
- Even some projects in the solution build fine, but at some point one project fails and naturally all dependent projects fail from there on
- Custom coding (I assume you mean build-events or stuff like that):
* Not in the project which fails.
* There is a post-build event executing in the EXE project, which is the last to be built in the solution. It does some app.config merging, but this is skipped in NCrunch altogether.
- We do have Resharper and Reflector installed in our IDE.
- What logfile do you mean and where can it be found?

Another speciality in our solution:
- All .csproj files do have "DoNotCopyLocalIfInGac=true" to match the old behavior of VS2013. This was necessary due to a 3rd party assembly that relies on that behavior.

<PropertyGroup>
<!-- Fix the default copy local behaviour changed in VS 2015 -->
<DoNotCopyLocalIfInGac>true</DoNotCopyLocalIfInGac>
</PropertyGroup>

Also, we do reference a 3rd party ActiveX control (COM).

And we upgraded NUnit from 2.6.x to 3 at the same time when upgrading to VS2015.
Remco
#4 Posted : Monday, August 15, 2016 1:24:36 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,145

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Thanks for the extra details!

- Under the 'NCrunch' menu, there is an option for 'Submit bug report'. This captures a log of the most recent engine activity, which will include any build failures if you try it after the solution has been opened with NCrunch enabled. If you like, you can save the log to disk and have a look through it yourself. Alternatively, the submit option will upload it to a secure place where I can review it.

- Does removing the 'DoNotCopyLocalIfInGac' adjustment make any difference to this error?

- What can you tell me about the ActiveX control? How is this referenced from your projects?

- Noting that this is only affecting specific projects, is there anything unique about these projects that might cause them to be hit by the problem? Is it possible for you to deductively identify the point of difference that is creating the problem by making adjustments to the projects that build and the ones that don't?
teplas
#5 Posted : Tuesday, August 16, 2016 11:30:37 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 8/15/2016(UTC)
Posts: 4
Location: Switzerland

I could fix it while trying to create a minimal solution which reproduces the issue.

We had this import in the failing .csproj files:
Code:
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(MSBuildToolsVersion)\WebApplications\Microsoft.WebApplication.targets" Condition="exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(MSBuildToolsVersion)\WebApplications\Microsoft.WebApplication.targets')" />


I don't really understand why, but at the moment we can live without this import.
Remco
#6 Posted : Tuesday, August 16, 2016 11:37:34 AM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,145

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Interestingly, adding this import to a test project on my end doesn't produce the problem, even though the import target clearly exists. I wonder if there may be a problem with a version of this particular build extension. I haven't seen it declared before in the manner that you've described above.

If you do need to make use of this import in future, it may be possible to suppress the problem in NCrunch builds by adding an extra condition to the import:

<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(MSBuildToolsVersion)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(NCrunch)' != '1' and exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(MSBuildToolsVersion)\WebApplications\Microsoft.WebApplication.targets')" />
teplas
#7 Posted : Tuesday, August 16, 2016 12:04:54 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 8/15/2016(UTC)
Posts: 4
Location: Switzerland

The "exists(<path>)" was there to not import it on the build machine where this file isn't present (no VS installed).

Thanks for the workaround!
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.056 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download