dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.45k stars 4.76k forks source link

System.Diagnostics.Process.CreateProcessInfo Platform not supported error in net8.0-ios #94903

Open rolfbjarne opened 1 year ago

rolfbjarne commented 1 year ago

From @last-Programmer on Thu, 16 Nov 2023 23:40:15 GMT

Steps to Reproduce

  1. Create a native .net8.0 ios project and install Oracle.ManagedDataAccess.Core version 2.19.60 and try to create an instance of OracleConnectionStringBuilder or OracleConnection and run the project
  2. Creeate Xamarin.IOS project and repeat the previous steps

Expected Behavior

OracleConnectionSrtingBuilder and OrcaleConnection should be instantiated without error in xamarin ios project and .net8 ios project.

Actual Behavior

In .net8 ios project i get the error Platform not supported In Xmarin Ios project there is no error

Environment

Version information ``` Visual Studio Enterprise 2022 for Mac Version 17.6.7 (build 417) Installation UUID: b7c0b5ca-2bfe-4415-a452-68f6af6b9f1a Runtime .NET 7.0.3 (64-bit) Architecture: X64 Microsoft.macOS.Sdk 13.1.1007; git-rev-head:8afca776a0a96613dfb7200e0917bb57f9ed5583; git-branch:release/7.0.1xx-xcode14.2 Roslyn (Language Service) 4.6.0-3.23180.6+99e956e42697a6dd886d1e12478ea2b27cceacfa NuGet Version: 6.4.0.117 .NET SDK (x64) SDK: /usr/local/share/dotnet/sdk/8.0.100/Sdks SDK Versions: 8.0.100 7.0.311 7.0.310 7.0.308 7.0.304 6.0.417 6.0.416 6.0.414 6.0.410 MSBuild SDKs: /Applications/Visual Studio.app/Contents/MonoBundle/MSBuild/Current/bin/Sdks .NET Runtime (x64) Runtime: /usr/local/share/dotnet/dotnet Runtime Versions: 8.0.0 7.0.14 7.0.13 7.0.11 7.0.7 6.0.25 6.0.24 6.0.22 6.0.18 Xamarin.Profiler Version: 1.8.0.49 Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler Updater Version: 11 Apple Developer Tools Xcode: 15.0.1 22266 Build: 15A507 Xamarin.Mac Version: 9.3.0.23 Visual Studio Enterprise Hash: 9defd91b3 Branch: xcode14.3 Build date: 2023-10-23 16:14:59-0400 Xamarin.iOS Version: 16.4.0.23 Visual Studio Enterprise Hash: 9defd91b3 Branch: xcode14.3 Build date: 2023-10-23 16:15:00-0400 Xamarin Designer Version: 17.6.3.9 Hash: 2648399ae8 Branch: remotes/origin/d17-6 Build date: 2023-11-10 12:19:21 UTC Xamarin.Android Version: 13.2.2.0 (Visual Studio Enterprise) Commit: xamarin-android/d17-5/45b0e14 Android SDK: /Users/balu/Library/Developer/Xamarin/android-sdk-macosx Supported Android versions: 13.0 (API level 33) SDK Command-line Tools Version: 7.0 SDK Platform Tools Version: 34.0.3 SDK Build Tools Version: 32.0.0 Build Information: Mono: d9a6e87 Java.Interop: xamarin/java.interop/d17-5@149d70fe SQLite: xamarin/sqlite/3.40.1@68c69d8 Xamarin.Android Tools: xamarin/xamarin-android-tools/d17-5@ca1552d Microsoft Build of OpenJDK Java SDK: /Library/Java/JavaVirtualMachines/microsoft-11.jdk 11.0.16.1 Android Designer EPL code available here: https://github.com/xamarin/AndroidDesigner.EPL Eclipse Temurin JDK Java SDK: /Library/Java/JavaVirtualMachines/temurin-8.jdk 1.8.0.302 Android Designer EPL code available here: https://github.com/xamarin/AndroidDesigner.EPL Android SDK Manager Version: 17.6.0.50 Hash: a715dca Branch: HEAD Build date: 2023-11-10 12:19:27 UTC Android Device Manager Version: 0.0.0.1309 Hash: 06e3e77 Branch: HEAD Build date: 2023-11-10 12:19:27 UTC Build Information Release ID: 1706070417 Git revision: 179aa48a5702754e41a8218d0403ddc3be46706f Build date: 2023-11-10 12:17:47+00 Build branch: release-17.6 Build lane: release-17.6 Operating System Mac OS X 14.1.1 Darwin 23.1.0 Darwin Kernel Version 23.1.0 Mon Oct 9 21:27:27 PDT 2023 root:xnu-10002.41.9~6/RELEASE_X86_64 x86_64 ```

Build Logs

Example Project (If Possible)

XamarinOracle.zip

Copied from original issue xamarin/xamarin-macios#19471

rolfbjarne commented 1 year ago

From @rolfbjarne on Fri, 17 Nov 2023 09:53:44 GMT

I can reproduce with:

Console.WriteLine (System.Diagnostics.Process.GetCurrentProcess ().ProcessName);

resulting in:

System.PlatformNotSupportedException Operation is not supported on this platform. (System.PlatformNotSupportedException)
   at System.Diagnostics.ProcessManager.GetProcessInfo(Int32 processId, String machineName)
   at System.Diagnostics.Process.EnsureState(State state)
   at System.Diagnostics.Process.get_ProcessName()
   at ios_plain.AppDelegate.FinishedLaunching(UIApplication application, NSDictionary launchOptions) in /Users/rolf/test/dotnet/ios-plain/AppDelegate.cs:line 28

