Daily Usage Issues

Use in solution with VC++ project

Started by psilvaferreira on 7,050 views

Hi,

My solution contains one VC++ project that builds a DLL which is used by my test assembly. This unmanaged DLL is required to run the tests (basically, my .NET assembly will be testing against the unmanaged version).

Now when I configure NCrunch in my solution it will try to build the VC++ project and, as far as I can see, will try to load the unmanaged DLL as if it were managed, giving me an error:


NCrunch: If you are experiencing problems in getting this project to build, have a look at https://www.ncrunch.net/documentation/troubleshooting_project-build-issues
(0): System.BadImageFormatException: Format of the executable (.exe) or library (.dll) is invalid.
at Mono.Cecil.PE.ImageReader.ReadOptionalHeaders(UInt16& subsystem)
at Mono.Cecil.PE.ImageReader.ReadImage()
at Mono.Cecil.PE.ImageReader.ReadImageFrom(Stream stream)
at Mono.Cecil.ModuleDefinition.ReadModule(Stream stream, ReaderParameters parameters)
at nCrunch.Reflection.Cecil.CustomCecilAssemblyResolver.LoadAssembly(String compiledAssemblyFilePath, IDictionary`2 documentFilePathMap)
at nCrunch.Compiler.StaticManipulation.BuiltAssembly..ctor(String builtAssemblyFilePath, IList`1 adjustedAssemblyReferences, IDictionary`2 codeFilePathsByWorkspaceFilePath, Boolean instrumentForPerformanceMeasurement)
at nCrunch.Compiler.RemoteBuildRunner.#=qG3xdYhfR9FrLKjSk7_DjKTEHGSCh98p3RXMZRew3v94=(ComponentBuildParameters #=qdxVPMjovJt8faoeOknNjoA==, String #=q_Vd_hVdT8ec$sXMmcu$iiwI6vfq43uyiWq3iGXbN3Tk=, BuildOutput #=qCE28jExqmIRdWsuiBUzoIQ==, String #=qDISW8vYeJKSpzLfOxACHpG_LUfk0kp_p0n_fP40Rmg0=)
at nCrunch.Compiler.RemoteBuildRunner.Build(ComponentBuildParameters parameters)


Is there any way to workaround this?

Thanks

Pedro
Hi Pedro,

At the moment NCrunch doesn't support C++ projects. The best workaround I can offer would be to avoid creating project references to C++ projects inside your solution - use assembly references instead. Using the IDE, delete all references from other projects in your solution to your C++ project, then replace them with references to the compiled C++ assembly on disk. If you adjust your NCrunch project configuration to enable the 'Ignore this component completely' on the C++ project, NCrunch should be able to build and run tests over your solution while ignoring the C++ project.

This suggestion is theoretical since without your solution I have no way to be sure whether it would work, but my expectation is that NCrunch won't trigger for any changes you make to your C++ project until you manually rebuild it.

I'm keen to hear if this gets you working.


Cheers,

Remco

Post a reply

Log in to reply.