Unity.ResolutionFailedException Общедоступный конструктор недоступен - PullRequest
1 голос
/ 04 октября 2019

Я создал приложение форм Xamarin для платформ Android и iOS и теперь планирую развернуть его в Google Play Store и App Store.

Теперь мне нужно включить Linker SDK и User Assemblies для удаления всехнеиспользуемые классы и чтобы уменьшить размер файла приложения.

В настройках Android у меня есть этот параметр

Android options

Я также создал компоновщик.xml и установите его как LinkDescription в настройке свойства

<?xml version="1.0" encoding="utf-8" ?>
<linker>
  <assembly fullname="Prism.Forms">
    <type fullname="Prism.Common.ApplicationProvider" preserve="all" />
    <type fullname="Prism.Services.PageDialogService" preserve="all" />
    <type fullname="Prism.Services.DeviceService" preserve="all" />
    <type fullname="Prism.Ioc*" preserve="all" />
    <type fullname="Prism.Modularity*" preserve="all" />
    <type fullname="Prism.Navigation*" preserve="all" />
    <type fullname="Prism.Behaviors.PageBehaviorFactory" preserve="all">
      <method name=".ctor" />
    </type>
    <type fullname="Prism.Services.DependencyService" preserve="all">
      <method name=".ctor" />
    </type>
  </assembly>

  <assembly fullname="Prism">
    <type fullname="Prism.Navigation*" preserve="all" />
    <type fullname="Prism.Logging.EmptyLogger" preserve="all">
      <method name=".ctor" />
    </type>
  </assembly>

  <assembly fullname="Unity.Abstractions">
    <type fullname="*" />
  </assembly>

  <assembly fullname="Unity.Container">
    <type fullname="*" />
  </assembly>

  <assembly fullname="Newtonsoft.Json">
    <type fullname="Newtonsoft.Json.*" preserve="all" />
  </assembly>

</linker>

ниже приведены Stacktrace, который у меня есть

10-04 06:06:06.537 E/mono    ( 2305): referenceTable GDEF length=670 1
referenceTable GSUB length=7202 1
referenceTable GPOS length=24560 1

