0

I'm trying to avoid wrong form showing when "Scale and layout" in windows screen settings is different than 100%.
I've folloved this LINK, and it works but only in 2 cases
1 - in debugging mode in VS
2 - if i put my *.exe file together with *.manifest and *.config files in same location.
If *.exe is alone then it does not work. I'm looking for a clue what to do next.


Update
This is how application is run.
Private Sub Monitor_Click(sender As Object, e As EventArgs)    
    Dim trd As New Thread(AddressOf ShowMonitor)
    trd.SetApartmentState(Threading.ApartmentState.STA)
    trd.Start()
End Sub

Private Sub ShowMonitor()
    Dim frMonitor As System.Reflection.Assembly = System.Reflection.Assembly.Load(File.ReadAllBytes("path to folder with DLL files\Monitor.dll"))
    Dim oType As System.Type
    Dim pControl As System.Object

    oType = frMonitor.GetType("Monitor.frmMonitor")
    pControl = Activator.CreateInstance(oType)
    Application.Run(pControl)
End Sub

So my "monitor" application works as expected only in 2 cases written above.

Sphinx
  • 628
  • 7
  • 15
  • What is the scenario for which you're running the exe without the config in the same location? – Andrew Mortimer Apr 29 '22 at 13:18
  • See https://stackoverflow.com/a/13228495/14171304 The `SetProcessDPIAware` part. – dr.null Apr 29 '22 at 13:32
  • @AndrewMortimer Well, this exe i used for testing. In real i compile it as dll. Scenario in general is that there's a "launcher" installed on user pc. This launcher runs DLL file on network location which is (this dll) a "hub" tu run multiple other DLLs. Each DLL is a different winform application. That would be the short explanation. – Sphinx Apr 29 '22 at 20:28
  • @dr.null I believe that this is what i've tried, and as i wrote it works partially. – Sphinx Apr 29 '22 at 20:28
  • See also https://stackoverflow.com/a/50276714/14171304. – dr.null Apr 29 '22 at 21:02
  • I've tried to dig through all the links but i'm stuck, and can't find my problem solution. Probably not skilled enough. I've updated my code with the part relevant to how the application is run. – Sphinx May 09 '22 at 09:58

0 Answers0