Hi, everyone. I'm having a problem that I hope some more experienced
developers can help me figure-out.
We have a project called Records that has been around for a year or so.
We're currently coding an add-on to this project called Lessons. In
creating Lessons we're obviously trying to re-use existing code from
Records. And, of course, for political reasons I'm not free to make
any changes to Records.
The project Records contains a class called UserControl and a class
called Manager. Manager is a class that keeps track of the Record's
status, the user's actions, the Record's summary, etc.
The new project Lessons contains analogous classes. It has its own
UserControl and Manager classes that function similarly to the
analogous classes in Records. The new Lessons project also re-uses
some of the Records code and data, and the Records assembly is
referenced in the Lessons project.
So when Lessons starts-up it creates its own Manager object and stores
it in the Session object, which we handle in our own WebSession object.
At one point in the project we want to access some data from the
Record's database. We do this by creating a UserControl object from
the Records. Unfortunately we hit this code in the Records:
Dim obj As Core.Manager
obj = CType(Me.WebSession("ManagerSession"), Core.Manager)
The CType is what is puking because the application has a Manager
object that was created in the Lessons world, and this line of code is
trying to covert the object into the Records flavored Manager object.
Obviously. So what can I do to make sure that this cast is valid? I
think that I need to make sure that the Manager object created in
Lessons has the same signature as the Manager object created in
Records. Right? They currently have the same public methods and
properties, but some of those properties have the type of other custom
objects. Would I have to then ensure that each of THOSE objects has
the same signature in each project?
I hope this is clear, and I hope that this is just a problem that will
be more easily fixed when I have more experience with VB.Net.