无法加载文件或程序集(dll文件) [英] Could not load file or assembly (dll file)

查看:123
本文介绍了无法加载文件或程序集(dll文件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一些由C ++ dll调用的第三方dll,我在CLI中编写了一个包装器(用/clr编译),并在我的c#应用程序中调用函数和方法.
如果在调试中执行此操作,则一切正常.但是,当我切换到释放并编译一切正常(即使使用第3方发布dll)时,它总是告诉我未找到包装dll.
错误:

so I have some 3rd party dlls which are called by a c++ dll for which I wrote a wrapper in CLI(compiled with /clr) and I am calling funtions and methodes in my c# app.
If I do it in the debug everything works perfectly. But when I switch to release and compile everything ok(even using the 3rd party release dll''s) it keeps telling me that the wrapper dll was not found.
error :

//Could not load file or assembly 'xxx, Version=1.0.4475.16087, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.


为什么可能这样...我搜索了路径,并且dll存在于其中.
顺便说一下,我所有的dll和可执行文件都建在同一个目录中.

还有一件事...是否有可能在每个地方都有相对路径,所以我可以使它更便携?


why could that be possible...and I searched the path and the dll exists there.
By the way all my dlls and executable are all built in the same directory.

and one more thing...is it possible to have relative paths everywhere so I can make it more portable ?

推荐答案

因此,如果我在c#项目中进行更改,它就可以工作从任何CPU到x86(所有dll都在WIN32中编译),从Properties->建立->平台目标.我在64位Win7 PC上工作,显然如果我使用Any CPU作为目标,则找不到包装dll.
So it works if I change in the c# project from Any CPU to x86(all dlls are compiled in WIN32) from Properties -> Build -> Platform Target. I work on a 64-bit Win7 pc and aparently if I use Any CPU as target it does''t find the wrapper dll.


这篇关于无法加载文件或程序集(dll文件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