System.PlatformNotSupportedException

About programming and getting involved with Linux Mint development
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Locked
Grigori Rasputin
Level 1
Level 1
Posts: 7
Joined: Tue Aug 23, 2022 2:56 pm

System.PlatformNotSupportedException

Post by Grigori Rasputin »

Hi, guys. I'm a beginner coder. I started learning C# some months ago. I use Linux Mint 21 and Visual Studio Code.
The thing is that when coding a console app I tried to use this line
Console.SetWindowSize(100, 50);
but I got this compiling error
Unhandled exception. System.PlatformNotSupportedException: Operation is not supported on this platform.
.
What is the problem here? What should I do to fix it?
Last edited by LockBot on Sun Feb 26, 2023 11:00 pm, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
spamegg
Level 14
Level 14
Posts: 5047
Joined: Mon Oct 28, 2019 2:34 am
Contact:

Re: System.PlatformNotSupportedException

Post by spamegg »

I believe C# requires Visual Studio and the .NET platform. Until recently this was available only on Windows and not possible on Linux. But recently Ubuntu and Microsoft made a deal to get .NET working on Ubuntu: https://ubuntu.com//blog/install-dotnet-on-ubuntu
deepakdeshp
Level 20
Level 20
Posts: 12337
Joined: Sun Aug 09, 2015 10:00 am

Re: System.PlatformNotSupportedException

Post by deepakdeshp »

spamegg wrote: Sat Aug 27, 2022 2:31 am I believe C# requires Visual Studio and the .NET platform. Until recently this was available only on Windows and not possible on Linux. But recently Ubuntu and Microsoft made a deal to get .NET working on Ubuntu: https://ubuntu.com//blog/install-dotnet-on-ubuntu
I tried dotnet on Mint and basic web application runs on dotnet.
If I have helped you solve a problem, please add [SOLVED] to your first post title, it helps other users looking for help.
Regards,
Deepak

Mint 21.1 Cinnamon 64 bit with AMD A6 / 8GB
Mint 21.1 Cinnamon AMD Ryzen3500U/8gb
cfb
Level 3
Level 3
Posts: 153
Joined: Sun Nov 08, 2015 3:36 am

Re: System.PlatformNotSupportedException

Post by cfb »

I guess that you are simply trying to use a function that is unavailable on the current platform, in this case Linux.
.NET is a cross-platform product and as such restricted by what the current OS provides. It might work if you tried to run the same code on Windows or macOS. On the other hand, you could possibly find a function that would only work on Linux.

By the way:
.NET (previously .NET Core) has been available for Linux for a number of years and has been provided as a separate package.
See https://en.wikipedia.org/wiki/.NET.
deepakdeshp
Level 20
Level 20
Posts: 12337
Joined: Sun Aug 09, 2015 10:00 am

Re: System.PlatformNotSupportedException

Post by deepakdeshp »

Recently dotnet 6 has been fully ported to Ubuntu and Mint.
If I have helped you solve a problem, please add [SOLVED] to your first post title, it helps other users looking for help.
Regards,
Deepak

Mint 21.1 Cinnamon 64 bit with AMD A6 / 8GB
Mint 21.1 Cinnamon AMD Ryzen3500U/8gb
Grigori Rasputin
Level 1
Level 1
Posts: 7
Joined: Tue Aug 23, 2022 2:56 pm

Re: System.PlatformNotSupportedException

Post by Grigori Rasputin »

spamegg wrote: Sat Aug 27, 2022 2:31 am I believe C# requires Visual Studio and the .NET platform. Until recently this was available only on Windows and not possible on Linux. But recently Ubuntu and Microsoft made a deal to get .NET working on Ubuntu: https://ubuntu.com//blog/install-dotnet-on-ubuntu
Hi.
I have installed the latest version of dotnet and it works fine (otherwise I guess I couldn't compile my vscode C# code.
Yet it doesn't seem to solve my issue :cry:
Grigori Rasputin
Level 1
Level 1
Posts: 7
Joined: Tue Aug 23, 2022 2:56 pm

Re: System.PlatformNotSupportedException

Post by Grigori Rasputin »

cfb wrote: Sat Aug 27, 2022 6:49 am I guess that you are simply trying to use a function that is unavailable on the current platform, in this case Linux.
.NET is a cross-platform product and as such restricted by what the current OS provides. It might work if you tried to run the same code on Windows or macOS. On the other hand, you could possibly find a function that would only work on Linux.

By the way:
.NET (previously .NET Core) has been available for Linux for a number of years and has been provided as a separate package.
See https://en.wikipedia.org/wiki/.NET.

Thanks for your reply. I'll read the article.
Btw, if it is a OS-related issue, do you think that coding on a multiplatform programming language such as Java would solve the problem?
deepakdeshp
Level 20
Level 20
Posts: 12337
Joined: Sun Aug 09, 2015 10:00 am

Re: System.PlatformNotSupportedException

Post by deepakdeshp »

https://docs.microsoft.com/en-us/dotnet/fundamentals/

The documentation. I feel all the features in dotnet 6 do work on Mint.
If I have helped you solve a problem, please add [SOLVED] to your first post title, it helps other users looking for help.
Regards,
Deepak

Mint 21.1 Cinnamon 64 bit with AMD A6 / 8GB
Mint 21.1 Cinnamon AMD Ryzen3500U/8gb
cfb
Level 3
Level 3
Posts: 153
Joined: Sun Nov 08, 2015 3:36 am

Re: System.PlatformNotSupportedException

Post by cfb »

Look at this page: https://docs.microsoft.com/en-us/dotnet ... ew=net-6.0
It clearly says that you will get exception PlatformNotSupportedException if the platform is NOT Windows.
Grigori Rasputin
Level 1
Level 1
Posts: 7
Joined: Tue Aug 23, 2022 2:56 pm

Re: System.PlatformNotSupportedException

Post by Grigori Rasputin »

cfb wrote: Sun Aug 28, 2022 1:28 am Look at this page: https://docs.microsoft.com/en-us/dotnet ... ew=net-6.0
It clearly says that you will get exception PlatformNotSupportedException if the platform is NOT Windows.
Thank you very much !
Locked

Return to “Programming & Development”