Visual Studio 19 apps are much larger and include .dll files

Mark Green 41 Reputation points
2021-04-13T16:04:39.903+00:00

After previously using Visual Studio 2015 and 2012, I recently installed and began using Visual Studio 2019. Right away I noticed that .exe files, even for small apps were large, e.g. 150-200 KB. Using VS 2012, much larger apps had .exe sizes of 20-30 KB. I also noticed that apps developed with VS 2019 have .dll files. Apps developed using previous versions of VS do not.

Nearly all of the apps I develop are created using the Windows Forms Desktop template. They are meant to be simple apps that run on a Windows PC. Is there a simplified template that I can choose when I create a new project in VS 2019 so that apps are smaller and no .dll files are necessary?

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,604 questions
0 comments No comments
{count} votes

Accepted answer
  1. Michael Taylor 47,966 Reputation points
    2021-04-13T16:39:30.16+00:00

    Which template are you using exactly - there are multiple winforms templates? If you're targeting .NET Core/5 then yes there will be lots of extra DLLs because the runtime is very small so all additional dependencies are included in the app. This helps prevent breaking changes when the runtime is updated at the cost of more space.

    However if you're building a .NET Framework application then nothing has changed. The monolithic runtime is already installed somewhere and your app just needs its own code. Of course if an update to the .NET Framework happens to break your app there is not much you can do about it as the runtime is shared and you have no control over the runtime installed on a client machine but your app is smaller.

    This is the standard tradeoff that all languages/platforms have. Note that if you are building a .NET Core/5 app and you don't want any dependencies on external code then you can use a self contained deployment which packages everything into one. This makes it easier to deploy but the binary will be bigger and it is not cross-platform IIRC. The docs provide some guidance here.

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Mark Green 41 Reputation points
    2021-04-13T17:55:37.653+00:00

    I'm using one of these two circled templates (see attached screenshot). I used a text editor to look in some of the files in a solution/project but couldn't tell which template was used to create it.
    87410-vs-2019-project-templates.jpg

    From your description, it sounds like a Windows Forms app using the .NET Framework is what I want in order to have a smaller app. If I wanted to re-create my existing Windows Forms app as a .NET Framework app, how would I do that? Could I just create a new Windows Forms project using .NET Framework and then add the Form1.cs and Form1.Designer.cs files to the new project?

    Thanks!


  2. Mark Green 41 Reputation points
    2021-04-13T20:33:15.463+00:00

    Thank you very much! My project was based on .NET Core 3.1 which explains its large size and .dll's.

    I checked a second project that I created recently using VS 2019 and it was based on .NET Framework 4.7.2. The .exe file was quite small and there were no .dll's.

    It makes sense now. Thank you for explaining the difference so that I can convert my existing project and choose the right template for new projects.

    0 comments No comments