1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
Try
Dim pathkd As String = Path.Combine(Application.StartupPath, "kd.sdk.dll")
'write dll on Application.StartupPath
If decompressdll(pathkd, My.Resources.kd_sdk) Then
temp_clean.Add(pathkd)
'Create the plug-in AppDomain setup.
Dim appDomSetup As AppDomainSetup = New AppDomainSetup With {
.ApplicationName = "KD.SDK",
.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory,
.LoaderOptimization = LoaderOptimization.MultiDomainHost,
.ShadowCopyFiles = "true"
}
'Create the plug-in AppDomain with the setup.
appDom = AppDomain.CreateDomain(appDomSetup.ApplicationName, Nothing, appDomSetup)
'Execute the loader in the plug-in AppDomain's context.
appDom.DoCallBack(New CrossAppDomainDelegate(AddressOf PluginCallback))
AppDomain.Unload(appDom)
appDom = Nothing
File.Delete(Path.Combine(Application.StartupPath, "kd.sdk.dll"))
Return True
Else
Throw (New Exception("decompress dll => false"))
End If
Catch ex As Exception
temp_log.Add(Now.ToString & " Error: " & ex.Message)
Return False
End Try
Public Sub PluginCallback()
Try
'Load the plug-in.
Dim pluginDLL As Reflection.Assembly = Reflection.Assembly.Load("kd.sdk")
'Create the instance of the plug-in And call the interface methods.
Dim myType As Type = pluginDLL.GetType("KD.SDK.Appli", True, True)
oAppli = Activator.CreateInstance(myType, IO.Path.GetFileName(SpaceFileName))
If Not oAppli.sessionid > 1 Then
Throw (New Exception("Session error => 0"))
End If
Catch ex As Exception
temp_log.Add(Now.ToString & " Error: " & ex.Message)
End Try
End Sub |
Partager