Reputation: 4574
I have a pair of assemblies that implement the same functionality using two different backends:
Engine.OpenGL.dll
Engine.DirectX11.dll
Is it possible to create a single Visual Studio project that is capable of using any of these backends without recompiling? The namespaces/classes/methods exposed by both Engine DLLs are the same (or at least the ones I use in my project are the same).
I tried building my project against one of the Engine assemblies, and then replacing it with the other (by overwriting the dll file). This results in the following error:
The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Do I have to create 2 separate projects with the only difference between them being which Engine DLL they reference?
Upvotes: 3
Views: 1347
Reputation: 326
Couldn't you create a project called something like "GraphicsEngineContract" and use that to define interfaces that represent the various classes in your two different engine projects. Then in your engine projects you could make sure that all of your matching classes implement the same interfaces (or abstract classes from the Contract project if any are in there).
You would then refactor the primary project to refer only to the supertypes (abstract classes and interfaces) in the contract project. Finally, your initialization processes would get the ball rolling by detecting what is available on the local systems and assigning concrete instances based on what it finds.
Then it wouldn't be a case of either-or. You would copy both references locally and create objects for them based on what is installed on the end user's machine.
If you followed this approach you would probably end up with four projects. The primary project, contract project, directx project, and opengl project.
Upvotes: 2