0

我正在 Visual Studio 2017 中开发一个解决方案,其中有几个旨在分离功能的项目。然后将这些项目添加为其他项目的依赖项。

我正在尝试构建顶级项目的 64 位 exe,但由于某种原因,一些 32 位 dll 泄漏到构建中。

    ------ 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 ==========

一般层次结构如下:

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)

问题是在顶层,来自 LeadtoolsLib 项目的 32 位 .dll 被包括在内,而不是 64 位 dll。

PDFConverter 依赖于依赖于 LeadtoolsLib 的 IQHyland,但是 PDFConverter 也直接依赖于 LeadtoolsLib,我想这可能会导致问题,但我仍然不知道为什么考虑到 PDFConverter 本身它不会获得 64 位版本的 dll它是一个 64 位目标。

当我进行构建时,只构建了 64 位目标,除了 LeadtoolsLib,它同时构建了 32 位和 64 位目标。我不知道为什么构建认为任何东西都需要 32 位版本。

任何的想法?

编辑:配置管理器配置管理器 未显示“WebServicesWrapper /Debug/x64/ build 检查。

PDFConverter 参考资料

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 ==========
4

1 回答 1

1

在解决这个问题时,我们需要确定依赖项的来源。Visual Studio 中有两种类型的依赖项:程序集引用(如您通过“浏览...”对话框指定的依赖项)和项目引用。

要查看这两种类型的引用,您可以打开 Project -> Add Reference...

查看直接依赖关系的一种方法是在所有项目文件中搜索“HintPath”,例如“git grep HintPath”可能会显示如下内容:

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

如果您同时包含同一程序集的项目和程序集引用,则系统可能更喜欢其中一个(在这种情况下,其中一个项目首选 32 位库直接引用)。

于 2019-03-11T20:33:01.243 回答