System.ArgumentNullException xamarin.forms

时间:2017-11-18 12:30:03

标签: xamarin xamarin.forms

我使用xamarin.forms开发了一个应用程序,仅在android上进行过测试。我现在开始测试iOS,我将我正在使用的所有图像从我的android资源可绘制文件夹复制到iOS资源文件夹。在模拟器上进行调试时,我的应用程序一直在破坏:" System.ArgumentNullException已被抛出。值不能为空。参数名称:图像。"

我尝试了什么

  • 我将所有图片的大小调整为100kb以下。
  • 确保xaml中的所有图像引用都以相应的结尾 png或jpg。

不确定还有什么可能导致此异常。任何帮助将不胜感激。

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"
                 x:Class="LoyaltyWorx.GridMenu"
                 BackgroundImage="grid.jpg"
                 Title="Main Menu"
                 >
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <RowDefinition Height="2*" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="1*" />
                <ColumnDefinition Width="2*" />
            </Grid.ColumnDefinitions>
            <Label Text="Cards" TextColor="White" FontAttributes="Bold" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" Grid.Row="0" Grid.Column="0" BackgroundColor="#1481BA"  Opacity="0.5" x:Name="CardTile"/>
            <Label Text="Transactions" TextColor="Black" FontAttributes="Bold" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" Grid.Row="0" Grid.Column="1" BackgroundColor="#ede890" Opacity="0.5" x:Name="TransactionTile"/>
            <Label Text="Promotions" TextColor="White" FontSize="30" FontAttributes="Bold" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" Grid.Row="1" Grid.Column="0" BackgroundColor="#1481BA" Grid.ColumnSpan="2" Opacity="0.7" x:Name="PromoTile"/>
            <Label Text="Settings" TextColor="Black" FontAttributes="Bold" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" Grid.Row="2" Grid.Column="0" BackgroundColor="#ede890" Opacity="0.5" x:Name="SettingsTile" />
            <Label Text="My Profile" TextColor="White" FontAttributes="Bold" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" Grid.Row="2" Grid.Column="1" BackgroundColor="#1481BA" Opacity="0.7" x:Name="ProfileTile"/>
        </Grid>
    </ContentPage>

1 个答案:

答案 0 :(得分:0)

我遇到了同样的错误,但是花了几个小时才能找到问题所在的图像。

我想知道如何改善错误消息,以便更轻松地查找主管图像。 我现在正在注释掉所有内容,然后逐步将更多的xaml带回来以查明问题,但这很耗时。

