Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception: Window already exists #645

Open
ChristianM66 opened this issue Jun 11, 2024 · 5 comments
Open

Exception: Window already exists #645

ChristianM66 opened this issue Jun 11, 2024 · 5 comments

Comments

@ChristianM66
Copy link

Hello, I am using DryIoC in conjunction with IServiceColleciotn in net8 and Maui.
When merging DryIoC and IServiceCollection using IContainer.Populate the following exception is thrown .

Without DryIoC and the Populate call, the exception does not occur.

Many thanks for your help

StackTrace
at Microsoft.Maui.Controls.Window.Microsoft.Maui.IWindow.Created()
at Microsoft.Maui.LifecycleEvents.AppHostBuilderExtensions.<>c.b__2_0(Window window)
at Microsoft.Maui.Platform.ApplicationExtensions.<>c__DisplayClass1_0.b__1(OnWindowCreated del)
at Microsoft.Maui.LifecycleEvents.LifecycleEventServiceExtensions.InvokeLifecycleEvents[TDelegate](IServiceProvider services, Action`1 action)
at Microsoft.Maui.Platform.ApplicationExtensions.CreatePlatformWindow(Application platformApplication, IApplication application, OpenWindowRequest args)
at Microsoft.Maui.Platform.ApplicationExtensions.CreatePlatformWindow(Application platformApplication, IApplication application, LaunchActivatedEventArgs args)
at Microsoft.Maui.MauiWinUIApplication.OnLaunched(LaunchActivatedEventArgs args)
at Microsoft.UI.Xaml.Application.Microsoft.UI.Xaml.IApplicationOverrides.OnLaunched(LaunchActivatedEventArgs args)
at ABI.Microsoft.UI.Xaml.IApplicationOverrides.Do_Abi_OnLaunched_0(IntPtr thisPtr, IntPtr args)

@dadhi
Copy link
Owner

dadhi commented Jun 11, 2024

What is the exception message?

@ChristianM66
Copy link
Author

What is the exception message?
The exception message is: Window already exists.

The error occurs under net8 regardless of which versions of DryIoC and DryIoc.Microsoft.DependencyInjection are used.

ioCManager encapsulates DryIoC.IContainer and is registered in DryIoContainer itself.

DryIoC: 5.4.3
DryIoc.Microsoft.DependencyInjection: 6.2.0

Configuration:
private IocManager()
{
this.Container = new Container(_ =>
Rules.Default.WithConcreteTypeDynamicRegistrations(reuse: Reuse.Transient).
With(Made.Of(FactoryMethod.ConstructorWithResolvableArguments)).
WithFuncAndLazyWithoutRegistration().
WithTrackingDisposableTransients().
WithFactorySelector(Rules.SelectLastRegisteredFactory()).
WithMicrosoftDependencyInjectionRules().
WithUseInterpretation());
}

or
DryIoC: 6.0.0-preview-07
DryIoc.Microsoft.DependencyInjection: 8.0.0-preview-02

Configuration
private IocManager()
{
Rules rules = DryIocAdapter.MicrosoftDependencyInjectionRules.WithConcreteTypeDynamicRegistrations(reuse: Reuse.Transient).
With(Made.Of(FactoryMethod.ConstructorWithResolvableArguments)).
WithFuncAndLazyWithoutRegistration().
WithTrackingDisposableTransients().
WithFactorySelector(Rules.SelectLastRegisteredFactory()).
WithUseInterpretation();

this.Container = new Container(rules)
}

When I call Populate (iocManager.Container.Populate(mauiAppBuilder.Services);) the exception is thrown.

I have been working successfully with DryIoc, Xamarin, netStandard, AspNet.Core since 2019. The error occurs with net8 and Maui.

No matter which platform (Windows Machine, Android, iOS) is used

@dadhi
Copy link
Owner

dadhi commented Jun 12, 2024

@ChristianM66

Thanks for the clarifying.
Sadly, nor exception message, nor the stack trace contains any DryIoc related information.
I would suggest to search MAUI code for specifics of the "Window already exists" condition.

Also in regard to the Rules.Default.WithConcreteTypeDynamicRegistrations(reuse: Reuse.Transient).
Could you remove it and check again?

@dadhi
Copy link
Owner

dadhi commented Jun 27, 2024

@ChristianM66 Hi, I want to suggest trying DryIoc v6.0.0-preview-07 and check if the issue is reproducible.

@dadhi
Copy link
Owner

dadhi commented Aug 29, 2024

@ChristianM66 any updates on the issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants