开发者

Is there a difference when referencing dll binaries or referencing a project in Visual Studio 2008?

开发者 https://www.devze.com 2023-03-31 07:53 出处:网络
I have two projects.Project A is a web project and project B is a Data Access Library.Project B has references to another Project (Project C), as well as some third party dlls that are referenced thro

I have two projects. Project A is a web project and project B is a Data Access Library. Project B has references to another Project (Project C), as well as some third party dlls that are referenced through files in a directory call "Library". If I reference Project B as a project reference, everything works. If, instead I reference the dlls that are output into the bin/debug folder of Projec开发者_C百科t B, everything builds, but I get the following error we the built in development web server tries to show the default page.

[BadImageFormatException: Could not load file or assembly 'my_dal.data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.]

I'm running Windows 7 64 bit Operating System, so it would seem I have a 32/64 bit problem, but I can't see how the build process is working with one reference and not the other.


That's because the project knows about it's own dependencies. A DLL doesnt provide information on dependent binaries that visual studio also needs to provide.

Either way, you should reference your project as a project not a binary, because then when you make changes to it, they automatically update the DLL on build.


The reason behind why referencing the files in bin/debug folder fails is because those files gets wiped out when you rebuild/clean the solution. The best way to reference a project in another project is to add it as a project reference and not through binary files.


The error you are getting there indicates you are trying to either
A) Load an assembly built for 64 bit and your on 32 bit
B) Load an assembly built for 32 bit and your on 64 bit

You can fix this error by changing your project to build for "Any CPU"

0

精彩评论

暂无评论...
验证码 换一张
取 消