Я перепробовал все поисковые предложения, но безуспешно.
Это мой код, чтобы определить, является ли Winforms или браузером:
Код: Выделить всё
public static class EnvironmentHelper
{
public static bool IsWeb => System.Web.HttpContext.Current != null;
public static bool IsWinForms => !IsWeb;
}
Код: Выделить всё
if (EnvironmentHelper.IsWinForms)
{
Response.Write("Loaded on Windows Form App");
}
Это мой код приложения WinForm
MainPage.xaml
Код: Выделить всё
Код: Выделить всё
public partial class MainPage : ContentPage{
public MainPage()
{
InitializeComponent();
//- The WebUrl is not real just to give you a sample what I am doing
//- The WebUrl is WebForm built ASP.NET C# Framework 8.0, it is not a .NET Core just in case you ask.
//- In the Webform Project I am checking whether the access is a WinForm App or the Browser using the EnvironmentHelper.IsWinForms
//- if (EnvironmentHelper.IsWinForms) {Response.Write("Loading the WebForm Project in Windows Form App";}
//- else {Response.Write("Loading on the Browser(Edge, Chrome, FireFox, etc.";}
Browser.Source = "https://testmywebformpage.com";
}
Спасибо
Подробнее здесь: https://stackoverflow.com/questions/798 ... or-winform
Мобильная версия