{System.ArgumentNullException:值不能为null。 参数名称:图像   在/Library/Frameworks/Xamarin.iOS.framework/Versions/11.14.0.14/src/Xamarin.iOS/UIKit/UIColor.g.cs:257中的UIKit.UIColor.FromPatternImage(UIKit.UIImage图像)[0x0000e]   在Xamarin.Forms.Platform.iOS.PageRenderer.UpdateBackground()[0x00019]在D:\ agent_work \ 1 \ s \ Xamarin.Forms.Platform.iOS \ Renderers \ PageRenderer.cs:261中   在Xamarin.Forms.Platform.iOS.PageRenderer.ViewDidLoad()[0x00074]在D:\ agent_work \ 1 \ s \ Xamarin.Forms.Platform.iOS \ Renderers \ PageRenderer.cs:120中   在(包装器托管到本地)ObjCRuntime.Messaging.IntPtr_objc_msgSendSuper(intptr,intptr)   在/Library/Frameworks/Xamarin.iOS.framework/Versions/11.14.0.14/src/Xamarin.iOS/UIKit/UIViewController.g.cs:2938中的UIKit.UIViewController.get_View()[0x0002a]   在Xamarin.Forms.Platform.iOS.PageRenderer.get_NativeView()[0x00000]在D:\ agent_work \ 1 \ s \ Xamarin.Forms.Platform.iOS \ Renderers \ PageRenderer.cs:41中   在Xamarin.Forms.Platform.iOS.PageRenderer.SetElement(Xamarin.Forms.VisualElement元素)[0x0004f]在D:\ agent_work \ 1 \ s \ Xamarin.Forms.Platform.iOS \ Renderers \ PageRenderer.cs:56   在Xamarin.Forms.Platform.iOS.Platform.CreateRenderer(Xamarin.Forms.VisualElement元素)[0x00014]在D:\ agent_work \ 1 \ s \ Xamarin.Forms.Platform.iOS \ Platform.cs:193中   在Xamarin.Forms.Platform.iOS.TabbedRenderer.SetupPage(Xamarin.Forms.Page页面,System.Int32索引)[0x0000a]在D:\ agent_work \ 1 \ s \ Xamarin.Forms.Platform.iOS \ Renderers \ TabbedRenderer中。 cs:286   在Da:\ agent_work \ 1 \ s \ Xamarin.Forms.Platform.iOS \ Renderers \ TabbedRenderer.cs:263中的Xamarin.Forms.Platform.iOS.TabbedRenderer.Reset()[0x0001c]   在Xamarin.Forms.Internals.NotifyCollectionChangedEventArgsExtensions.Apply(System.Collections.Specialized.NotifyCollectionChangedEventArgs自我,System.Action 3[T1,T2,T3] insert, System.Action 2 [T1,T2] removeAt,System.Action重置)[0x001e1]在D:\ agent_work \ 1 \ s \ Xamarin.Forms.Core \ Internals \ NotifyCollectionChangedEventArgsExtensions.cs:79   在Xamarin.Forms.Platform.iOS.TabbedRenderer.OnPagesChanged(System.Object sender,System.Collections.Specialized.NotifyCollectionChangedEventArgs e)[0x00000]在D:\ agent_work \ 1 \ s \ Xamarin.Forms.Platform.iOS \ Renderers \ TabbedRenderer.cs:201   在Xamarin.Forms.Platform.iOS.TabbedRenderer.SetElement(Xamarin.Forms.VisualElement元素)[0x0005b]在D:\ agent_work \ 1 \ s \ Xamarin.Forms.Platform.iOS \ Renderers \ TabbedRenderer.cs:66   在Xamarin.Forms.Platform.iOS.Platform.CreateRenderer(Xamarin.Forms.VisualElement元素)[0x00014]在D:\ agent_work \ 1 \ s \ Xamarin.Forms.Platform.iOS \ Platform.cs:193中   在Xamarin.Forms.Platform.iOS.NavigationRenderer.CreateViewControllerForPage(Xamarin.Forms.Page页面)[0x00008]在D:\ agent_work \ 1 \ s \ Xamarin.Forms.Platform.iOS \ Renderers \ NavigationRenderer.cs:350中   在Xamarin.Forms.Platform.iOS.NavigationRenderer + d__46.MoveNext()[0x00016]在D:\ agent_work \ 1 \ s \ Xamarin.Forms.Platform.iOS \ Renderers \ NavigationRenderer.cs:337中 ---从之前引发异常的位置开始的堆栈结束跟踪---   在/Library/Frameworks/Xamarin.iOS.framework/Versions/11.14.0.14/src/Xamarin.iOS/mcs/class中的System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task任务)[0x00037] /referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187   在/Library/Frameworks/Xamarin.iOS.framework/Versions/11.14.0.14/src/Xamarin.iOS/mcs/class中的System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task任务)[0x00028] /referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156   在/Library/Frameworks/Xamarin.iOS.framework/Versions/11.14.0.14/src/Xamarin.iOS/mcs/class中的System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(System.Threading.Tasks.Task任务)[0x00008] /referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128   在/Library/Frameworks/Xamarin.iOS.framework/Versions/11.14.0.14/src/Xamarin.iOS/mcs/class/referencesource/中的System.Runtime.CompilerServices.TaskAwaiter`1 [TResult] .GetResult()[0x00000] mscorlib / system / runtime / compilerservices / TaskAwaiter.cs:357   在Xamarin.Forms.Platform.iOS.NavigationRenderer + d.MoveNext()[0x00022]在D:\ agent_work \ 1 \ s \ Xamarin.Forms.Platform.iOS \ Renderers \ NavigationRenderer.cs:221中 ---从之前引发异常的位置开始的堆栈结束跟踪---   在/Library/Frameworks/Xamarin.iOS.framework/Versions/11.14.0.14/src/Xamarin.iOS/mcs/class/中的System.Runtime.CompilerServices.AsyncMethodBuilderCore + <> c.b__6_0(系统对象状态)[0x00000] referencesource / mscorlib / system / runtime / compilerservices / AsyncMethodBuilder.cs:1018   在/Library/Frameworks/Xamarin.iOS.framework/Versions/11.14.0.14/src/Xamarin.iOS/Foundation/NSAction.cs:178中的Foundation.NSAsyncSynchronizationContextDispatcher.Apply()[0x00000]中   在(包装器托管到本地)UIKit.UIApplication.UIApplicationMain(int,string [],intptr,intptr)   在/Library/Frameworks/Xamarin.iOS.framework/Versions/11.14.0.14/src/Xamarin.iOS中的UIKit.UIApplication.Main(System.String [] args,System.IntPtr主体,System.IntPtr委托)[0x00005] /UIKit/UIApplication.cs:79   在/Library/Frameworks/Xamarin.iOS.framework/Versions/11.14.0.14/src/Xamarin.iOS中的UIKit.UIApplication.Main(System.String [] args,System.StringPrincipalClassName,System.String委托ClassName)[0x0002c] /UIKit/UIApplication.cs:63   在WheelFlow.App.iOS.Application.Main(System.String [] args)[0x00001]位于C:\ repositories \ WheelFlow \ WheelFlow.App \ WheelFlow.App.iOS \ Main.cs:17}