c# - .NET Client supporting multiple versions of an unmanaged DLL -


I am developing a .NET 4.0 client which will use the C library for data processing. The user will be able to specify the DLL file you want to load for processing.

I am loading late bond / assembly as described here.

For each DLL, the same method call sequence in my client will be similar, but the method signing will change or the data strings will be changed. Based on version of DLL and other factors, the population data with structures will be different. For example, the definition of MyStruct will change based on the version of DLL.

Public Representative int INTF_my_method (Ref: MyStruct pDataStruct);

What design patterns or design approaches are recommended for this approach? I need to load proper system representatives and data definitions based on the version of the DLL that the user has specified, and have properly populated the structures. Has anyone done something like this before?

There is no clear view in it, neither in managed code nor in native code. Best of all, you probably have to declare an interface type that tries to cover all possible versions and then writes solid wrapper sections for each individual version of API. If there is at least some general functionality then you can dig into that base category.

Noteworthy too is that you can not choose a DLL user, you must add DLL to the concrete wrapper class example.

Preparing such flexibility in your program is clearly very expensive.

Comments