2

I'm working on an existing solution at work that was written in C# targeting .NET Framework 4 in Visual Studio 2019 for Windows. I'm attempting to open the project on my MacBook Pro (running Catalina 10.15.6 if that's relevant) in Visual Studio Mac 2019 Community (Version 8.7.7 Build 10) so I can keep working on this remotely.

I'm noticing that a usage of System.Windows.Media isn't being found. My understanding is that this relies on PresentationCore, which I believe is included in .NET Framework 4. Sure enough, in the project's References, PresentationCore has a red "x" next, with alt text telling me "Assembly not found for framework .NET Framework 4".

Is there any way to add this? Is this just something not supported in macOS? I'm happy to provide any additional information.

Kusal Dissanayake
  • 714
  • 14
  • 32
  • I didn't think you could run .Net Framework code on a Mac (or through Visual Studio for Mac). I thought it was only .Net Core stuff. – gunr2171 Sep 18 '20 at 20:08
  • I'm honestly not sure - I'm able to create a new solution and select from several versions of .Net Framework as a target framework. If you're correct, I can run the project in a virtual machine. But, I'd prefer to figure this out. – Patrick Willmann Sep 18 '20 at 20:23
  • You can run virtual machine with Windows under MacOS. – Lukasz Szczygielek Sep 18 '20 at 23:44

2 Answers2

3

You are trying to run a WPF application, which targets .Net Framework (4), on MacOS.

MacOS doesn't support WPF, or any version of .Net Framework, as .Net Framework is Windows-dependent1.

https://visualstudio.microsoft.com/vs/mac/

Image source: https://visualstudio.microsoft.com/vs/mac/

.Net Core is supported - that's the cross-platform version of .Net, which works on Windows, Mac, and Linux.

You'll need to do a migration to make it work with Core. Of course, this still won't allow you use to run WPF on a Mac, you'd need to use another cross-platform supported UI framework.

1 Of course, Mono is the open-source version of .Net Framework that runs on Mac and Linux, so you can also try that as an option if you're feeling adventurous or can't migrate to Core.

See also: Can you install and run apps built on the .NET framework on a Mac?

gunr2171
  • 16,104
  • 25
  • 61
  • 88
  • That's cut and dry - thanks for tracking that down for me. Migration isn't an option, so I may give Mono a try. – Patrick Willmann Sep 18 '20 at 21:32
  • 1
    It's only a partially correct answer (no WPF nor .NET Framework on macOS). Migrating to Mono or .NET Core won't magically bring WPF to macOS or Linux. The complete solution is to use a cross platform framework instead of WPF (and I [blogged about that](https://blog.lextudio.com/the-story-about-net-cross-platform-ui-frameworks-dd4a9433d0ea)). – Lex Li Jul 13 '21 at 19:42
0

Gunr2171 is correct; but you could also look at running a virtual box on your Mac for a windows environment then use VS Code.

For a VM I recommend

https://www.virtualbox.org/wiki/Mac%20OS%20X%20build%20instructions

Then Windows 10 OS: https://www.microsoft.com/en-ca/software-download/windows10ISO

Just an idea if Mono doesn't work for you.

Brian Dunk
  • 63
  • 7