kawark
New member
I have a Winforms applicaton compiled as a Dynamic Link Library instead of an .exe
I pass the path of the dll to a console applicaton, Load the dll an assembly, do all the necessary steps to run the application and all works.
The Problem is that I can close my winforms application but my "Loader application" still shows up as running. You have to go to Taskmanager and close it.
Here is the console app that I pass the path to the dll to, create and run the application.
Can someone tell me what I need to do to get the console starter app to close either independently of the app it starts? Or how to close the console app when then started application is closed?
I pass the path of the dll to a console applicaton, Load the dll an assembly, do all the necessary steps to run the application and all works.
The Problem is that I can close my winforms application but my "Loader application" still shows up as running. You have to go to Taskmanager and close it.
Here is the console app that I pass the path to the dll to, create and run the application.
Can someone tell me what I need to do to get the console starter app to close either independently of the app it starts? Or how to close the console app when then started application is closed?
VB.NET:
Imports System
Imports System.Windows.Forms
Imports System.Diagnostics
Imports System.IO
Imports System.Reflection
Imports System.Xml
Module Module1
Sub Main()
Main(Environment.GetCommandLineArgs())
End Sub
Private Sub Main(ByVal args() As String)
Dim dllpath As String = ""
Try
dllpath = args(1).ToString()
Catch ex As Exception
'write to error log
Exit Sub
End Try
Dim fi As FileInfo = New FileInfo(dllpath)
Dim appname As String = fi.Name.Substring(0, fi.Name.Length() - fi.Extension.Length)
Try
Dim asm As Assembly = Assembly.LoadFrom(dllpath)
Dim clsname As String = appname & ".clsConsole"
Dim type As Type = asm.GetType(clsname)
Dim instance As Object = Activator.CreateInstance(type)
Dim mi As MethodInfo = type.GetMethod("CallFormWithParms")
mi.Invoke(instance, New Object() {My.Settings.AppConfigFilesPath})
Application.Run()
Catch ex As Exception
Dim str1 As String = ex.Message
End Try
End Sub
End Module