lundi 9 juillet 2018

C# Integrating classes from Shared Projects with many projects

I'm splitting an old project up into it's component parts so that the individual components can be used by several other projects.

There are around 4 stages that are split up into components and 3 master projects which will reference these components.

There's a main class (call it Master class for reference) that is consistent throughout that needs to be shared. I've setup a shared project and added the references, working fine.

The problem comes when trying to pass a variable using Class A (referenced from Project A's version of Master class) to a method in Component A's version of Master Class, I get compatibility issues. (Along the lines of cannot implicitly convert MasterClassA to MasterClassA)

I know they're identical and I understand that they are essentially a separate instance of Master class, which is why they're not currently compatible.

I've looked into generics/reflection, changing to a Portable Library Class and seem to be going around in circles. I know reflection is slow so I'd like to avoid it if possible.

Any guidance on best practice and how to resolve the issue? Here's a crude diagram of the layout. Solution Layout





Aucun commentaire:

Enregistrer un commentaire