I am writing a program that uses an unmanaged library.
What is a best practice to handle a situation where the available foo.dll is of an incompatible version?
Examples: The user starts up the program and has an older version of the DLL than that which the program is expecting. Would you try to use it anyway, as breaking API changes should be uncommon in a mature library? Immediately error out? Maintain a resource in the program with download locations to every unmanaged DLL used?
Or is it considered best to include every DLL in the project’s own folder and insist on using exactly that file?
For now, I do the latter, and update the DLL with new project versions, but I’d like my software to be as fault-tolerant as is practical and I am unaware of any best practices for the use of unmanaged DLLs (other than “don’t use them unless you have to”).
Assuming the unmanaged DLL has version info embedded when compiled you could use the FileVersionInfo class in System.Diagnostics at application load to check for compatible versions.
If no compatible versions are found then alert the user?
http://msdn.microsoft.com/en-us/library/system.diagnostics.fileversioninfo.aspx