0

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 (located in the Shared Project, call it Master class for reference) that is consistent throughout that is 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

Matt Scott
  • 252
  • 2
  • 15
  • If you need to share your masterclass it should be located in the shared project. Then you can use it in all places. Duplicating a class and compile it into different assemblies will result in completely independant classes albeit the same name and content. – thehennyy Jul 09 '18 at 10:01
  • It is indeed located in the shared project, just referenced elsewhere. I've updated the post to make that more obvious. Thanks – Matt Scott Jul 09 '18 at 10:12

1 Answers1

0

In case anyone comes across this, this answer resolved the issue for me;

Referencing shared project in several projects of solution

Essentially we create a class library that references the Shared Project, then reference the new project, not the Shared project.

Matt Scott
  • 252
  • 2
  • 15