簡體   English   中英

Xamarin System.Reflection.TargetInvocationException:調用的目標已引發異常

[英]Xamarin System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation

我遇到了這個錯誤和我的截止日期,我的 XAML 或 ViewModel 有問題,但我無法識別問題(在 xamarin 中)。

我不斷收到此錯誤System.Reflection.TargetInvocationException: 'Exception has been thrown by the target of an invocation.' 在 SignUpView.xaml.g.cs:26

注冊視圖.Xaml

<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" 
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:ctrls="clr-namespace:MiniPOS.UserControls;assembly=MiniPOS"
             xmlns:effects="clr-namespace:MiniPOS.Effects;assembly=MiniPOS"
             xmlns:views="clr-namespace:MiniPOS.Views;assembly=MiniPOS"
             xmlns:inputLayout="clr-namespace:Syncfusion.XForms.TextInputLayout;assembly=Syncfusion.Core.XForms"
             xmlns:combobox="clr-namespace:Syncfusion.XForms.ComboBox;assembly=Syncfusion.SfComboBox.XForms"
             xmlns:border="clr-namespace:Syncfusion.XForms.Border;assembly=Syncfusion.Core.XForms"
             xmlns:button="clr-namespace:Syncfusion.XForms.Buttons;assembly=Syncfusion.Buttons.XForms"
             xmlns:customViews="clr-namespace:MiniPOS.UserControls;assembly=MiniPOS"
             xmlns:viewModelBase="clr-namespace:MiniPOS.ViewModels.Base;assembly=MiniPOS"
             xmlns:texts="clr-namespace:MiniPOS.Resources.Texts;assembly=MiniPOS"
             viewModelBase:ViewModelLocator.AutoWireViewModel="true"
             xmlns:system="clr-namespace:System;assembly=mscorlib"
             Title="Sign Up"
             x:Name="signUpView"
             x:Class="MiniPOS.Views.SignUpView"
            >
    <ContentPage.Resources>
        <ResourceDictionary>

            <Style x:Key="TitleLabelStyle" 
                   TargetType="Label"
                   BasedOn="{StaticResource SpectralRegularLabelStyle}">
                <Setter Property="TextColor" 
                        Value="{StaticResource BlueColor}" />
                <Setter Property="HorizontalOptions" 
                        Value="FillAndExpand" />
                <Setter Property="FontSize" 
                        Value="{StaticResource LittleSize}" />
                <Setter Property="Margin"
                        Value="0,10,0,0">
                </Setter>
            </Style>

            <Style x:Key="AddCustomerHeaderStyle" 
                   TargetType="{x:Type Label}">
                <Setter Property="FontFamily"
                        Value="{StaticResource NunitoRegular}" />
                <Setter Property="FontSize"
                        Value="{StaticResource MidMediumSize}" />
                <!--<Setter Property="TextColor"
                        Value="Gray" />-->
                <Setter Property="HorizontalOptions"
                        Value="FillAndExpand" />
                <Setter Property="VerticalOptions"
                        Value="End" />
                <Setter Property="Margin"
                        Value="0,0,0,0" />
            </Style>

            <Style x:Key="AddCustomerLabelStyle" 
                   TargetType="{x:Type Label}">
                <Setter Property="FontFamily"
                        Value="{StaticResource NunitoRegular}" />
                <Setter Property="FontSize"
                        Value="{StaticResource LargeSize}" />
                <Setter Property="TextColor"
                        Value="{StaticResource BlackTextColor}" />
                <Setter Property="HorizontalOptions"
                        Value="FillAndExpand" />
                <Setter Property="VerticalOptions"
                        Value="Center" />
                <Setter Property="Margin"
                        Value="0,10,0,0" />
            </Style>
        </ResourceDictionary>
    </ContentPage.Resources>
    <ContentPage.ToolbarItems>
        <ToolbarItem 
            Clicked="ToolbarItem_Clicked"
            Command="{Binding User_SaveCommand}"
            Text="{texts:Translate Save}"
            Order="Primary"
            Priority="1">
            <ToolbarItem.Icon>
                <OnPlatform x:TypeArguments="FileImageSource">
                    <On Platform="Android" Value="save.png" />
                </OnPlatform>
            </ToolbarItem.Icon>
        </ToolbarItem>
    </ContentPage.ToolbarItems>
    <ContentPage.Content>
        <Grid>
            <ScrollView>
                <StackLayout BackgroundColor="White">
                    <Grid Margin="10,15,10,15">
                        <Grid.RowSpacing>
                            <OnPlatform x:TypeArguments="x:Double" Android="-5" iOS="10"/>
                        </Grid.RowSpacing>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <inputLayout:SfTextInputLayout Grid.Row="0"
                                                       ContainerType="Outlined"
                                                       FocusedColor="{StaticResource Primary}"
                                                       Hint="Username"
                                                       ContainerBackgroundColor="Aqua"
                                                       HorizontalOptions="Fill"
                                                       LeadingViewPosition="Inside">
                            <Entry  MaxLength="250" Text="{Binding Username}"/>
                            <inputLayout:SfTextInputLayout.LeadingView>
                                <Label FontSize="18" 
                                               Text="&#xf3c5;"
                                               TextColor="{StaticResource Primary}"
                                               VerticalTextAlignment="Center">
                                    <Label.FontFamily>
                                        <OnPlatform x:TypeArguments="x:String" iOS="Font Awesome 5 Free" Android="fa-solid-900.ttf#Font Awesome 5 Free Solid" >
                                        </OnPlatform>
                                    </Label.FontFamily>
                                </Label>
                            </inputLayout:SfTextInputLayout.LeadingView>
                        </inputLayout:SfTextInputLayout>
                        <inputLayout:SfTextInputLayout Grid.Row="1"
                                                       ContainerType="Outlined"
                                                       FocusedColor="{StaticResource Primary}"
                                                       ContainerBackgroundColor="Aqua"
                                                       Hint="Password"
                                                       HorizontalOptions="Fill"
                                                       LeadingViewPosition="Inside">
                            <Entry IsPassword="True" MaxLength="250" Text="{Binding Password}"/>
                            <inputLayout:SfTextInputLayout.LeadingView>
                                <Label FontSize="18" 
                                               Text="&#xf3c5;"
                                               TextColor="{StaticResource Primary}"
                                               VerticalTextAlignment="Center">
                                    <Label.FontFamily>
                                        <OnPlatform x:TypeArguments="x:String" iOS="Font Awesome 5 Free" Android="fa-solid-900.ttf#Font Awesome 5 Free Solid" >
                                        </OnPlatform>
                                    </Label.FontFamily>
                                </Label>
                            </inputLayout:SfTextInputLayout.LeadingView>
                        </inputLayout:SfTextInputLayout>
                        <inputLayout:SfTextInputLayout Grid.Row="2"
                                                       ContainerType="Outlined"
                                                       FocusedColor="{StaticResource Primary}"
                                                       Hint="First Name"
                                                       ContainerBackgroundColor="Aqua"
                                                       HorizontalOptions="Fill"
                                                       LeadingViewPosition="Inside">
                            <Entry  MaxLength="250" Text="{Binding FirstName}"/>
                            <inputLayout:SfTextInputLayout.LeadingView>
                                <Label FontSize="18" 
                                               Text="&#xf3c5;"
                                               TextColor="{StaticResource Primary}"
                                               VerticalTextAlignment="Center">
                                    <Label.FontFamily>
                                        <OnPlatform x:TypeArguments="x:String" iOS="Font Awesome 5 Free" Android="fa-solid-900.ttf#Font Awesome 5 Free Solid" >
                                        </OnPlatform>
                                    </Label.FontFamily>
                                </Label>
                            </inputLayout:SfTextInputLayout.LeadingView>
                        </inputLayout:SfTextInputLayout>
                        <inputLayout:SfTextInputLayout Grid.Row="3"
                                                       ContainerType="Outlined"
                                                       FocusedColor="{StaticResource Primary}"
                                                       ContainerBackgroundColor="Aqua"
                                                       Hint="Last Name"
                                                       HorizontalOptions="Fill"
                                                       LeadingViewPosition="Inside">
                            <Entry  MaxLength="250" Text="{Binding LastName}"/>
                            <inputLayout:SfTextInputLayout.LeadingView>
                                <Label FontSize="18" 
                                               Text="&#xf3c5;"
                                               TextColor="{StaticResource Primary}"
                                               VerticalTextAlignment="Center">
                                    <Label.FontFamily>
                                        <OnPlatform x:TypeArguments="x:String" iOS="Font Awesome 5 Free" Android="fa-solid-900.ttf#Font Awesome 5 Free Solid" >
                                        </OnPlatform>
                                    </Label.FontFamily>
                                </Label>
                            </inputLayout:SfTextInputLayout.LeadingView>
                        </inputLayout:SfTextInputLayout>
                        <inputLayout:SfTextInputLayout Grid.Row="4"
                                                       ContainerType="Outlined"
                                                       FocusedColor="{StaticResource Primary}"
                                                       ContainerBackgroundColor="Aqua"
                                                       HasError="{Binding IsMobileInValid}"
                                                       Hint="{texts:Translate PhoneHint}"
                                                       HorizontalOptions="Fill"
                                                       LeadingViewPosition="Inside">
                            <Entry Text="{Binding PhoneNumber}" Keyboard="Telephone"/>
                            <inputLayout:SfTextInputLayout.LeadingView>
                                <Label FontSize="18" 
                                               Text="&#xf3cd;"
                                               TextColor="{StaticResource Primary}"
                                               VerticalTextAlignment="Center">
                                    <Label.FontFamily>
                                        <OnPlatform x:TypeArguments="x:String" iOS="Font Awesome 5 Free" Android="fa-solid-900.ttf#Font Awesome 5 Free Solid" >
                                        </OnPlatform>
                                    </Label.FontFamily>
                                </Label>
                            </inputLayout:SfTextInputLayout.LeadingView>
                        </inputLayout:SfTextInputLayout>

                        <inputLayout:SfTextInputLayout Grid.Row="5"
                                                       ContainerType="Outlined"
                                                       FocusedColor="{StaticResource Primary}"
                                                       ContainerBackgroundColor="Aqua"
                                                       HasError="{Binding IsEmailInValid}"
                                                       Hint="Email"
                                                       HorizontalOptions="Fill"
                                                       LeadingViewPosition="Inside">
                            <Entry Text="{Binding Email}" Keyboard="Email"/>
                            <inputLayout:SfTextInputLayout.LeadingView>
                                <Label FontSize="18" 
                                               Text="&#xf0e0;"
                                               TextColor="{StaticResource Primary}"
                                               VerticalTextAlignment="Center">
                                    <Label.FontFamily>
                                        <OnPlatform x:TypeArguments="x:String" iOS="Font Awesome 5 Free" Android="fa-solid-900.ttf#Font Awesome 5 Free Solid" >
                                        </OnPlatform>
                                    </Label.FontFamily>
                                </Label>
                            </inputLayout:SfTextInputLayout.LeadingView>
                        </inputLayout:SfTextInputLayout>

                        <inputLayout:SfTextInputLayout Grid.Row="6"
                                                       ContainerType="Outlined"
                                                       FocusedColor="{StaticResource Primary}"
                                                       ContainerBackgroundColor="Aqua"
                                                       Hint="{texts:Translate AddressHint}"
                                                       HorizontalOptions="Fill"
                                                       LeadingViewPosition="Inside">
                            <Entry Text="{Binding Address}" MaxLength="250"/>
                            <inputLayout:SfTextInputLayout.LeadingView>
                                <Label FontSize="18" 
                                               Text="&#xf3c5;"
                                               TextColor="{StaticResource Primary}"
                                               VerticalTextAlignment="Center">
                                    <Label.FontFamily>
                                        <OnPlatform x:TypeArguments="x:String" iOS="Font Awesome 5 Free" Android="fa-solid-900.ttf#Font Awesome 5 Free Solid" >
                                        </OnPlatform>
                                    </Label.FontFamily>
                                </Label>
                            </inputLayout:SfTextInputLayout.LeadingView>
                        </inputLayout:SfTextInputLayout>
                    </Grid>
                </StackLayout>
            </ScrollView>
            <customViews:LoadingIndicator 
                        Grid.Row="0"
                        IsRunning="{Binding IsBusy, Mode=TwoWay}"
                        HorizontalOptions="Fill"
                        VerticalOptions="Fill" />
        </Grid>
    </ContentPage.Content>
