Security warning regarding WinForms component in VS 2019 (dll may have been downloaded from a network location)

wisekat 1 Reputation point
2021-07-22T09:23:19.807+00:00

Our customers have a legal copy of a WinForms component compiled for .NET Framework 4. Recently they surprised us - they can no longer add it to the Toolbox in Visual Studio 2019 and use it in VB.NET WinForms projects. The installation package of the component simply does not create the icons on the Toolbox automatically without reporting any errors, though earlier it worked without any problems.

While investigating this issue, I tried to add the component to the Toolbox manually and faced a strange security warning while doing this. First I create a new Toolbox tab, then open the Toolbox context menu and select the Choose Items... command to open the Choose Toolbox Items dialog. If I click the Browse button in the dialog on the default .NET Framework Components tab and select the component in the File Open dialog, the following security warning appears:

117017-warning-message-box.png

Security warning: 'C:...\Something.DLL' may have been downloaded from a network location, and it can potentially harm your computer. Only load assemblies from publishers you trust.

Do you want to load it anyway?

If I allow adding of the component in this message box by clicking Sì (Yes in Italian), it appears on the Toolbox, but it still cannot be added to a WinForms form. It does not appear on the form if we double-click its icon on the Toolbox or drag-and-drop it onto the form. The only thing that appears is a reference to the component in the References node of the project in the Solution Explorer.

It is very strange because the same component works without any problems on another pc of our customers. I tried to reinstall the component, cleaned all remnants on the disk and in the registry after previous installations of the component, checked the component digital signature, launched VS with admin rights, checked it with the alternative antivirus the customer is using (BitDefender) - nothing helped.

The only workaround that helps to solve the problem is the following. If the component DLLs are copied to C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE, they can be successfully added to the Toolbox without any security warnings.

What can be the reason of this problem specific only for one instance of Visual Studio? The customers were using the latest build of Visual Studio, v16.10.3, on the moment of investigating this issue.

Developer technologies | Windows Forms
Developer technologies | VB
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Karen Payne MVP 35,586 Reputation points Volunteer Moderator
    2021-07-22T13:56:57.073+00:00

    Perhaps running the following code where folderName is where the DLL is located.

    Option Infer On
    
    Public Shared Sub UnblockFiles(ByVal folderName As String)
        If Not Directory.Exists(folderName) Then
            Return
        End If
    
        Dim start = New ProcessStartInfo With {
            .FileName = "powershell.exe",
            .Arguments = $"Get-ChildItem -Path '{folderName}' -Recurse | Unblock-File",
            .CreateNoWindow = True
        }
    
        Using process As System.Diagnostics.Process = System.Diagnostics.Process.Start(start)
    
        End Using
    End Sub
    

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.