首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >XCalendar插件错误: TargetInvocationException

XCalendar插件错误: TargetInvocationException
EN

Stack Overflow用户
提问于 2022-04-10 02:17:53
回答 1查看 139关注 0票数 1

我是Xamarin的新手,在C#方面不是很有经验。我安装了XCalendar插件,并试图实现EventCalendarExample示例代码(参见这里的GitHub ),以更好地理解这段代码的工作原理,并学习如何修改和使用它。我对Xamarin的日历插件做了一些研究,并且喜欢这个插件,因为它展示了如何使用它。我看过的其他一些没有太多的文档或示例代码可以查看。

我实现的代码与我的项目中的代码完全一样,但是,当我在调试代码时单击日历选项卡时,我会收到以下错误:

System.Reflection.TargetInvocationException:‘异常已被调用的目标抛出。’

下面的文件在GitHub中实现:

  • 模型/Event.cs
  • 转换器/Converters变换器
  • ViewModel/BaseViewModel.cs
  • ViewModel/EventCalportExampleViewModel.cs
  • 视图/EventCalcalamplePage.xaml
  • 视图/EventCalcalamplePage.xaml.cs

我的AppShell.xaml在下面。请注意,我的EventCalendarExamplePage名为EventManagerPage。

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>
<Shell xmlns="http://xamarin.com/schemas/2014/forms" 
       xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
       xmlns:local="clr-namespace:PPA.Views"
       Title="PPA"
       x:Class="PPA.AppShell"
       >

    <!--
        The overall app visual hierarchy is defined here, along with navigation.
    
        https://learn.microsoft.com/xamarin/xamarin-forms/app-fundamentals/shell/
    -->

    <Shell.Resources>
        <ResourceDictionary>
            <Style x:Key="BaseStyle" TargetType="Element">
                <Setter Property="Shell.BackgroundColor" Value="{StaticResource Primary}" />
                <Setter Property="Shell.ForegroundColor" Value="White" />
                <Setter Property="Shell.TitleColor" Value="White" />
                <Setter Property="Shell.DisabledColor" Value="#B4FFFFFF" />
                <Setter Property="Shell.UnselectedColor" Value="#95FFFFFF" />
                <Setter Property="Shell.TabBarBackgroundColor" Value="{StaticResource Primary}" />
                <Setter Property="Shell.TabBarForegroundColor" Value="White"/>
                <Setter Property="Shell.TabBarUnselectedColor" Value="#95FFFFFF"/>
                <Setter Property="Shell.TabBarTitleColor" Value="White"/>
            </Style>
            <Style TargetType="TabBar" BasedOn="{StaticResource BaseStyle}" />
            <Style TargetType="FlyoutItem" BasedOn="{StaticResource BaseStyle}" />
        </ResourceDictionary>
    </Shell.Resources>

    <TabBar>
        <ShellContent Title="Tasks" Icon="icon_about.png" Route="TaskManagerPage" ContentTemplate="{DataTemplate local:TaskManagerPage}" />
        <ShellContent Title="Events" Icon="icon_about.png" Route="EventManagerPage" ContentTemplate="{DataTemplate local:EventManagerPage}" />
        <ShellContent Title="Reminders" Icon="icon_about.png" Route="ReminderManagerPage" ContentTemplate="{DataTemplate local:ReminderManagerPage}"/>

    </TabBar>


</Shell>

我环顾四周,没有看到任何有这个错误的人。任何信息或建议将不胜感激!

注-当我单击模拟器中的日历选项卡时,这是我在输出窗格中看到的唯一文本。

代码语言:javascript
复制
[OpenGLRenderer] Davey! duration=1240ms; Flags=0, IntendedVsync=16577769666564, Vsync=16577769666564, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=16577772074980, AnimationStart=16577772093180, PerformTraversalsStart=16577772332780, DrawStart=16577773064980, SyncQueued=16577774097980, SyncStart=16577775454680, IssueDrawCommandsStart=16577775647080, SwapBuffers=16579009952980, FrameCompleted=16579011771880, DequeueBufferDuration=449700, QueueBufferDuration=929200, GpuCompleted=0, 

[TabLayout] MODE_SCROLLABLE + GRAVITY_FILL is not supported, GRAVITY_START will be used instead

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

我寻找一个堆栈跟踪或其他更多的信息,但这是我所能找到的全部。错误列表没有任何内容,“调用堆栈”选项卡只显示“外部代码”。当我按建议从异常框中单击“复制详细信息”时,我将得到以下内容,而没有其他内容。

调用的目标引发了System.Reflection.TargetInvocationException Message=Exception。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-04-11 02:43:58

结果发现,我丢失了一些被引用的静态资源,这些资源导致了它的崩溃。感谢ToolmakerSteve提供关于内部异常的更多信息。我没有意识到这个异常有任何内部组件。

当抛出时,我能够将组件初始化包装在尝试捕获中,并在弹出框中将异常打印为.ToString()。这是奇怪的VS显示作为外部代码的堆栈跟踪,但我很高兴这可以看到更多关于异常的信息。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71813287

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档