简体   繁体   中英

Referencing DLL, Compiling, DLL versioning

After years in .NET, I'm asking a basic question. One kid just out of college asked me this and I was suddenly confused!

I am referencing a IBM DATA DB2 DLL in my .NET project. The version we used initially was 9.7.0.2. So after we ran some tests, we upgraded the IBM DATA DLL to version 9.7.6.2.

Now the question is, should I recompile my code and then run it or can I directly replace the IBM DATA DLL in my build directory and will it run fine?

When should we ideally recompile our code?

Thanks Soni

It depends on how you referenced DLL. In Solution Explorer, select your project and expand References in it. Select DLL and look at Property Editor window for property "Specific Version" . If it is set to false, then you can just replace binary in output, otherwise your application will throw error if it will not find that exact version of DLL.

Version of library must not be changed unless you're specifically targeting one (as when using entity framework and mysql adapter ), then you'll need to change the version number in order to work. Other case occurs when API change (not frequently, not ideally but it happens ).

This actually all depends on the DLL and the 3rd party that produced it. You need to look at the documentation and look for deprecated and modified functions (are you calling any of them?) And even if the doc says that nothing was changed and deprecated you should still do a regression test. Docs are not code, and the code is the truth that matters.

In a perfect world nothing would ever change or be deprecated in a public API and the writers of the DLL (interface) would just add new functions. Unfortunately, we can't count on that.

In brief: If any of the functions you're calling in the DLL were modified or deprecated, you have to rebuild, otherwise no.

Typically, third party DLL's should be backwards compatible. However, that is not always the case and you should recompile when upgrading to ensure that it is. If you swap versions of a DLL without compiling you risk running into a variety of runtime errors that could have easily been detected with compilation / testing.

You shouldn't need to recompile your code. That is the benefit of a dynamically linked library.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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