G
Guest
In VB6, we created a number of ActiveX DLLs that all shared a similar
interface. The main application would load these in dynamically (late-bound.)
This worked well for our situation because we could update the DLLs
independently of the main EXE, and performance was not a problem.
We want to do the same thing in C# (at least test it), but we are not
exactly clear what the best practice is. We would prefer to do something
similar, but we are open to any advice.
In VB6 terms, we have a shared class which serves as the interface to our
DLLs. To keep the example simple, I created this:
‘ VB6 Class Interface
Public Function DoSomething() As Boolean
DoSomething = True
End Function
Each DLL would be compiled with the same class.
A simple example of how we would use this is here:
Private Sub Command1_Click()
Dim objClass As Object
Dim strClass As String
Dim bUseFirstClass As Boolean
bUseFirstClass = False
If bUseFirstClass = True Then
strClass = "prjTestA.clsExample"
Else
strClass = "prjTestB.clsExample"
End If
Set objClass = CreateObject(strClass)
Debug.Print objClass.DoSomething()
Set objClass = Nothing
End Sub
What is the best way to do something similar in C#? We started looking at
reflection, but I want to make sure that is considered the best way to
approach this, or if there is some other words of wisdom we should follow.
Any sample code would be most appreciated!
Thank you for your time and advice.
Mo
interface. The main application would load these in dynamically (late-bound.)
This worked well for our situation because we could update the DLLs
independently of the main EXE, and performance was not a problem.
We want to do the same thing in C# (at least test it), but we are not
exactly clear what the best practice is. We would prefer to do something
similar, but we are open to any advice.
In VB6 terms, we have a shared class which serves as the interface to our
DLLs. To keep the example simple, I created this:
‘ VB6 Class Interface
Public Function DoSomething() As Boolean
DoSomething = True
End Function
Each DLL would be compiled with the same class.
A simple example of how we would use this is here:
Private Sub Command1_Click()
Dim objClass As Object
Dim strClass As String
Dim bUseFirstClass As Boolean
bUseFirstClass = False
If bUseFirstClass = True Then
strClass = "prjTestA.clsExample"
Else
strClass = "prjTestB.clsExample"
End If
Set objClass = CreateObject(strClass)
Debug.Print objClass.DoSomething()
Set objClass = Nothing
End Sub
What is the best way to do something similar in C#? We started looking at
reflection, but I want to make sure that is considered the best way to
approach this, or if there is some other words of wisdom we should follow.
Any sample code would be most appreciated!
Thank you for your time and advice.
Mo