As a .NET developer, I’ve spent most of my time coding on Windows machines. It’s only logical: Visual Studio is the richest development experience for building C# and VB.NET applications, and it only runs on Windows…right?
- Windows Form Application Visual Studio 2019
- Visual Studio Winforms Controls
- Visual Studio Mac Windows Forms
- Windows Form Application Visual Studio
- Winform App On Mac Using Visual Studio Windows 10
- Winform App On Mac Using Visual Studios
Visual Studio for Mac.NET. Azure DevOps. Azure DevOps Server (TFS) 0. Visual Studio warnings for a Winform app if I close the app after starting to build the code again. Visual studio 2017 version 15.8 windows 10.0. Sylvia-List-ext reported Sep 19, 2018 at 12:02 PM. I have a rather large WinForms app I'm developing in C# using VS Community 2015 (Version 14.0.25123.00 Update 2) with SQLite as the dbms and a UI that heavily uses a DataGridView that works in somewhat fancy ways via various event handling. I'd like to port as much of it as possible to also run on a Mac. Visual Studio 2019 for Mac. Develop apps and games for iOS, Android and using.NET. Download Visual Studio for Mac. Create and deploy scalable, performant apps using.NET and C# on the Mac.
When I joined Stormpath to work on our open-source .NET authentication library, I was handed a MacBook Pro and given an interesting challenge: can a Mac be an awesome .NET development platform?
To my surprise, the answer is yes! I’ll share how I turned a MacBook Pro into the ultimate Visual Studio development machine.
How to Run Visual Studio on a Mac
Visual Studio doesn’t run natively on OS X, so my first step was to get Windows running on my MacBook Pro. (If you want an editor that does run natively, Xamarin Studio or Visual Studio Code might fit the bill).
There are multiple options for running Windows on a Mac. Every Mac comes with Apple’s Boot Camp software, which helps you install Windows into a separate partition. To switch between OSes, you need to restart.
Parallels is a different animal: it runs Windows (or another guest OS) inside a virtual machine. This is convenient because you don’t have to restart your computer to switch over to Windows. Instead, Windows runs in an OS X application window.
I found that a combination of both worked best for me. I installed Windows into a Boot Camp partition first, and then turned that partition into an active Parallels virtual machine. This way, I have the option of using Windows in the virtual machine, or restarting to run Windows natively at full speed.
I was initially skeptical of the performance of a heavy application like Visual Studio running in a virtual machine. The option to restart to Windows via Boot Camp gave me a fallback in case Visual Studio was sluggish.
There are some minor disadvantages to this method: you can’t pause the virtual machine or save it to a snapshot. A non-Boot Camp virtual machine doesn’t have these limitations. This guide will work regardless of what type of virtual machine you create.
After three months of serious use, and some tweaks, I’ve been very impressed with Parallels’ performance. I haven’t needed to boot directly to Windows at all. (For comparison, my host machine is a 15” mid-2015 MacBook Pro with 16GB of RAM and a 1TB flash drive.)
In the remainder of this guide, I’ll detail the steps I took to optimize both Parallels and Visual Studio to run at peak performance.
Installing Windows With Boot Camp and Parallels
This part’s easy. I followed Apple’s Boot Camp guide to install Windows in a separate partition.
Then, I installed Parallels and followed the Parallels Boot Camp guide to create a new virtual machine from the existing Boot Camp partition.
Tweaking Parallels for Performance and Usability
The Parallels team publishes guidelines on how to maximize the performance of your virtual machine. Here’s what I adopted:
Virtual machine settings:
- 2 virtual CPUs
- 4096MB system memory
- 256MB graphics memory
- Optimization: Faster virtual machine, Adaptive hypervisor, Tune Windows for speed all turned on.
- Sharing: Shared cloud, SmartMount, and Access Windows folders from Mac turned off, as I didn’t need these for my workflow.
I experimented with both of Parallels’ presentation modes, Coherence and Full Screen. While it was cool to see my Windows apps side-by-side with OS X in Coherence mode, I found that the UI responsiveness (especially opening and closing windows and dialogs) felt sluggish.
Because of this, I use Full Screen exclusively now. I have Windows full-screen on my external Thunderbolt display, and OS X on my laptop. If I need to use OS X on my large monitor, I can swipe the Magic Mouse to switch desktops.
Adjusting OS X and Windows Features
I fixed a few annoyances and performance drains right off the bat:
- Function keys. If you’re using the Mac keyboard, you’ll want to change the function key behavior so the F1-F12 keys work correctly in Visual Studio. From System Preferences – Keyboard, make sure Use all F1, F2, etc. keys as standard function keys is checked. With this turned on, hold Fn to use the Mac functions (brightness, volume, etc.) on F1-F12. With an external non-Mac keyboard, this isn’t an issue.
Start menu. I’m using Windows 8, and the removal of the Start menu annoyed me. I clung to my old ways and installed Start8 to restore it.
Disable Windows visual effects. I turned off most of the Windows desktop manager visual effects by going to Control Panel – System and Security – Advanced system settings – Advanced – Performance – Settings – Visual Effects and choosing Adjust for best performance. However, I left Smooth edges of screen fonts checked because it improves text rendering on my monitor.
Installing Visual Studio and Helpful Extensions
Windows Form Application Visual Studio 2019
Installing Visual Studio is a piece of cake once the virtual machine is set up. I simply downloaded the latest release from MSDN and let the installer run.
If you use an Apple Magic Mouse (as I do), Visual Studio tends to be overly eager to zoom the text size in and out as you swipe your finger over the mouse. The Disable Mouse Wheel Zoom add-on fixes this annoyance.
Improving Visual Studio for Performance
I was impressed with how well Visual Studio performed under emulation. With a large multi-project solution open, though, I saw some slowdowns.
Through trial and error, I found a number of things that could be disabled to improve performance. You may not want to make all of the changes I did, so pick and choose your own list of tweaks:
- Disable hardware-accelerated rendering. Unchecking Automatically adjust visual experience based on client performance, Enable rich client visual experience, and Use hardware graphics acceleration if available via Options – Environment made the UI feel much more responsive on my machine.
Start up to an empty environment. Starting up Visual Studio for the first time feels a lot snappier if you skip the default news page on startup. Select Empty environment under Options – Environment – Startup – At startup.
Remove unused extensions. Visual Studio ships with a number of extensions that you may not need. From Tools – Extensions and Updates – Installed, remove any extensions you aren’t actively using (you can always reinstall them later). I got rid of six extensions I didn’t need.
Disable extra debugging features. I turned off both Enable Diagnostic Tools while debugging and Show elapsed time PerfTip while debugging in Options – Debugging – General. I wasn’t using these debugging features, and debugging felt snappier after I disabled them.
Turn off the Navigation Bar. I found the code editor Navigation Bar to be unnecessary if the Solution Explorer is open. I disabled it via Options – Text Editor – All Languages – Navigation Bar.
Disable CodeLens. CodeLens is a cool feature for collaboration, but it’s not part of my current workflow. I got rid of the CPU overhead by turning it off via Options – Text Editor – All
Languages – CodeLens – Enable CodeLens.
Turn off Track Changes. When a file is open in the code editor, Visual Studio will represent recent changes by displaying small regions of green or yellow on the scroll bar. If you can live without this, turn off Track changes via Options – Text Editor – General for a small performance boost.
Turn off Track Active Item. Squeeze out a little bit more UI performance out by ensuring Track Active Item in Solution Explorer is unchecked under Options – Projects and Solutions – General.
Visual Studio on a Mac: The Best of Both Worlds
With these tweaks, I’ve come to love using Visual Studio on a Mac. The performance is good, and by running Windows in a virtual machine, I get the best of both OS worlds.
Want to see what I’m building with this setup? Check out our open-source .NET SDK on Github.
Do you have any other tricks you’ve used to improve Visual Studio performance? Any must-have add-ons that boost your productivity? Leave me a comment below!-->
This article describes how to port your Windows Forms-based desktop app from .NET Framework to .NET Core 3.0 or later. The .NET Core 3.0 SDK includes support for Windows Forms applications. Windows Forms is still a Windows-only framework and only runs on Windows. This example uses the .NET Core SDK CLI to create and manage your project.
In this article, various names are used to identify types of files used for migration. When migrating your project, your files will be named differently, so mentally match them to the ones listed below:
|MyApps.sln||The name of the solution file.|
|MyForms.csproj||The name of the .NET Framework Windows Forms project to port.|
|MyFormsCore.csproj||The name of the new .NET Core project you create.|
|MyAppCore.exe||The .NET Core Windows Forms app executable.|
Visual Studio 2019 16.5 Preview 1 or later for any designer work you want to do. We recommend to update to the latest Preview version of Visual Studio.
Install the following Visual Studio workloads:
- .NET desktop development
- .NET Core cross-platform development
A working Windows Forms project in a solution that builds and runs without issue.
A project coded in C#.
.NET Core 3.0 projects are only supported in Visual Studio 2019 or a later version. Starting with Visual Studio 2019 version 16.5 Preview 1, the .NET Core Windows Forms designer is also supported.
To enable the designer, go to Tools > Options > Environment > Preview Features and select the Use the preview Windows Forms designer for .NET Core apps option.
When porting a .NET Framework Windows Forms application, there are a few things you must consider.
Check that your application is a good candidate for migration.
Use the .NET Portability Analyzer to determine if your project will migrate to .NET Core 3.0. If your project has issues with .NET Core 3.0, the analyzer helps you identify those problems.
You're using a different version of Windows Forms.
When .NET Core 3.0 Preview 1 was released, Windows Forms went open source on GitHub. The code for .NET Core Windows Forms is a fork of the .NET Framework Windows Forms codebase. It's possible some differences exist and your app won't port.
The Windows Compatibility Pack may help you migrate.
Some APIs that are available in .NET Framework aren't available in .NET Core 3.0. The Windows Compatibility Pack adds many of these APIs and may help your Windows Forms app become compatible with .NET Core.
Update the NuGet packages used by your project.
It's always a good practice to use the latest versions of NuGet packages before any migration. If your application is referencing any NuGet packages, update them to the latest version. Ensure your application builds successfully. After upgrading, if there are any package errors, downgrade the package to the latest version that doesn't break your code.
Create a new SDK project
The new .NET Core 3.0 project you create must be in a different directory from your .NET Framework project. If they're both in the same directory, you may run into conflicts with the files that are generated in the obj directory. In this example, we'll create a directory named MyFormsAppCore in the SolutionFolder directory:
Next, you need to create the MyFormsCore.csproj project in the MyFormsAppCore directory. You can create this file manually by using the text editor of choice. Paste in the following XML:
If you don't want to create the project file manually, you can use Visual Studio or the .NET Core SDK to generate the project. However, you must delete all other files generated by the project template except for the project file. To use the SDK, run the following command from the SolutionFolder directory:
After you create the MyFormsCore.csproj, your directory structure should look like the following:
Add the MyFormsCore.csproj project to MyApps.sln with either Visual Studio or the .NET Core CLI from the SolutionFolder directory:
Fix assembly info generation
Windows Forms projects that were created with .NET Framework include an
AssemblyInfo.cs file, which contains assembly attributes such as the version of the assembly to be generated. SDK-style projects automatically generate this information for you based on the SDK project file. Having both types of 'assembly info' creates a conflict. Resolve this problem by disabling automatic generation, which forces the project to use your existing
There are three settings to add to the main
When you set this property to
false, it won't generate the assembly attributes. This avoids the conflict with the existing
AssemblyInfo.csfile from the .NET Framework project.
The value of this property is the output binary created when you compile. The name doesn't need an extension added to it. For example, using
The default namespace used by your project. This should match the default namespace of the .NET Framework project.
Add these three elements to the
<PropertyGroup> node in the
Visual Studio Winforms Controls
Add source code
Right now, the MyFormsCore.csproj project doesn't compile any code. By default, .NET Core projects automatically include all source code in the current directory and any child directories. You must configure the project to include code from the .NET Framework project using a relative path. If your .NET Framework project used .resx files for icons and resources for your forms, you'll need to include those too.
Add the following
<ItemGroup> node to your project. Each statement includes a file glob pattern that includes child directories.
Alternatively, you can create a
<EmbeddedResource> entry for each file in your .NET Framework project.
Add NuGet packages
Add each NuGet package referenced by the .NET Framework project to the .NET Core project.
Visual Studio Mac Windows Forms
Most likely your .NET Framework Windows Forms app has a packages.config file that contains a list of all of the NuGet packages that are referenced by your project. You can look at this list to determine which NuGet packages to add to the .NET Core project. For example, if the .NET Framework project referenced the
MetroFramework.Fonts NuGet packages, add each to the project with either Visual Studio or the .NET Core CLI from the SolutionFolder directory:
The previous commands would add the following NuGet references to the MyFormsCore.csproj project:
Port control libraries
If you have a Windows Forms Controls library project to port, the directions are the same as porting a .NET Framework Windows Forms app project, except for a few settings. And instead of compiling to an executable, you compile to a library. The difference between the executable project and the library project, besides paths for the file globs that include your source code, is minimal.
Using the previous step's example, lets expand what projects and files we're working with.
|MyApps.sln||The name of the solution file.|
|MyControls.csproj||The name of the .NET Framework Windows Forms Controls project to port.|
|MyControlsCore.csproj||The name of the new .NET Core library project you create.|
|MyCoreControls.dll||The .NET Core Windows Forms Controls library.|
Consider the differences between the
MyControlsCore.csproj project and the previously created
Here is an example of what the .NET Core Windows Forms Controls library project file would look like:
As you can see, the
<OutputType> node was removed, which defaults the compiler to produce a library instead of an executable. The
<RootNamespace> were changed. Specifically the
<RootNamespace> should match the namespace of the Windows Forms Controls library you are porting. And finally, the
<EmbeddedResource> nodes were adjusted to point to the folder of the Windows Forms Controls library you are porting.
Next, in the main .NET Core MyFormsCore.csproj project, add a reference to the new .NET Core Windows Forms Control library. Add a reference with either Visual Studio or the .NET Core CLI from the SolutionFolder directory:
The previous command adds the following to the MyFormsCore.csproj project:
If you have problems compiling your projects, you may be using some Windows-only APIs that are available in .NET Framework but not available in .NET Core. You can try adding the Windows Compatibility Pack NuGet package to your project. This package only runs on Windows and adds about 20,000 Windows APIs to .NET Core and .NET Standard projects.
The previous command adds the following to the MyFormsCore.csproj project:
Windows Form Application Visual Studio
Windows Forms Designer
Winform App On Mac Using Visual Studio Windows 10
As detailed in this article, Visual Studio 2019 only supports the Forms Designer in .NET Framework projects. By creating a side-by-side .NET Core project, you can test your project with .NET Core while you use the .NET Framework project to design forms. Your solution file includes both the .NET Framework and .NET Core projects. Add and design your forms and controls in the .NET Framework project, and based on the file glob patterns we added to the .NET Core projects, any new or changed files will automatically be included in the .NET Core projects.
Once Visual Studio 2019 supports the Windows Forms Designer, you can copy/paste the content of your .NET Core project file into the .NET Framework project file. Then delete the file glob patterns added with the
<EmbeddedResource> items. Fix the paths to any project reference used by your app. This effectively upgrades the .NET Framework project to a .NET Core project.
Winform App On Mac Using Visual Studios
- Learn about breaking changes from .NET Framework to .NET Core.
- Read more about the Windows Compatibility Pack.
- Watch a video on porting your .NET Framework Windows Forms project to .NET Core.