【问题标题】:Unhandled Error in Silverlight Application Code: 4004 System.ArgumentException:Silverlight 应用程序代码中未处理的错误:4004 System.ArgumentException:
【发布时间】:2012-12-12 16:11:45
【问题描述】:

我正在 Silverlight 上开发一个 esri 地图项目。当我将自定义用户控件添加为元素层时,从浏览器中获取该错误:

Line: 56
Error: Unhandled Error in Silverlight Application 
Code: 4004    
Category: ManagedRuntimeError       
Message: System.ArgumentException: 
Parameter name: height
   at System.Windows.Rect..ctor(Double x, Double y, Double width, Double height)
   at ESRI.ArcGIS.Client.LayerCanvas.ArrangeOverride(Size finalSize)
   at System.Windows.FrameworkElement.ArrangeOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)     

这很奇怪,因为我没有写任何代码或其他东西。我的地图服务有效。 我认为问题发生在解析 xaml 文件时。所以;

mainpage.xaml 是:

<UserControl x:Class="tbl.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    xmlns:esri1="http://schemas.esri.com/arcgis/client/2009"
    xmlns:lcl="clr-namespace:tbl"
    d:DesignHeight="600" d:DesignWidth="800">

    <Grid x:Name="LayoutRoot" Background="White">

        <esri1:Map x:Name="esrimap">
            <esri1:ArcGISTiledMapServiceLayer Url="http://.../ArcGIS/rest/services/.../MapServer">
            </esri1:ArcGISTiledMapServiceLayer>

            <esri1:ElementLayer>
                <lcl:SilverlightControl1 esri1:ElementLayer.Envelope="495942.700915659,4509916.68364022,495942.700915659,4509916.683614022"></lcl:SilverlightControl1>
            </esri1:ElementLayer>

        </esri1:Map>
    </Grid>


</UserControl>

和silverlightcontrol.xaml:

<UserControl x:Class="tbl.SilverlightControl1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">

    <Grid x:Name="LayoutRoot" Background="White">

    </Grid>
</UserControl>

谁能帮帮我?

【问题讨论】:

    标签: silverlight xaml user-controls esri


    【解决方案1】:

    这是 ESRI 控件的 ArrangeOverride 方法中的错误。它正在尝试创建一个高度为负的System.Windows.Rect

    4-argument constructor for System.Windows.Rect 仅在宽度和/或高度为负时抛出 ArgumentException。我快速玩了一下这个结构,可以确认这一点。我还可以确认,如果高度为NaN,这个构造函数不会抛出异常,这让我很吃惊。

    【讨论】:

    • 你有更多关于那个或参考网站的信息吗?
    • @gomp: 有关Rect 构造函数或 ESRI 控件的更多信息?如果是前者,那么我链接到的 MSDN 页面的备注部分提到构造函数“不允许 widthheight 为负值”。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多