Note that Process.ProcessName isn't marked as unsupported on any platform: https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.process.processname?view=net-7.0

ghost commented 1 year ago

Tagging subscribers to this area: @dotnet/area-system-diagnostics-process See info in area-owners.md if you want to be subscribed.

Issue Details
_From @last-Programmer on Thu, 16 Nov 2023 23:40:15 GMT_ ### Steps to Reproduce 1. Create a native .net8.0 ios project and install Oracle.ManagedDataAccess.Core version 2.19.60 and try to create an instance of OracleConnectionStringBuilder or OracleConnection and run the project 2. Creeate Xamarin.IOS project and repeat the previous steps ### Expected Behavior OracleConnectionSrtingBuilder and OrcaleConnection should be instantiated without error in xamarin ios project and .net8 ios project. ### Actual Behavior In .net8 ios project i get the error Platform not supported In Xmarin Ios project there is no error ### Environment
Version information ``` Visual Studio Enterprise 2022 for Mac Version 17.6.7 (build 417) Installation UUID: b7c0b5ca-2bfe-4415-a452-68f6af6b9f1a Runtime .NET 7.0.3 (64-bit) Architecture: X64 Microsoft.macOS.Sdk 13.1.1007; git-rev-head:8afca776a0a96613dfb7200e0917bb57f9ed5583; git-branch:release/7.0.1xx-xcode14.2 Roslyn (Language Service) 4.6.0-3.23180.6+99e956e42697a6dd886d1e12478ea2b27cceacfa NuGet Version: 6.4.0.117 .NET SDK (x64) SDK: /usr/local/share/dotnet/sdk/8.0.100/Sdks SDK Versions: 8.0.100 7.0.311 7.0.310 7.0.308 7.0.304 6.0.417 6.0.416 6.0.414 6.0.410 MSBuild SDKs: /Applications/Visual Studio.app/Contents/MonoBundle/MSBuild/Current/bin/Sdks .NET Runtime (x64) Runtime: /usr/local/share/dotnet/dotnet Runtime Versions: 8.0.0 7.0.14 7.0.13 7.0.11 7.0.7 6.0.25 6.0.24 6.0.22 6.0.18 Xamarin.Profiler Version: 1.8.0.49 Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler Updater Version: 11 Apple Developer Tools Xcode: 15.0.1 22266 Build: 15A507 Xamarin.Mac Version: 9.3.0.23 Visual Studio Enterprise Hash: 9defd91b3 Branch: xcode14.3 Build date: 2023-10-23 16:14:59-0400 Xamarin.iOS Version: 16.4.0.23 Visual Studio Enterprise Hash: 9defd91b3 Branch: xcode14.3 Build date: 2023-10-23 16:15:00-0400 Xamarin Designer Version: 17.6.3.9 Hash: 2648399ae8 Branch: remotes/origin/d17-6 Build date: 2023-11-10 12:19:21 UTC Xamarin.Android Version: 13.2.2.0 (Visual Studio Enterprise) Commit: xamarin-android/d17-5/45b0e14 Android SDK: /Users/balu/Library/Developer/Xamarin/android-sdk-macosx Supported Android versions: 13.0 (API level 33) SDK Command-line Tools Version: 7.0 SDK Platform Tools Version: 34.0.3 SDK Build Tools Version: 32.0.0 Build Information: Mono: d9a6e87 Java.Interop: xamarin/java.interop/d17-5@149d70fe SQLite: xamarin/sqlite/3.40.1@68c69d8 Xamarin.Android Tools: xamarin/xamarin-android-tools/d17-5@ca1552d Microsoft Build of OpenJDK Java SDK: /Library/Java/JavaVirtualMachines/microsoft-11.jdk 11.0.16.1 Android Designer EPL code available here: https://github.com/xamarin/AndroidDesigner.EPL Eclipse Temurin JDK Java SDK: /Library/Java/JavaVirtualMachines/temurin-8.jdk 1.8.0.302 Android Designer EPL code available here: https://github.com/xamarin/AndroidDesigner.EPL Android SDK Manager Version: 17.6.0.50 Hash: a715dca Branch: HEAD Build date: 2023-11-10 12:19:27 UTC Android Device Manager Version: 0.0.0.1309 Hash: 06e3e77 Branch: HEAD Build date: 2023-11-10 12:19:27 UTC Build Information Release ID: 1706070417 Git revision: 179aa48a5702754e41a8218d0403ddc3be46706f Build date: 2023-11-10 12:17:47+00 Build branch: release-17.6 Build lane: release-17.6 Operating System Mac OS X 14.1.1 Darwin 23.1.0 Darwin Kernel Version 23.1.0 Mon Oct 9 21:27:27 PDT 2023 root:xnu-10002.41.9~6/RELEASE_X86_64 x86_64 ```
### Build Logs ### Example Project (If Possible) [XamarinOracle.zip](https://github.com/xamarin/xamarin-macios/files/13385217/XamarinOracle.zip) _Copied from original issue xamarin/xamarin-macios#19471_
Author: rolfbjarne
Assignees: -
Labels: `area-System.Diagnostics.Process`, `untriaged`, `os-ios`
Milestone: -
last-Programmer commented 2 months ago

Any update on this?

MartinRobins commented 1 month ago

Is System.Diagnostics.Process.GetCurrentProcess().ProcessName required when you can achieve the same result using Assembly.GetEntryAssembly().FullName?