r/visualbasic • • Apr 22 '21

Windows Forms Application without console windows

I am currently creating a Windows Forms application for work.

Whenever I execute the app it not only opens the form itself but also a console window.

I've found out the apparently switching the type of the application from "console application" to "Windows Application" should result in the desired behaviour. But unfortunately it still persists.

Is there anything else that I might have to set to disable the console?

Thank you all in advance.

5 Upvotes

4 comments sorted by

1

u/free_spam Apr 23 '21

I was not able to get it to work through the built-in publishing in visual studio, but using

dotnet publish -c Release -r win10-x64 --self-contained true -p:PublishSingleFile=true

worked immediately (which is weird, since I am using the same parameters in the .pubxml.

Creating a new project also did not fix the problem.

Thanks to all for your help.

3

u/chacham2 Apr 22 '21

Console applications open a console. Windows applications do not (automatically). Hence, if you switch the application type from the former to the latter, the console should not open. I have done this many times.

My thoughts are, either your application is not being recompiled before running as a Windows application, or the code is opening to console. To verify the former, go to Build->Rebuild Solution and try again. For the latter, use F11 to see when the console opens.

2

u/darkspy13 Apr 22 '21

Without digging through to see what's wrong.. Create a new winforms app that works correctly and move your designer/code files over?

2

u/thalrok Apr 22 '21

You might want to look at your project settings. I don't think changing the application type automatically updates the projects "start object".
My guess is the "start object" is still the "main" procedure and you'll need to change it to the form.