dotnet / MobileBlazorBindings

Experimental Mobile Blazor Bindings - Build native and hybrid mobile apps with Blazor
MIT License
1.2k stars 151 forks source link

uwp project missing #41

Open vscodewinodws opened 4 years ago

vscodewinodws commented 4 years ago

by generating project described in blog https://devblogs.microsoft.com/aspnet/mobile-blazor-bindings-experiment/

creates android and ios project missing uwp projects , why hate for windows from Microsoft ? we need UWP app along side with this projects.

Eilon commented 4 years ago

It wasn't added mostly due to time constraints. You should be able to manually add a UWP project by creating one as part of a Xamarin.Forms project, but pointing it at your shared UI project with Mobile Blazor Bindings. We will look into adding a UWP template here as well.

Eilon commented 4 years ago

Also please note that we've never tried it, so if you do try it, please let us know if it works or if you ran into any issues.

Knudel commented 4 years ago

I don't know if I am doing it right, but I get an exception:

System.PlatformNotSupportedException: 'EventLog access is not supported on this platform.'

On the line:

 var host = Host.CreateDefaultBuilder()
            .ConfigureServices((hostContext, services) =>
            {
                // Register app-specific services
                //services.AddSingleton<AppState>();
            })
            .Build();
Eilon commented 4 years ago

Oh darn. Generic Host has a few default things that don't seem to be working on iOS or UWP. I will investigate and get an answer.

@tratcher / @glennc - do you know how I can use Generic Host, but disable certain default things, such as EventLog, file watchers for config changes, etc.?

This is how Generic Host is used in the templates:

https://github.com/xamarin/MobileBlazorBindings/blob/master/templates/MobileBlazorBindings-app/NewApp/App.cs#L12-L18

Tratcher commented 4 years ago

@Knudel what's the stack trace for that exception?

@Eilon I expect you'll need to move from Host.CreateDefaultBuilder() to new HostBuilder() and/or provide your own platform defaults.

Knudel commented 4 years ago

@Tratcher new HostBuilder() did the trick, thank you.

UWP is working..

(Do you still need the stack trace?)

This exception was originally thrown at this call stack:
    System.Diagnostics.EventLog.EventLog(string, string, string)
    Microsoft.Extensions.Logging.EventLog.EventLogSettings.CreateDefaultEventLog()
    Microsoft.Extensions.Logging.EventLog.EventLogSettings.EventLog.get()
    Microsoft.Extensions.Logging.EventLog.EventLogLogger.EventLogLogger(string, Microsoft.Extensions.Logging.EventLog.EventLogSettings, Microsoft.Extensions.Logging.IExternalScopeProvider)
    Microsoft.Extensions.Logging.EventLog.EventLogLoggerProvider.CreateLogger(string)
    Microsoft.Extensions.Logging.LoggerFactory.CreateLoggers(string)
    Microsoft.Extensions.Logging.LoggerFactory.CreateLogger(string)
    System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(Microsoft.Extensions.DependencyInjection.ServiceLookup.ConstructorCallSite, Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeResolverContext)
Tratcher commented 4 years ago

Ah, there's an isWindows check, but that's not good enough for UWP. https://github.com/dotnet/extensions/blob/dea81ef6ca214e023f918ac32c2d9e9facf13672/src/Hosting/Hosting/src/Host.cs#L110-L114

Feel free to file an issue on that.

vscodewinodws commented 4 years ago

there should be proper documentation how to do add uwp support in MobileBlazorBindings . there is well documented docs for xamarin forms in case uwp needs to be added later and earlier was not selected for creation , i tried to take that reference and failed seems there is difference between this and xamarin forms xaml page app

Eilon commented 4 years ago

@vscodewinodws I'm keeping this issue to track proper UWP support.

jamesmontemagno commented 4 years ago

@Eilon can look at how I do it: https://montemagno.com/add-asp-net-cores-dependency-injection-into-xamarin-apps-with-hostbuilder/

vscodewinodws commented 4 years ago

@jamesmontemagno I gone through your link I am familiar with asp.net core and Xamarin still I am not able to closely relate it how it will solve my problem I still think there should be step by step documentation which will help all developer like we have for Xamarin forms

AutumnEvans418 commented 4 years ago

Another option is to remove the EventLog source like so in the webhost builder

.ConfigureLogging(d =>
                {
                    d.ClearProviders();
                    d.AddConsole();
                })
freever commented 4 years ago

@chrisevans9629 that works on UWP and Android but throws PlatformNotSupported on iOS :)

freever commented 4 years ago

var host = new HostBuilder() works on UWP and iOS, but not Android

freever commented 4 years ago

So it looks like there's a MobileBlazorBindingsHost that works.

@Eilon I have added a UWP project for the Hello World sample, do you want a PR? I could take a stab at the other samples too.

AutumnEvans418 commented 4 years ago

@freever I made a pull request for a UWP todo list sample awhile back. I need to update it to use the mobileblazorbindingsHost though: https://github.com/xamarin/MobileBlazorBindings/pull/62

Eilon commented 4 years ago

Thank you I will take a look! BTW sorry things have been a bit slow. I'm home with 2 kids full time due to virus lockdown and daycare not available. But I assure you that I spent what previous little time I have on Mobile Blazor Bindings!

brunoprietog commented 3 years ago

Hi! I am delighted with this. Is there any news?