</ContentPage>

注冊視圖.Xaml.cs

using System;
using System.Collections.Generic;
using MiniPOS.ViewModels;
using Xamarin.Forms;
using Xamarin.Forms.PlatformConfiguration.AndroidSpecific;
using Xamarin.Forms.Xaml;

namespace MiniPOS.Views
{
    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class SignUpView : ContentPage
    {
        public SignUpViewModel Context => (SignUpViewModel)this.BindingContext;
        public SignUpView()
        {
            InitializeComponent();
            NavigationPage.SetHasBackButton(this, false);
        }
        protected override void OnAppearing()
        {
            base.OnAppearing();
            App.Current.On<Xamarin.Forms.PlatformConfiguration.Android>().UseWindowSoftInputModeAdjust(WindowSoftInputModeAdjust.Resize);
        }



        protected override void OnDisappearing()
        {
            base.OnDisappearing();
            App.Current.On<Xamarin.Forms.PlatformConfiguration.Android>().UseWindowSoftInputModeAdjust(WindowSoftInputModeAdjust.Pan);
        }

        private void ToolbarItem_Clicked(object sender, EventArgs e)
        {
            ((SignUpViewModel)this.BindingContext).User_SaveCommand.Execute(null);
            Navigation.RemovePage(this);
        }

注冊ViewModel.cs

using DataModel;
using MiniPOS.AppSettings;
using MiniPOS.Entity;
using MiniPOS.Extensions;
using MiniPOS.Helpers;
using MiniPOS.Resources.Texts;
using MiniPOS.Services;
using MiniPOS.ViewModels.Base;
using MiniPOS.Views;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using Xamarin.Forms;
using System.IO;

namespace MiniPOS.ViewModels
{
    public class SignUpViewModel : ViewModelBase
    {
        private readonly ISignUpService _signUpService;
        private User _user;
        private List<User> _users;
        private UserDetail _userDetail;
        private readonly LogWriter log = new LogWriter();
        const string filename = "SignUpViewModel.cs";
        public SignUpViewModel(ISignUpService signUpService)
        {
            _signUpService = signUpService;
            _user = new User();
            _userDetail = new UserDetail();
            _users = new List<User>();
            MessagingCenter.Subscribe<string>(this, "OnDataSourceChanged", (args) =>
            {
                Device.BeginInvokeOnMainThread(async () =>
                {
                    IsBusy = true;
                    await LoadSignUp();
                    IsBusy = false;
                    ItemIndex = -1;
                });
            });
            Task.Run(async () =>
            {
                await LoadSignUp();
            });
        }
        public List<User> Users
        {
            get => _users;
            set
            {
                _users = value;
                RaisePropertyChanged(() => Users);
            }
        }
        public async Task LoadSignUp()
        {
            Expression<Func<User, bool>> signUpExpression = x => x.Deleted == 0;
            var cashs = await _signUpService.GetAllUserAsync(signUpExpression);
        }
        private string _username;
        public string Username
        {
            get => _username;
            set
            {
                _username = value;
                RaisePropertyChanged(() => Username);
            }
        }

        private string _password;
        public string Password
        {
            get => _password;
            set
            {
                _password = value;
                RaisePropertyChanged(() => Password);
            }
        }

        private string _firstName;
        public string FirstName
        {
            get => _firstName;
            set
            {
                _firstName = value;
                RaisePropertyChanged(() => FirstName);
            }
        }

        private string _lastName;
        public string LastName
        {
            get => _lastName;
            set
            {
                _lastName = value;
                RaisePropertyChanged(() => LastName);
            }
        }

        private long _phoneNumber;
        public long PhoneNumber
        {
            get => _phoneNumber;
            set
            {
                _phoneNumber = value;
                RaisePropertyChanged(() => PhoneNumber);
            }
        }

        private string _email;
        public string Email
        {
            get => _email;
            set
            {
                _email = value;
                RaisePropertyChanged(() => Email);
            }
        }

        private string _address;
        public string Address
        {
            get => _address;
            set
            {
                _address = value;
                RaisePropertyChanged(() => Address);
            }
        }

        private void ResetForm()
        {
            Username = string.Empty;
            Password = string.Empty;
            PhoneNumber = 0;
            Email = string.Empty;
            Address = string.Empty;
            FirstName = string.Empty;
            LastName = string.Empty;
        }

        public ICommand User_SaveCommand => new Command(async () => await AddUser_SaveAsync());

        public async Task AddUser_SaveAsync()
        {
            string informedMessage = "";
            IsBusy = true;
            var user = new User
            {
                Id = Generator.GenerateKey(),
                Username = Username,
                Password = Password,
                IsSuper = true
            };
            await _signUpService.InsertUserAsync(user);
            var userDetail = new UserDetail
            {
                Id = Generator.GenerateKey(),
                UserId = user.Id,
                FirstName = FirstName,
                LastName = LastName,
                Email = Email,
                Address = Address,
                PhoneNumber = PhoneNumber,
                Role = 0,
                IsSync = false
            };
            await _signUpService.InsertUserDetailAsync(userDetail);
            ResetForm();
            informedMessage = TextsTranslateManager.Translate("CustomerSaved");
            log.Info("User Saved", filename);
            App._uValid = false;
            IsBusy = false;
            DialogService.ShowToast(informedMessage);
        }
        private void ConvertBackModelToEntity()
        {
            _user.Username = Username;
            _user.Password = Password;
            _userDetail.FirstName = FirstName;
            _userDetail.LastName = LastName;
            _userDetail.PhoneNumber = PhoneNumber;
            _userDetail.Address = Address;
            _userDetail.Email = Email;
        }

        public override async Task InitializeAsync(object navigationData)
        {
            IsBusy = true;
            PageTitle = TextsTranslateManager.Translate("AddCustomerTitle");
            IsBusy = false;
        }


    }
}

我在其他問題中注意到,normaly 是 xaml 中的一個問題,但我找不到我的錯誤(對不起,英語不好)

輸出:

**System.Reflection.TargetInvocationException:** 'Exception has been thrown by the target of an invocation.'

02-20 16:41:34.738 E/mono    (20824): 
02-20 16:41:34.738 E/mono    (20824): Unhandled Exception:
02-20 16:41:34.738 E/mono    (20824): System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> TinyIoC.TinyIoCResolutionException: Unable to resolve type: MiniPOS.ViewModels.SignUpViewModel ---> TinyIoC.TinyIoCResolutionException: Unable to resolve type: MiniPOS.ViewModels.SignUpViewModel ---> TinyIoC.TinyIoCResolutionException: Unable to resolve type: MiniPOS.Services.ISignUpService
02-20 16:41:34.738 E/mono    (20824):   at TinyIoC.TinyIoCContainer.ResolveInternal (TinyIoC.TinyIoCContainer+TypeRegistration registration, TinyIoC.NamedParameterOverloads parameters, TinyIoC.ResolveOptions options) [0x0022c] in C:\Users\Juan Finol\source\repos\terminalpointofsale\Mobile\MiniPOS\MiniPOS\TinyIoC\TinyIoC.cs:3827 
02-20 16:41:34.738 E/mono    (20824):   at TinyIoC.TinyIoCContainer.ConstructType (System.Type requestedType, System.Type implementationType, System.Reflection.ConstructorInfo constructor, TinyIoC.NamedParameterOverloads parameters, TinyIoC.ResolveOptions options) [0x000ab] in C:\Users\Juan Finol\source\repos\terminalpointofsale\Mobile\MiniPOS\MiniPOS\TinyIoC\TinyIoC.cs:4031 
02-20 16:41:34.738 E/mono    (20824):    --- End of inner exception stack trace ---
02-20 16:41:34.738 E/mono    (20824):   at TinyIoC.TinyIoCContainer.ConstructType (System.Type requestedType, System.Type implementationType, System.Reflection.ConstructorInfo constructor, TinyIoC.NamedParameterOverloads parameters, TinyIoC.ResolveOptions options) [0x000ee] in C:\Users\Juan Finol\source\repos\terminalpointofsale\Mobile\MiniPOS\MiniPOS\TinyIoC\TinyIoC.cs:4043 
02-20 16:41:34.738 E/mono    (20824):   at TinyIoC.TinyIoCContainer+MultiInstanceFactory.GetObject (System.Type requestedType, TinyIoC.TinyIoCContainer container, TinyIoC.NamedParameterOverloads parameters, TinyIoC.ResolveOptions options) [0x00002] in C:\Users\Juan Finol\source\repos\terminalpointofsale\Mobile\MiniPOS\MiniPOS\TinyIoC\TinyIoC.cs:2858 
02-20 16:41:34.738 E/mono    (20824):    --- End of inner exception stack trace ---
02-20 16:41:34.738 E/mono    (20824):   at TinyIoC.TinyIoCContainer+MultiInstanceFactory.GetObject (System.Type requestedType, TinyIoC.TinyIoCContainer container, TinyIoC.NamedParameterOverloads parameters, TinyIoC.ResolveOptions options) [0x0001d] in C:\Users\Juan Finol\source\repos\terminalpointofsale\Mobile\MiniPOS\MiniPOS\TinyIoC\TinyIoC.cs:2862 
02-20 16:41:34.738 E/mono    (20824):   at TinyIoC.TinyIoCContainer.ResolveInternal (TinyIoC.TinyIoCContainer+TypeRegistration registration, TinyIoC.NamedParameterOverloads parameters, TinyIoC.ResolveOptions options) [0x0002d] in C:\Users\Juan Finol\source\repos\terminalpointofsale\Mobile\MiniPOS\MiniPOS\TinyIoC\TinyIoC.cs:3736 
02-20 16:41:34.738 E/mono    (20824):   at TinyIoC.TinyIoCContainer.Resolve (System.Type resolveType) [0x00001] in C:\Users\Juan Finol\source\repos\terminalpointofsale\Mobile\MiniPOS\MiniPOS\TinyIoC\TinyIoC.cs:1827 
02-20 16:41:34.739 E/mono    (20824):   at MiniPOS.ViewModels.Base.ViewModelLocator.OnAutoWireViewModelChanged (Xamarin.Forms.BindableObject bindable, System.Object oldValue, System.Object newValue) [0x00070] in C:\Users\Juan Finol\source\repos\terminalpointofsale\Mobile\MiniPOS\MiniPOS\ViewModels\Base\ViewModelLocator.cs:158 
02-20 16:41:34.739 E/mono    (20824):   at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x00120] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:463 
02-20 16:41:34.739 E/mono    (20824):   at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x00173] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:397 
02-20 16:41:34.739 E/mono    (20824):   at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, System.Boolean fromStyle, System.Boolean checkAccess) [0x00042] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:334 
02-20 16:41:34.739 E/mono    (20824):   at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:311 
02-20 16:41:34.739 E/mono    (20824):   at MiniPOS.Views.SignUpView.InitializeComponent () [0x00023] in C:\Users\Juan Finol\source\repos\terminalpointofsale\Mobile\MiniPOS\MiniPOS\obj\Debug
etstandard2.0\Views\SignUpView.xaml.g.cs:26 
02-20 16:41:34.739 E/mono    (20824):   at MiniPOS.Views.SignUpView..ctor () [0x00008] in C:\Users\Juan Finol\source\repos\terminalpointofsale\Mobile\MiniPOS\MiniPOS\Views\SignUpView.xaml.cs:16 
02-20 16:41:34.739 E/mono    (20824):   at (wrapper managed-to-native) System.Reflection.RuntimeConstructorInfo.InternalInvoke(System.Reflection.RuntimeConstructorInfo,object,object[],System.Exception&)
02-20 16:41:34.739 E/mono    (20824):   at System.Reflection.RuntimeConstructorInfo.InternalInvoke (System.Object obj, System.Object[] parameters, System.Boolean wrapExceptions) [0x00005] in /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/mcs/class/corlib/System.Reflection/RuntimeMethodInfo.cs:936 
02-20 16:41:34.739 E/mono    (20824):    --- End of inner exception stack trace ---

異常告訴我們錯誤是什么:

Unable to resolve type: MiniPOS.Services.ISignUpService

為了在構造函數中注入/解析 ISignUpService,它需要在 TinyIoC 容器中注冊。 這將是類似

var container = TinyIoCContainer.Current;
container.Register<ISignUpService, SignUpService>();

請注意,您可能希望在應用程序生命周期的早期(可能在 App.Xaml.cs 文件中)執行此操作。

查看TinyIoC 文檔了解更多信息。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM