Search code examples
visual-studio-2017

Build is using inconsistent dll architecture from referenced projects


I'm working on a solution in Visual Studio 2017 where there are several projects intended to separate functionality. Those projects are then added as dependencies of other projects.

I'm trying to build a 64-bit exe of the top level project but for some reason some 32-bit dlls are leaking into the build.

    ------ Build started: Project: LeadtoolsLib, Configuration: Debug x64 ------
  LeadtoolsLib -> C:\Users\its-rowc\source\Workspaces\Imaging\LeadTools\bin\x64\Debug\IQLeadtools.dll
------ Build started: Project: LeadtoolsLib, Configuration: Debug Any CPU ------
  LeadtoolsLib -> C:\Users\its-rowc\source\Workspaces\Imaging\LeadTools\bin\Debug\IQLeadtools.dll
------ Build started: Project: WebServicesWrapper, Configuration: Debug x64 ------
  WebServicesWrapper -> C:\Users\its-rowc\source\Workspaces\Imaging\WebServicesWrapper\bin\x64\Debug\WebServicesWrapper.dll
------ Build started: Project: IQHyland, Configuration: Debug x64 ------
  IQHyland -> C:\Users\its-rowc\source\Workspaces\Imaging\IQHyland\bin\x64\Debug\IQHyland.dll
------ Build started: Project: PDFConverter, Configuration: Debug x64 ------
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2110,5): warning MSB3270: There was a mismatch between the processor architecture of the project being built "AMD64" and the processor architecture of the reference "Leadtools.Codecs", "x86". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2110,5): warning MSB3270: There was a mismatch between the processor architecture of the project being built "AMD64" and the processor architecture of the reference "Leadtools.Codecs.Fax", "x86". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2110,5): warning MSB3270: There was a mismatch between the processor architecture of the project being built "AMD64" and the processor architecture of the reference "Leadtools.Codecs.Tfx", "x86". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2110,5): warning MSB3270: There was a mismatch between the processor architecture of the project being built "AMD64" and the processor architecture of the reference "Leadtools.Codecs.Tif", "x86". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2110,5): warning MSB3270: There was a mismatch between the processor architecture of the project being built "AMD64" and the processor architecture of the reference "Leadtools", "x86". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2110,5): warning MSB3270: There was a mismatch between the processor architecture of the project being built "AMD64" and the processor architecture of the reference "Leadtools.Pdf, Version=19.0.0.0, Culture=neutral, PublicKeyToken=9cf889f53ea9b907, processorArchitecture=x86", "x86". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.
  PDFConverter -> C:\Users\its-rowc\source\Workspaces\Imaging\PDFConverter\bin\x64\Debug\PDFConverter.dll
------ Build started: Project: DocProcessor, Configuration: Debug x64 ------
  DocProcessor -> C:\Users\its-rowc\source\Workspaces\Imaging\DocProcessor\bin\x64\Debug\DocProcessor.exe
------ Build started: Project: IQHylandTest, Configuration: Debug x64 ------
  IQHylandTest -> C:\Users\its-rowc\source\Workspaces\Imaging\IQHylandTest\bin\x64\Debug\IQHylandTest.exe
------ Build started: Project: IQHylandUnitTest, Configuration: Debug x64 ------
  IQHylandUnitTest -> C:\Users\its-rowc\source\Workspaces\Imaging\IQHylandUnitTest\bin\x64\Debug\IQHylandUnitTest.dll
========== Build: 8 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

The general hierarchy is as follows:

PDFConverter .exe (64-bit exe with some incompatible 32-bit dlls)
    IQHyland 
    LeadtoolsLib 
        Leadtools.dll (32-bit!)
    WebServicesWrapper

IQHyland .dll (only 64-bit gets built)
    LeadtoolsLib 
        Leadtools.dll (64-bit)

LeadtoolsLib .dll (both 32 and 64 bit get built, why?)


WebServicesWrapper .dll (only 64-bit gets built)

The issue is that at the top level, the 32-bit .dlls from the LeadtoolsLib project are being included rather than the 64-bit dlls.

PDFConverter depends on IQHyland which depends on LeadtoolsLib, however PDFConverter also directly depends on LeadtoolsLib, which I imagine might be causing the issue, though I still don't know why it wouldn't get the 64-bit version of the dlls considering PDFConverter itself it a 64-bit target.

When I do the build, only 64-bit targets are built EXCEPT for LeadtoolsLib which has both 32-bit and 64-bit targets built. I don't know why the build thinks the 32-bit version is required by anything.

Any idea?

Edit: Configuration manager Configuration manager Not shown "WebServicesWrapper /Debug/x64/ build checked.

PDFConverter References

2>------ Build started: Project: WebServicesWrapper, Configuration: Debug x64 ------
1>  LeadtoolsLib -> C:\Users\its-rowc\source\Workspaces\Imaging\LeadTools\bin\x64\Debug\IQLeadtools.dll
3>------ Build started: Project: IQHyland, Configuration: Debug x64 ------
2>  WebServicesWrapper -> C:\Users\its-rowc\source\Workspaces\Imaging\WebServicesWrapper\bin\x64\Debug\WebServicesWrapper.dll
3>  IQHyland -> C:\Users\its-rowc\source\Workspaces\Imaging\IQHyland\bin\x64\Debug\IQHyland.dll
4>------ Build started: Project: PDFConverter, Configuration: Debug x64 ------
4>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2110,5): warning MSB3270: There was a mismatch between the processor architecture of the project being built "AMD64" and the processor architecture of the reference "Leadtools", "x86". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.
4>  PDFConverter -> C:\Users\its-rowc\source\Workspaces\Imaging\PDFConverter\bin\x64\Debug\PDFConverter.dll
========== Build: 4 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

Solution

  • When solving this we needed to identify where dependencies are coming from. There are 2 types of dependencies in Visual Studio: Assembly references (like the dependencies you specify by "Browse..." dialog), and Project references.

    To see both types of references you can open Project -> Add Reference...

    One way to see just the direct dependencies is to search for "HintPath" in all of project files, e.g. "git grep HintPath" might show something like:

    ...
    myproject.csproj:      <HintPath>...\path\to\LeadtoolsLib.dll</HintPath>
    ...
    

    If you include both Project and Assembly reference for the same assembly, the system might prefer one over the other (in this case the 32-bit library direct reference was preferred for one of the projects).