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

Notification

Icon
Error

Missing project reference only in NCrunch
Luciferius
#1 Posted : Wednesday, December 3, 2014 8:10:54 AM(UTC)
Rank: Member

Groups: Registered
Joined: 2/28/2013(UTC)
Posts: 22

Thanks: 2 times
Was thanked: 4 time(s) in 4 post(s)
Hello,

I have added lately a new project to our solution as always, but I get the following error while building the assembly.

The type 'Ade.Documents.IDocument' is defined in an assembly that is not referenced. You must add a reference to assembly 'Ade.Core, version=1.0.0.0, Culture=neutral, PublicKeyToken=################'

This is a public type in the assembly Ade.Core which is a project reference of the failing assembly. If I build with VS everything is ok. I have enabled the option 'Prevent signing of output assembly'on all projects. When I disable it on the failing assembly I get the expected error:

Referenced assembly 'Ade.Core' does not have a strong name

This shows, that I have referenced the expected assembly. This is what I tried so far:

  • Readding the reference to the project.
  • Enabling the option 'Copy Referenced Assemblies To Workspace' on both projects.
  • Defining Ade.Core as 'Implicit Project Dependency' on the failing project.

Nothing worked so far.

I am using NCrunch 2.7.0.5. The assembly is referenced as:

<ProjectReference Include="..\Ade.Core\Ade.Core.csproj">
<Project>{F341BF26-967F-4113-BBE1-98819370832C}</Project>
<Name>Ade.Core</Name>
</ProjectReference>

Best regards,

Tobias Wilker

EDIT

I have further information regarding this issue. I use a different assembly reference to an assembly called Ade.Safety.Context.dll. I use a method - where the build error happens - called ManipulateDocument(Ade.Documents.IDocument) The interface Ade.Documents.IDocument was changed lately. My assembly uses the new version - because Ade.Core is a project reference. The Ade.Safety.Context.dll was compiled with the older version. Normally this would lead to an exception during runtime. Could it be,that NCrunch kind of anticipates this an therefore throws the build error? Can I force it to build nonetheless?
Remco
#2 Posted : Wednesday, December 3, 2014 9:17:02 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)
Hi Tobias,

Thanks for sharing this issue.

Based on what you've described, this is basically a type mismatch between the Ade.Safety.Context DLL and the project referencing Ade.Core ... So the error isn't entirely unexpected, but that doesn't explain why the projects are able to build in Visual Studio.

NCrunch uses somewhat different build logic than Visual Studio in that it swaps project references for assembly references at build time. This is done so that it can build projects independently without needing to build entire trees. In almost all cases, the end result is consistently the same as building against project references ... however, it wouldn't surprise me if there were some mechanical differences under the hood that might result in edge cases like this one being handled differently.

Troubleshooting a problem like this tends to get very expensive time-wise and doesn't always yield any solid information about why the compiler is behaving as it is. I would recommend rebuilding the Ade.Safety.Context DLL with the new version of Ade.Core, or perhaps consider including this project in the solution as a project reference.

Something else that may be worth trying is to set NCrunch in compatibility mode. Although it would be a rather academic exercise, this may help to identify whether there is a specific feature of NCrunch providing alternative logic in this situation.
Luciferius
#3 Posted : Wednesday, December 3, 2014 10:29:38 AM(UTC)
Rank: Member

Groups: Registered
Joined: 2/28/2013(UTC)
Posts: 22

Thanks: 2 times
Was thanked: 4 time(s) in 4 post(s)
Thank you for your fast reply. I certainly will update the Safety.Context, hoping this will solve the issue. Nonetheless I am looking for a way to force the build, so that I can see the failing tests, because the mentioned assembly is not in my hand. Like I said I already tried the 'Copy Referenced Assemblies To Workspace' option, no difference.
Remco
#4 Posted : Wednesday, December 3, 2014 10:42:46 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)
Luciferius;6650 wrote:
Thank you for your fast reply. I certainly will update the Safety.Context, hoping this will solve the issue. Nonetheless I am looking for a way to force the build, so that I can see the failing tests, because the mentioned assembly is not in my hand. Like I said I already tried the 'Copy Referenced Assemblies To Workspace' option, no difference.


Sorry, I wish I could provide you with a certain way to push through this .. although without the source itself I'm not sure if I could reliably reproduce the issue in order to troubleshoot it. If compatibility mode makes no difference here, then I don't think there is an existing option in NCrunch that would be able to alter the behaviour you're seeing.

If you don't have access to the source for the project in question, it may be possible to use ILDASM.EXE to decompile it into an IL dump, manually change the reference declarations inside the IL dump to point to the new version of the Core assembly, then use ILDASM to recompile the dump back into its assembly form.
1 user thanked Remco for this useful post.
Luciferius on 12/4/2014(UTC)
Luciferius
#5 Posted : Thursday, December 4, 2014 6:21:06 AM(UTC)
Rank: Member

Groups: Registered
Joined: 2/28/2013(UTC)
Posts: 22

Thanks: 2 times
Was thanked: 4 time(s) in 4 post(s)
I will try this. Thank you for your help. I appreciate it.
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.043 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download