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

Notification

Icon
Error

C++ types not available in C# under VS2015
wilhelmmedetz
#1 Posted : Thursday, July 30, 2015 11:11:04 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 7/4/2012(UTC)
Posts: 35

Was thanked: 2 time(s) in 2 post(s)
Project A is C# project.
Project B is a mixed mode (VS 2013) C++ project, defining .Net types, referencing project A.
Project C is a C# project, referencing project A and B.

With NCrunch under VS2013 everything works fine.

VS2015 builds and executes tests without an error

NCrunch under VS 2015 displays build errors for project C, when referencing types defined in project B.
"The name ... is not available in the current context."

Any idea why this happens?

Regards

Wilhelm
Remco
#2 Posted : Thursday, July 30, 2015 12:03:25 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Hi Wilhelm,

Unfortunately I can't think of any reason off the top of my head as to why this would happen. Do you have any sample code that you might be able to share? I may have more luck with a solution that can reproduce the issue.
wilhelmmedetz
#3 Posted : Thursday, July 30, 2015 3:24:08 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 7/4/2012(UTC)
Posts: 35

Was thanked: 2 time(s) in 2 post(s)
Hi,

I could reproduce this with a simple example (ProjectA is not needed).

It works with VS2013.
It fails with VS 2015.

Building ProjectB creates an error - see below.

There also is a second problem - when deselecting 'Show passing tests' only the build error for ProjectC is displayed.
When selecting 'Show passing tests' build errors are displayed for PrjectB and ProjectC.

Is there any place where I can upload the solution?


System.Exception: An exception was thrown in the remote environment: System.Reflection.TargetInvocationException: Ein Aufrufziel hat einen Ausnahmefehler verursacht. ---> nCrunch.Common.UserException: Errors occurred while trying to load the project file:
Die "SetEnv"-Aufgabe konnte nicht aus der "C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.Build.CppTasks.Common.dll"-Assembly instanziiert werden. Überprüfen Sie, ob die Aufgabenassembly mit der gleichen Version der Microsoft.Build.Framework-Assembly erstellt wurde, die auf Ihrem Computer installiert ist, und dass Ihrer Hostanwendung kein BindingRedirect-Eintrag für Microsoft.Build.Framework fehlt. Das Objekt des Typs "Microsoft.Build.CPPTasks.SetEnv" kann nicht in Typ "Microsoft.Build.Framework.ITask" umgewandelt werden.
Die SetEnv-Aufgabe wurde falsch deklariert, falsch verwendet oder konnte bei der Erstellung nicht ausgeführt werden. Überprüfen Sie die Schreibweise des Aufgaben- und des Assemblynamens.
bei nCrunch.Compiler.RemoteBuildRunner.(FilePath ,   , String , String , DirectoryPath , String )
bei nCrunch.Compiler.RemoteBuildRunner.AnalyseComponentBuild(FilePath projectFilePath, BuildXml buildXml, String useBuildConfiguration, String useBuildPlatform, DirectoryPath solutionDir, String solutionName, List`1 importExpressionsToEvaluate)
--- Ende der internen Ausnahmestapelüberwachung ---
bei System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
bei System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
bei System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
bei nCrunch.TaskRunner.Ipc.IpcMessageProcessor.(CallMethodMessage )
bei nCrunch.TaskRunner.Ipc.IpcMessageProcessor.ProcessMessageReturningResult(Byte[] data)
bei nCrunch.TaskRunner.Ipc.RemoteInstance.[T](Byte[] )
bei nCrunch.TaskRunner.Ipc.RemoteInstance.Invoke(IMessage msg)
bei System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
bei nCrunch.Compiler.IRemoteBuildRunner.AnalyseComponentBuild(FilePath projectFilePath, BuildXml buildXml, String useBuildConfiguration, String useBuildPlatform, DirectoryPath solutionDir, String solutionName, List`1 importExpressionsToEvaluate)
bei nCrunch.Core.BuildManagement.BuildProcessLauncher..(IRemoteBuildRunner )
bei nCrunch.Core.BuildManagement.BuildProcessLauncher.(Action`1 , ProcessorArchitecture , GridClientId , IBuildableProject , CustomEnvironmentVariable[] )
bei nCrunch.Core.BuildManagement.BuildProcessLauncher.AnalyseComponentBuildInExternalProcess(FilePath projectFilePath, BuildXml buildXml, String useBuildConfiguration, String useBuildPlatform, DirectoryPath solutionDir, String solutionName, List`1 importExpressionsToEvaluate, ProcessorArchitecture processorArchitecture, VisualStudioVersion vsVersion, CustomEnvironmentVariable[] customEnvironmentVariables)
bei nCrunch.Client.ComponentLoader.SnapshotComponentFactory.(ProcessorArchitecture )
bei nCrunch.Client.ComponentLoader.SnapshotComponentFactory.CreateSnapshotComponentFromXml(FilePath projectFilePath, BuildXml projectXml, FilePath solutionFilePath, String[] additionalFilesToIncludeAtSolutionLevel, Boolean isLoadedFromFile, ISnapshotConfig snapshotConfig, VisualStudioVersion vsVersion)

Remco
#4 Posted : Thursday, July 30, 2015 11:05:05 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Thanks for sharing the extra details. It looks like VS2015 introduced a new range of binding redirections to allow its build process to work correctly with tasks built against older frameworks.

Go to your NCrunch installation (usually C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Remco Software\NCrunch for Visual Studio 2015). Look for a file called 'nCrunch.build.14.0.config'. Open the file, and look for a bunch of binding redirections like the following:

<dependentAssembly>
<assemblyIdentity name="Microsoft.Build.Framework" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="2.0.0.0-4.0.0.0" newVersion="14.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Build" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="2.0.0.0-4.0.0.0" newVersion="14.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Build.Engine" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="2.0.0.0-4.0.0.0" newVersion="14.0.0.0"/>
</dependentAssembly>

... Remove these, and replace them with the following:

<dependentAssembly>
<assemblyIdentity name="Microsoft.Build.Framework" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="2.0.0.0-12.0.0.0" newVersion="14.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Build" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="2.0.0.0-12.0.0.0" newVersion="14.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Build.Engine" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="2.0.0.0-12.0.0.0" newVersion="14.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Build.Conversion.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="2.0.0.0-12.0.0.0" newVersion="14.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Build.Tasks.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="2.0.0.0-12.0.0.0" newVersion="14.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Build.Utilities.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="2.0.0.0-12.0.0.0" newVersion="14.0.0.0"/>
</dependentAssembly>

Does this solve the issue?
wilhelmmedetz
#5 Posted : Friday, July 31, 2015 8:08:07 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 7/4/2012(UTC)
Posts: 35

Was thanked: 2 time(s) in 2 post(s)
Hi,

The proposed change worked.

Thanks for fixing it so fast.

Wilhelm

Remco
#6 Posted : Friday, July 31, 2015 11:13:38 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 959 times
Was thanked: 1290 time(s) in 1196 post(s)
Excellent. Thanks for confirming the fix. I'll see that these changes are introduced into the next version of NCrunch.
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.053 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download