Question

I have a 'small' problem in one of my projects. I have to invoke 2 assemblies stored in

Byte()

I don't want them to be written to the disk, to do so, I do

        Sub Main()                
                Dim trd As New System.Threading.Thread(AddressOf LodFile1)
                trd.IsBackground = True
                trd.Start()
                Dim resourceManager As New Resources.ResourceManager("Files", System.Reflection.Assembly.GetExecutingAssembly)
                Dim [Bin2] As Byte() = DirectCast(resourceManager.GetObject("File2"), Byte())
                resourceManager.ReleaseAllResources()
                Dim a2 = System.Reflection.Assembly.Load([Bin2])
                Dim m2 As System.Reflection.MethodInfo = a2.EntryPoint
                Dim o2 As Object = a2.CreateInstance(m2.Name)
                m2.Invoke(o2, New Object() {New String() {"1"}})
        End Sub
        Sub LodFile1()
                Dim resourceManager As New Resources.ResourceManager("Files", System.Reflection.Assembly.GetExecutingAssembly)
                Dim [Bin1] As Byte() = DirectCast(resourceManager.GetObject("File1"), Byte())
                resourceManager.ReleaseAllResources()
                Dim a1 = System.Reflection.Assembly.Load([Bin1])
                Dim m1 As System.Reflection.MethodInfo = a1.EntryPoint
                Dim o1 As Object = a1.CreateInstance(m1.Name)
                m1.Invoke(o1, New Object() {New String() {"1"}})
        End Sub

Yes, the two assemblies runs fine, the appear both, but when I close one, the three apps close(This one, and those that were loaded from byte()).

So, I am asking on how to run them separately.

Was it helpful?

Solution

Background threads are aborted when there are no foreground threads running.

Try: trd.IsBackground = False

Or even better: Just remove the line :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top