生成使用引用项目中不一致的dll体系结构

时间:2019-03-11 14:56:48

标签: visual-studio-2017

我正在研究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取决于IQHyland,后者取决于LeadtoolsLib,但是PDFConverter也直接取决于LeadtoolsLib,尽管我仍然不知道为什么它不能获得64位版本的dll,但我认为这可能是导致问题的原因。将PDFConverter本身视为64位目标。

进行构建时,除了LeadtoolsLib以外,仅构建了64位目标,而LeadtoolsLib既构建了32位目标,又构建了64位目标。我不知道为什么该版本认为任何东西都需要32位版本。

有什么主意吗?

编辑: 配置管理器Configuration manager 未显示“已检查WebServicesWrapper / Debug / x64 /构建。

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

1 个答案:

答案 0 :(得分:0)

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

要查看两种类型的引用,可以打开项目->添加引用...

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

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

如果您同时为同一程序集提供了Project和Assembly引用,则系统可能会优先选择另一个(在这种情况下,其中一个项目最好使用32位库直接引用)。