1

I have a WinForms application I'm designing, and I recently added capability to connect to Azure Devops to get a list of test suites/cases.

VssClientCredentials vcc = new VssClientCredentials(false);
connection = new VssConnection(new Uri(azureDevOpsOrganizationUrl), vcc);

When these lines run, the entire form shrinks down (including text sizes, button and frame sizes) and stay shrunken (not minimized, like 1/4 size). Note, that it becomes smaller the what the minimum size of the form is set to.

Here is a side-by-side comparison of the form size before and after: https://i.stack.imgur.com/zQkNw.png

I also just noticed as I was editing some identifying info out of the picture, that the Title on the Top-Left of the frame also disappeared when it shrunk.

Best I could figure it out, the line

VssClientCredentials vcc = new VssClientCredentials(false);

is the line that triggers the shrinking. I assume that this might be some function of the popup it's trying to call, but I'm not really sure why.

    private void AzureButton_Click (object sender, EventArgs e)
    {
        GetAzureNodes();
    }

    private async void GetAzureNodes()
    {
        AzureConnection azureConn = new AzureConnection(); //<----- Focus Here
        await azureConn.getConnection();
        if (azureConn.isConnected())
        {
            //Stuff
        }
    }
    public AzureConnection() //<----- Focus here
    {
        // Set false to require login popup every time.
        VssClientCredentials vcc = new VssClientCredentials(false);

        connection = new VssConnection(new Uri(azureDevOpsOrganizationUrl), vcc);
    }
    public async Task<int> getConnection()
    {
        await connection.ConnectAsync();
        return 0;
    }

Anybody know how to either prevent or undo the shrinking? Or even why it's happening at all?

  • After you enter the username & password on the pop-up the form still small? – Shayki Abramczyk Aug 01 '19 at 06:01
  • Yes, it is. Even resizing the form (dragging the sides or corner), while resizing the TreeView frame and moving the appropriate buttons relevant to their anchoring positions, does not make them grow back to their original size (text, button sizes). – Brad Shennette Aug 01 '19 at 13:12

1 Answers1

0

Problem was resolved by adding an app.manifest file with the following content.

<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3"  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>

  <asmv3:application>
    <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
     <!--
        Trying to generate the WPF Azure Login Page on a Winforms project suddenly made the app self-awar- I mean, aware of DPI.
        That caused it to suddenly shrink. This setting stops that.
      -->
      <dpiAware>false</dpiAware>
    </asmv3:windowsSettings>
  </asmv3:application>

</asmv1:assembly>

I found the answer in this question: https://stackoverflow.com/a/36344413/9866316