tryphotino / photino.Blazor

https://tryphotino.io
Apache License 2.0
332 stars 62 forks source link

After updating from 1.* to 2.* and dotnet 6 I just get a white screen #45

Closed grofit closed 2 years ago

grofit commented 2 years ago

I had a working setup in 1.x with:

class Program
{
    [STAThread]
    static void Main(string[] args)
    {
        ComponentsDesktop.Run<Startup>("Foo", "./wwwroot/index.html", false, 0, 0, 1920, 1080);
    }
}

public class Startup
{
    public void ConfigureServices(IServiceCollection services)
    { }

    public void Configure(DesktopApplicationBuilder app)
    {
        app.AddComponent<App>("app");
    }
}

I moved over to 2.* and mapped over to the calls and merged the startup into the main phase as shown below:

var appBuilder = PhotinoBlazorAppBuilder.CreateDefault(args);

appBuilder.Services.AddLogging();
appBuilder.RootComponents.Add<App>("app");

var app = appBuilder.Build();
AppDomain.CurrentDomain.UnhandledException += (sender, error) =>
    { app.MainWindow.OpenAlertWindow("Fatal exception", error.ExceptionObject.ToString()); };

app.MainWindow.Load("./wwwroot/index.html");
app.Run();

I can see on the output I get:

Photino.NET: "Photino".SetTitle(Photino.Blazor App)
Photino.NET: "Photino.Blazor App".SetWidth(1000)
Photino.NET: "Photino.Blazor App".SetHeight(900)
Photino.NET: "Photino.Blazor App".SetLeft(0)
Photino.NET: "Photino.Blazor App".SetTop(100)
Photino.NET: "Photino.Blazor App".Load(./wwwroot/index.html)
Photino.NET: "Photino.Blazor App".Load(file:///SomeDirectoryStuffHere/bin/Debug/net6.0/wwwroot/index.html)
Photino.NET: "Photino.Blazor App".Load(http://0.0.0.0/)

I was expecting after a second or so the app would pop up, but no such luck and there is no errors thrown from what I can tell.

I am running on .net6, windows 10 pro, using Rider as IDE.

== Edit ==

Forgot to mention that I changed the csproj sdk from the default console one to Microsoft.NET.Sdk.Razor when updating as shown in the sample one in this repo.

ottodobretsberger commented 2 years ago

If you have razor pages, they should run in the native window, but declaring the entire project as such is not correct. (at that point it would actually be a Web App). It should remain a console app. Also the [STAThread] is required for the Photino application to fire up in Windows, which you seem to have omitted in your changes.

grofit commented 2 years ago

Ah ok, the code on the readme threw me as that implied we should be using the new containerless style program code, and the samples were using the web sdk types. Will give that a swap and report back.

grofit commented 2 years ago

Yep changed those 2 above things and swapped it to use _framework/blazor.webview.js in the index and it works as expected, thanks for your assistance!