Select to view content in your preferred language

SimpleMarkerSymbol Exception in Silverlight

2112
2
04-28-2010 06:13 AM
DouglasZedler
Occasional Contributor
I'm playing with a Silverlight app in Visual Studio so that I can learn programming with the API for Silverlight.  I created a feature layer that points to a fire stations map service on our ArcGIS Server.  I'm following the example in the getting started pages for creating a symbol in the Grid.Resources tag and using it as a static resource for the FeatureSymbol property of the FeatureLayer.  When I comment out the SimpleMarkerSymbol tag in Grid.Resources, it builds fine, but won't run because it can't find the reference to MyMarkerSymbol.  When I include the SimpleMarkerSymbol tag in Grid.Resources, I get a build error.  Below are the error and my code.  Any help would be appreciated.

Thanks,
Doug

Error:

Error 1 The "ValidateXaml" task failed unexpectedly.
System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime.Serialization, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified.
File name: 'System.Runtime.Serialization, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'
   at System.ModuleHandle.ResolveType(Int32 typeToken, RuntimeTypeHandle* typeInstArgs, Int32 typeInstCount, RuntimeTypeHandle* methodInstArgs, Int32 methodInstCount)
   at System.ModuleHandle.ResolveTypeHandle(Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
   at System.Reflection.Module.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
   at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, Module decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, RuntimeMethodHandle& ctor, Boolean& ctorHasParameters, Boolean& isVarArg)
   at System.Reflection.CustomAttribute.GetCustomAttributes(Module decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes)
   at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeType type, RuntimeType caType, Boolean inherit)
   at System.RuntimeType.GetCustomAttributes(Type attributeType, Boolean inherit)
   at MS.Internal.Xaml.Schema.ClrType.GetCustomAttribute(Type attrType)
   at MS.Internal.Xaml.Schema.ClrType.LookupRuntimeNameProperty()
   at MS.Internal.Xaml.Schema.ClrType.LookupPropertyValue(NonBoolTypeValidBits typeBit)
   at MS.Internal.Xaml.Schema.ClrType.get_RuntimeNamePropertyCore()
   at MS.Internal.Xaml.Parser.XamlAttribute.Initialize(XamlParserContext context, XamlType ownerType, XamlNamespace ownerNamespace)
   at MS.Internal.Xaml.Parser.XamlScanner.PostprocessAttributes(XamlScannerNode node)
   at MS.Internal.Xaml.Parser.XamlScanner.ReadObjectElement(XamlName name, Boolean isEmptyTag)
   at MS.Internal.Xaml.Parser.XamlScanner.ReadElement()
   at MS.Internal.Xaml.Parser.XamlScanner.DoXmlRead()
   at MS.Internal.Xaml.Parser.XamlScanner.Read()
   at MS.Internal.Xaml.Parser.XamlPullParser.<P_PropertyElement>d__31.MoveNext()
   at MS.Internal.Xaml.Parser.XamlPullParser.<P_ElementBody>d__23.MoveNext()
   at MS.Internal.Xaml.Parser.XamlPullParser.<P_Element>d__7.MoveNext()
   at MS.Internal.Xaml.Parser.XamlPullParser.<P_ElementContent>d__39.MoveNext()
   at MS.Internal.Xaml.Parser.XamlPullParser.<P_ElementBody>d__23.MoveNext()
   at MS.Internal.Xaml.Parser.XamlPullParser.<P_Element>d__7.MoveNext()
   at MS.Internal.Xaml.Parser.XamlPullParser.<Parse>d__0.MoveNext()
   at MS.Internal.Xaml.TextReaderEnumerator.MoveNext()
   at MS.Internal.Xaml.XamlTextReader.Read()
   at MS.MarkupCompiler.ValidationPass.ValidateXaml(String fileName, Assembly[] assemblies, Assembly callingAssembly, TaskLoggingHelper log, Boolean shouldThrow)
   at Microsoft.Silverlight.Build.Tasks.ValidateXaml.XamlValidator.Execute()
   at Microsoft.Silverlight.Build.Tasks.ValidateXaml.XamlValidator.Execute()
   at Microsoft.Silverlight.Build.Tasks.ValidateXaml.Execute()
   at Microsoft.Build.BuildEngine.TaskEngine.ExecuteInstantiatedTask(EngineProxy engineProxy, ItemBucket bucket, TaskExecutionMode howToExecuteTask, ITask task, Boolean& taskResult)

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
ArcGISSilverlight


Here's my code:

<UserControl x:Class="ArcGISSilverlight.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"
    xmlns:esri="clr-namespace:ESRI.ArcGIS.Client;assembly=ESRI.ArcGIS.Client"
    xmlns:esriGeometry="clr-namespace:ESRI.ArcGIS.Client.Geometry;assembly=ESRI.ArcGIS.Client"
    xmlns:esriBehaviors="clr-namespace:ESRI.ArcGIS.Client.Actions;assembly=ESRI.ArcGIS.Client.Behaviors"
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:esriSymbols="clr-namespace:ESRI.ArcGIS.Client.Symbols;assembly=ESRI.ArcGIS.Client"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">
    <Grid x:Name="LayoutRoot">

        <Grid.RowDefinitions>
        <RowDefinition/>
        <RowDefinition Height="50"/>
       </Grid.RowDefinitions>
        <Grid.Resources>
            <esriSymbols:SimpleMarkerSymbol x:Name="MyMarkerSymbol" Style="Diamond" Color="Azure" Size="14" />
        </Grid.Resources>
        <esri:Map x:Name="MyMap" Extent="-97.599, 32.53, -97.023, 33.064" ZoomDuration="00:00:00.5" PanDuration="00:00:00.5">
            <esri:ArcGISTiledMapServiceLayer ID="StreetMapLayer"
                Url="http://server.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer"/>
            <esri:FeatureLayer ID="FireStationsLayer"
                Url="http://myserver/AGS/rest/services/FireStations/MapServer/1"
                Where="STATION = 1" FeatureSymbol="{StaticResource MyMarkerSymbol}" >
                <esri:FeatureLayer.OutFields>
                    <sys:String>STATION</sys:String>
                </esri:FeatureLayer.OutFields>
            </esri:FeatureLayer>
        </esri:Map>
    </Grid>
</UserControl>
0 Kudos
2 Replies
DouglasZedler
Occasional Contributor
Nevermind.  Just had to add a reference to System.Runtime.Serialization.  Duh.
0 Kudos
DominiqueBroux
Esri Frequent Contributor
0 Kudos