简体   繁体   English

C#项目,GAC,DLL

[英]C# Project, GAC, DLL

i'm having a problem with my built Application. 我的内置应用程序有问题。

I have a project taken from here modified it and implemented in my program. 我有一个项目从这里进行修改,并在我的程序中实现。
Shortly, this TableProc project generates a report to OpenOffice Calc and uses some libraries from OpenOffice - cli_basetypes (GAC/MSIL), cli_oootypes (GAC/MSIL), cli_uno (GAC/MSIL), cli_ure (GAC/MSIL), cli_uretypes (GAC/MSIL) AND cli_cppuhelper (GAC32). 不久,此TableProc项目生成了一份OpenOffice Calc报告,并使用了OpenOffice中的一些库-cli_basetypes(GAC / MSIL),cli_oootypes(GAC / MSIL),cli_uno(GAC / MSIL),cli_ure(GAC / MSIL),cli_uretypes(GAC / MSIL) cli_cppuhelper(GAC32)。

Looks like: 看起来像:
Solution
.....Project1 (references TableProc) ..... Project1(引用TableProc)
.....Project2 (references TableProc) ..... Project2(引用TableProc)
.....TableProc (implemented) (references on libraries in bin directory cli_basetypes.dll and others) ..... TableProc(已实现)(对bin目录cli_basetypes.dll和其他目录中库的引用)

So, when i'm in debugging mode VS 2010, those DLL are in directory */bin/ - Everything works fine - reports are done. 因此,当我处于VS 2010调试模式时,那些DLL位于目录* / bin /中 -一切正常-报告已完成。

But when i build up my application: 但是当我建立我的应用程序时:
1. There are no DLL's for cli_basetypes, cli_oootypes and others 1. cli_basetypes,cli_oootypes和其他没有DLL。
2. There are project1.dll, project2.dll and TableProc.dll and Program.exe 2.有project1.dll,project2.dll和TableProc.dll和Program.exe

PROBLEM: 问题:

In a built up application, it tells that: 在一个已构建的应用程序中,它表明:

Error 1: 错误1:

Could not load file or assembly 'cli_cppuhelper, Version=1.0.14.0, Culture=neutral, PublicKeyToken=ce2cb7e279207b9e' or one of its dependencies. 无法加载文件或程序集“ cli_cppuhelper,版本= 1.0.14.0,文化=中性,PublicKeyToken = ce2cb7e279207b9e”或其依赖项之一。 Ann attempt was made to load a programm with an incorrect format.) Ann试图加载格式错误的程序。)

Ok, I tried to manually put those DLL's next to my Program.exe - same error. 好的,我试图手动将那些DLL放在我的Program.exe旁边-同样的错误。

Then I found out, that those libraries are installed in GAC when you install Open Office. 然后我发现,当您安装Open Office时,这些库已安装在GAC中。 I looked at them, and noticed that all of them are installed in GAC/MSIL but cli_cppuhelper is installed in GAC/32. 我查看了它们,发现它们全部安装在GAC / MSIL中,而cli_cppuhelper安装在GAC / 32中。

I tried to manually copy cli_cppuhelper assembly from GAC/32 to GAC/MSIL, and got this error: 我尝试将cli_cppuhelper程序集从GAC / 32手动复制到GAC / MSIL,但出现此错误:

Error 2: 错误2:

Is not a valid Win32 application. 不是有效的Win32应用程序。 (Exception from HRESULT: 0x800700C1)) (来自HRESULT的异常:0x800700C1)

From this i understood, that my apllication, when looks for DLL's it looks only in GAC/MSIL 据我了解,我的应用程序在查找DLL时仅在GAC / MSIL中

Please help, i don't know what to do... 请帮助,我不知道该怎么办...

将平台从AnyCPU更改为x86。

For those that find this in the future. 对于那些将来会发现这一点的人。

The problem is that the targeted platform in Visual Studio is incorrect. 问题是Visual Studio中的目标平台不正确。 The .dlls need to be compiled with the correct bit version. .dll文件必须使用正确的位版本进行编译。

You need to change the targeted platform in Visual Studio to: 您需要将Visual Studio中的目标平台更改为:

  • 64-bit -> x64 64位-> x64
  • 32-bit -> x86 32位-> x86

Note: AnyCPU does not work. 注意:AnyCPU不起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM