Note: I’m a novice, so there may very well be a totally obvious way I’ve not recognized.
I have the following projects:
TradingProject (my code) Has reference to TradingLibrary, and to ApiLibrary?
TradingLibrary (my code) Has reference to ApiLibrary
ApiLibrary (3rd party code)
I’m making several projects (like TradingProject) that communicate with a software through use of an existing ApiLibrary. But I want to push generic methods into a library I write: TradingLibrary.
Still, I would like to use some parts of the ApiLibrary directly from TradingProject. However, I then would need to pass an object (of an ApiLibrary class) into a method in TradingLibrary. Where the object should be recognized. However I assume this will be a problem, as TradingLibrary use it’s own reference to ApiLibrary, so it will not be recognized as the same classes?
So.. Question is. Is there some way I can “forward” the ApiLibrary reference from TradingLibrary to MyProject, such that they will use the same reference? Or do I need to duplicate the classes and inherit from ApiLibrary for each class? Like:
NameSpace TradingLibrary
Public Class SomeClass
Inherits ApiLibrary.SomeClass
End Class
I guess that would work, if I do it for all classes I need, but is there perhaps some simpler way I’m not aware of?
Cheers!
If it is the same assembly (dll), then the type is the same and no mismatch will occur.
If you have multiple versions of the same dll loading into the same AppDomain, then things are already horribly mixed up. At this point, you can use forwarding via configuration; for example, the following forwards and MVC 1.*/2.* references to MVC 3.0
But I stress: the above is usually not needed, especially if you are shipping your dlls next to the application (rather than using the GAC).