Is it possible ti inherit form 2 dll

C

Chris

Hi,
I am using 2 .dlls to create a 3 dll and I would like to expose all the
methods and functions form dll1 and dll2 in my 3dll so it appears as if
the methods sre in my 3dll. Currently I have

Imports dll1
Imports dll2

Public Class Test

Inherits dll1
Inherits dll2 >> Error here "Can have multiple Ihnerits"


End Class

Is it possible?

Thanks
 
J

john wright

..NET does not allow multiple inheritance. The only way around this is to
expose interfaces in the two dll's and access them via the 3rd.
John
 
C

Chris Dunaway

Chris said:
Inherits dll1
Inherits dll2 >> Error here "Can have multiple Ihnerits"

As the others told you, VB.Net does not support multiple inheritance
but you could have dll2 Inherit from Dll1 and then have dll3 inherit
from dll2:

'Dll2
Inherits Dll1


'Dll3
Inherits Dll2

It's not exactly the same and may work for you.

Another option is to design Dll3 with all the properties that you need
it to expose and then include instances of Dll1 and Dll2 inside Dll3
and forward the calls to those objects:

'Dll1
Public Sub Foo()


'Dll2
Public Sub Bar()


'Dll3
Private d1 As New Dll1
Private d2 As New Dll2

'This Foo just passes the call on the Dll1
Public Sub Foo()
d1.Foo
End Sub

'This Bar just passes the call on to Dll2
Public Sub Bar()
d2.Bar
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top