首页 > 解决方案 > DryIoc 容器异常仅在带有 Prism Android 应用的 XF 的 RELEASE 模式下

问题描述

我收到以下异常,但仅在使用w/容器和 Popups 插件(异常所指)构建的Xamarin.FormsAndroid 应用程序的 RELEASE 构建中。该应用程序在调试中运行良好。我只使用 SDK 程序集链接。PrismDryIoc

有没有人遇到过这个?

关于确定根本原因/修复的任何建议?

仅在发布模式下运行时出现此异常,我不知道为什么 - 有人可以帮我解决这个问题吗?在调试模式下完美运行。

尝试进行第一次导航时抛出异常(使用 INavigationService.NavigateAsync)。

DryIoc.ContainerException:'无法使用传递的参数解析 MyProject.ViewModels.LoginPageViewModel [value(Prism.Plugin.Popups.PopupPageNavigationService)] IsResolutionCall 从容器没有范围与规则与 {AutoConcreteTypeResolution} 和没有 {UseFastExpressionCompilerIfPlatformSupported} 与 Made={FactoryMethod= ConstructorWithResolvableArguments} 在 Rules.DynamicServiceProviders 的 0 中未找到服务注册且未找到动态注册,在 Rules.UnknownServiceResolvers 的 1 中未找到任何服务注册

我在用着:

Windows 10 上的 Visual Studio Enterprise 版本 16.2.5 Xamarin Forms 版本 4.2.0.778463 Prism.DryIoc.Forms 版本 7.2.0.1367 Prism.Plugin.Popups 版本 7.2.0.573 Rg.Plugins.Popup 版本 1.1.5.188

这是我的发布 csproj 设置,我对其进行了修改,以便在我的物理设备上对其进行调试:

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants> <!-- get rid of debug -->
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <AndroidLinkMode>SdkOnly</AndroidLinkMode>
    <AndroidSupportedAbis>armeabi-v7a;</AndroidSupportedAbis>
    <AndroidCreatePackagePerAbi>true</AndroidCreatePackagePerAbi>
    <AndroidHttpClientHandlerType>Xamarin.Android.Net.AndroidClientHandler</AndroidHttpClientHandlerType>
    <EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
    <BundleAssemblies>false</BundleAssemblies>
    <AotAssemblies>false</AotAssemblies>
    <EnableLLVM>false</EnableLLVM>
    <AndroidUseSharedRuntime>false</AndroidUseSharedRuntime>
    <AndroidEnableProfiledAot>false</AndroidEnableProfiledAot>
    <AndroidEnableMultiDex>false</AndroidEnableMultiDex>
    <JavaMaximumHeapSize>1G</JavaMaximumHeapSize>
    <AndroidEnableSGenConcurrent>true</AndroidEnableSGenConcurrent>
  </PropertyGroup>

这是App.xaml.cs中的注册,我用 Prism 的 [AutoRegisterForNavigation] 装饰了 App 类。我尝试显式注册 PopupNavigationService 和 Popups(前 2 行注释掉),但没有任何区别。

    protected override void RegisterTypes(IContainerRegistry containerRegistry)
    {
        // Services / Plugins
        //containerRegistry.RegisterInstance<IPopupNavigation>(PopupNavigation.Instance);
        //containerRegistry.Register<Prism.Plugin.Popups.PopupPageNavigationService>();
        containerRegistry.RegisterPopupNavigationService();
        containerRegistry.RegisterInstance<IContactService>(CrossContactService.Current);
        containerRegistry.Register<IDialogService, DialogService>();
        containerRegistry.Register<IQuoteProviderService, QuoteProviderService>();
        containerRegistry.Register<IMessageCheshirerService, MessageCheshirerService>();
        containerRegistry.Register<IMessageTrackerService, MessageTrackerService>();
        containerRegistry.Register<IEmailService, SendGridEmailService>();


        containerRegistry.Register<IAnalyticsService, FakeAnalyticsService>();
        containerRegistry.Register<IAuthenticationService, FakeAuthService>(); // note this overrides the real platform-specific implementations as desired
        containerRegistry.Register<IApiManager, FakeApiManager>();
        containerRegistry.Register<IInAppPurchaser, FakeInAppPurchaser>();

        containerRegistry.Register(typeof(IApiService<>), typeof(ApiService<>));

        // Non-Auto-Registered Views
        containerRegistry.RegisterForNavigation<NavigationPage>();
    }

标签: androidxamarin.formsxamarin.androidprismdryioc

解决方案


此错误消息是一个完全不同的嵌套依赖项的红鲱鱼,该依赖项未正确注册发布模式构建....请忽略。


推荐阅读