10-04 06:06:06.537 E/mono    ( 2305): Unhandled Exception:
10-04 06:06:06.537 E/mono    ( 2305): Unity.ResolutionFailedException: For more information add Diagnostic extension: Container.AddExtension(new Diagnostic()) ---> System.InvalidOperationException: No public constructor is available for type MyXamarinApp.Mobile.Client.ViewModel.Booking.LandingPageViewModel. ---> Unity.Exceptions.InvalidRegistrationException: Exception of type 'Unity.Exceptions.InvalidRegistrationException' was thrown.
10-04 06:06:06.537 E/mono    ( 2305):    --- End of inner exception stack trace ---
10-04 06:06:06.537 E/mono    ( 2305):   at Unity.Processors.ConstructorProcessor+<>c.<GetResolver>b__18_1 (Unity.Builder.BuilderContext& c) [0x00022] in <4013266d08a1421d96f21954cb38814a>:0 
10-04 06:06:06.537 E/mono    ( 2305):   at Unity.Processors.MemberProcessor`2+<>c__DisplayClass8_0[TMemberInfo,TData].<GetResolver>b__0 (Unity.Builder.BuilderContext& c) [0x00000] in <4013266d08a1421d96f21954cb38814a>:0 
10-04 06:06:06.537 E/mono    ( 2305):   at Unity.Processors.MemberProcessor`2+<>c__DisplayClass8_0[TMemberInfo,TData].<GetResolver>b__0 (Unity.Builder.BuilderContext& c) [0x00000] in <4013266d08a1421d96f21954cb38814a>:0 
10-04 06:06:06.537 E/mono    ( 2305):   at Unity.Processors.MemberProcessor`2+<>c__DisplayClass8_0[TMemberInfo,TData].<GetResolver>b__0 (Unity.Builder.BuilderContext& c) [0x00000] in <4013266d08a1421d96f21954cb38814a>:0 
10-04 06:06:06.537 E/mono    ( 2305):   at Unity.UnityContainer+<>c__DisplayClass94_0.<OptimizingFactory>b__0 (Unity.Builder.BuilderContext& c) [0x00042] in <4013266d08a1421d96f21954cb38814a>:0 
10-04 06:06:06.537 E/mono    ( 2305):   at Unity.Strategies.BuildPlanStrategy.PreBuildUp (Unity.Builder.BuilderContext& context) [0x000e0] in <4013266d08a1421d96f21954cb38814a>:0 
10-04 06:06:06.537 E/mono    ( 2305):   at Unity.UnityContainer+<>c.<.ctor>b__58_1 (Unity.Builder.BuilderContext& context) [0x00015] in <4013266d08a1421d96f21954cb38814a>:0 
10-04 06:06:06.537 E/mono    ( 2305):    --- End of inner exception stack trace ---
10-04 06:06:06.537 E/mono    ( 2305):   at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.3(intptr,intptr,intptr)
10-04 06:06:06.537 E/mono    ( 2305):   at (wrapper native-to-managed) Android.Runtime.DynamicMethodNameCounter.3(intptr,intptr,intptr)
10-04 06:06:06.538 E/mono-rt ( 2305): [ERROR] FATAL UNHANDLED EXCEPTION: Unity.ResolutionFailedException: For more information add Diagnostic extension: Container.AddExtension(new Diagnostic()) ---> System.InvalidOperationException: No public constructor is available for type MyXamarinApp.Mobile.Client.ViewModel.Booking.LandingPageViewModel. ---> Unity.Exceptions.InvalidRegistrationException: Exception of type 'Unity.Exceptions.InvalidRegistrationException' was thrown.
10-04 06:06:06.538 E/mono-rt ( 2305):    --- End of inner exception stack trace ---
10-04 06:06:06.538 E/mono-rt ( 2305):   at Unity.Processors.ConstructorProcessor+<>c.<GetResolver>b__18_1 (Unity.Builder.BuilderContext& c) [0x00022] in <4013266d08a1421d96f21954cb38814a>:0 
10-04 06:06:06.538 E/mono-rt ( 2305):   at Unity.Processors.MemberProcessor`2+<>c__DisplayClass8_0[TMemberInfo,TData].<GetResolver>b__0 (Unity.Builder.BuilderContext& c) [0x00000] in <4013266d08a1421d96f21954cb38814a>:0 
10-04 06:06:06.538 E/mono-rt ( 2305):   at Unity.Processors.MemberProcessor`2+<>c__DisplayClass8_0[TMemberInfo,TData].<GetResolver>b__0 (Unity.Builder.BuilderContext& c) [0x00000] in <4013266d08a1421d96f21954cb38814a>:0 
10-04 06:06:06.538 E/mono-rt ( 2305):   at Unity.Processors.MemberProcessor`2+<>c__DisplayClass8_0[TMemberInfo,TData].<GetResolver>b__0 (Unity.Builder.BuilderContext& c) [0x00000] in <4013266d08a1421d96f21954cb38814a>:0 
10-04 06:06:06.538 E/mono-rt ( 2305):   at Unity.UnityContainer+<>c__DisplayClass94_0.<OptimizingFactory>b__0 (Unity.Builder.BuilderContext& c) [0x00042] in <4013266d08a1421d96f21954cb38814a>:0 
10-04 06:06:06.538 E/mono-rt ( 2305):   at Unity.Strategies.BuildPlanStrategy.PreBuildUp (Unity.Builder.BuilderContext& context) [0x000e0] in <4013266d08a1421d96f21954cb38814a>:0 
10-04 06:06:06.538 E/mono-rt ( 2305):   at Unity.UnityContainer+<>c.<.ctor>b__58_1 (Unity.Builder.BuilderContext& context) [0x00015] in <4013266d08a1421d96f21954cb38814a>:0 
10-04 06:06:06.538 E/mono-rt ( 2305):    --- End of inner exception stack trace ---
10-04 06:06:06.538 E/mono-rt ( 2305):   at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.3(intptr,intptr,intptr)
10-04 06:06:06.538 E/mono-rt ( 2305):   at (wrapper native-to-managed) Android.Runtime.DynamicMethodNameCounter.3(intptr,intptr,intptr)

Я использовал инфраструктуру Prism 7.0 и Unity.

...