Upgrading Silver Light Viewer 1.0 gto 3.0

587
6
01-21-2013 06:25 AM
HowardJohnson
New Contributor
Subject: Extension Load Failed.

After installation when I bring up the application Builder I recieve and the following.

"Could not load file assmeblly ERIS.ArGIS.Client.Extensibilty. version = 3.0.0.91 Culture = neutral
Public Key Token = 8fc3cc631c44ad86 or one of its dependecies.
The requested assembly version conflicts with what is already bound in the map app domain or specified in the manifest.
Exception from HRESULT : 0x80131053 could not load file assembly.


Please assit. It appears after doing the upgrade i need to move or edit this file extension but I am not sure.

P.S I am not concerned about upgrading the old Appllications and API'S  I going to rebuild everthing new.

Thank You
0 Kudos
6 Replies
Keithzammit
New Contributor
Hey,
I know it's been over a year but I am now faced with the same problem you had seen.
had you found a solution to the problem?

Regards,
Keith
0 Kudos
PietaSwanepoel2
Occasional Contributor
Might be easier to just redo the viewers than trying to find the reason. The file structures have changed most likely.
If you are going to redo it, why don't you just upgrade to version 3.2. Then it is over and done with
0 Kudos
Keithzammit
New Contributor
I am trying to do a complete redesign yet now I'm getting a very strange error in silverlight. I am trying to develop a customizable time slider, and silverlight is throwing on error on function :

Method not found: 'Void ESRI.ArcGIS.Client.Extensibility.MapApplication.ShowWindow(System.String, System.Windows.FrameworkElement, Boolean, System.EventHandler`1<System.ComponentModel.CancelEventArgs>, System.EventHandler, ESRI.ArcGIS.Client.Extensibility.WindowType)'.

at System.Windows.dll.JoltHelper.FireEvent  (IL offset: 0x13b)
at System.Windows.dll.Control.OnMouseLeftButtonUp  (IL offset: 0x0)
at System.Windows.dll.ButtonBase.OnMouseLeftButtonUp  (IL offset: 0x48)
at System.Windows.dll.Button.OnClick  (IL offset: 0x19)
at System.Windows.dll.ButtonBase.OnClick  (IL offset: 0x1f)
at System.Windows.dll.ButtonBase.ExecuteCommand  (IL offset: 0x1a)
at <Unknown>.TimeSliderTool.Execute  (IL offset: 0xffffffff)

I have put my code below:

TimeSliderTool.cs
using System;
using System.ComponentModel.Composition;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using ESRI.ArcGIS.Client.Extensibility;
using ESRI.ArcGIS.Client;

namespace TimeSlider.AddIns
{
    [Export(typeof(ICommand))]
    [DisplayName("Time Slider Tool")]
    public class TimeSliderTool : ICommand
    {
        
       
        #region ICommand members
        public void Execute(object parameter)
        {
            
            MapApplication.Current.ShowWindow("Time Slider   " + MapApplication.Current.SelectedLayer.DisplayName, new TimeSliderWindow());
        }

        public bool CanExecute(object parameter)
        {
            ESRI.ArcGIS.Client.FeatureLayer layer = MapApplication.Current.SelectedLayer as ESRI.ArcGIS.Client.FeatureLayer;

            if (layer == null)
            {
                return true;
            }
            else
            {
                if (layer.TimeExtent == null)
                {
                    return true;
                }
                else
                {
                    return true;
                }
            }
        }

        public event EventHandler CanExecuteChanged;

        #endregion
    }
}


TimeSliderWindow.xaml
<UserControl xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"  xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"  xmlns:esri="http://schemas.esri.com/arcgis/client/2009"  x:Class="TimeSlider.AddIns.TimeSliderWindow"
    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="84" d:DesignWidth="681">

    <Grid x:Name="LayoutRoot" Background="Transparent" Height="80" Width="676">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="30*" />
            <ColumnDefinition Width="646*" />
        </Grid.ColumnDefinitions>
        <toolkit:BureauBlackTheme Grid.ColumnSpan="2" Margin="7,0,7,20" />
        <StackPanel Orientation="Vertical" Grid.ColumnSpan="2">

            <StackPanel Orientation="Horizontal" Margin="0,0,0,1" Grid.ColumnSpan="3" HorizontalAlignment="Left" Width="675" Height="60">
                <esri:TimeSlider x:Name="_timeSlider" HorizontalAlignment="Left" Margin="15" VerticalAlignment="Top" Width="600" Height="30"
              TimeMode="TimeExtent"
                                MinimumValue="{Binding Layer.TimeExtent.Start, Mode=OneWay}" 
                 MaximumValue="{Binding Layer.TimeExtent.End, Mode=OneWay}"
                                Value="{Binding Map.TimeExtent, Mode=TwoWay}" ValueChanged="_timeSlider_ValueChanged" >
                </esri:TimeSlider>
                <Button Width="30" Height="30" FontSize="20" Click="Config_Click">
                    <StackPanel Orientation="Horizontal" Height="20" Width="20">
                        <Image Source="http://###/Apps/Test_Air/Images/config_icon.png" />
                    </StackPanel>
                </Button>
            </StackPanel>
            <StackPanel Height="17" Width="663">
                <sdk:Label Name="_currentTime" Height="15" HorizontalAlignment="Center" HorizontalContentAlignment="Center"/>
            </StackPanel>
        </StackPanel>
    </Grid>
</UserControl>
0 Kudos
Keithzammit
New Contributor
TimeSliderWindow.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using ESRI.ArcGIS.Client;
using ESRI.ArcGIS.Client.Extensibility;

namespace TimeSlider.AddIns
{
    public partial class TimeSliderWindow : UserControl
    {

        public Layer Layer
        {
            get
            {
                return MapApplication.Current.SelectedLayer as ESRI.ArcGIS.Client.FeatureLayer;
            }
        }

        public Map Map
        {
            get
            {
                return MapApplication.Current.Map;
            }
        }

        public int CurrentType
        {
            get;
            set;
        }

        public string CurrentNumber
        {
            get;
            set;
        }

        public TimeExtent DefaultTimeExtent
        {
            get
            {
                ESRI.ArcGIS.Client.FeatureLayer layer = Layer as ESRI.ArcGIS.Client.FeatureLayer;
                return layer.TimeExtent;
            }
        }

        public IEnumerable<DateTime> DefaultIntervals
        {
            get
            {
                return ESRI.ArcGIS.Client.Toolkit.TimeSlider.CreateTimeStopsByTimeInterval(DefaultTimeExtent, TimeSpan.FromDays(1));
            }
        }

        public TimeExtent DefaultSliderValue
        {
            get
            {
                ESRI.ArcGIS.Client.FeatureLayer layer = Layer as ESRI.ArcGIS.Client.FeatureLayer;
                return new TimeExtent(layer.TimeExtent.Start, layer.TimeExtent.Start.AddDays(1));
            }
        }

        public DateTime DefaultStart
        {
            get
            {
                ESRI.ArcGIS.Client.FeatureLayer layer = Layer as ESRI.ArcGIS.Client.FeatureLayer;
                return layer.TimeExtent.Start;
            }
        }

        public DateTime DefaultEnd
        {
            get
            {
                ESRI.ArcGIS.Client.FeatureLayer layer = Layer as ESRI.ArcGIS.Client.FeatureLayer;
                return layer.TimeExtent.End;
            }
        }

        public TimeExtent UpdatedValue
        {
            get;
            set;
        }

        public TimeSliderWindow()
        {
            InitializeComponent();
            _timeSlider.MinimumValue = DefaultStart;
            _timeSlider.MaximumValue = DefaultEnd;
            _timeSlider.Intervals = DefaultIntervals;
            _timeSlider.Value = DefaultSliderValue;
            CurrentNumber = "1";
            CurrentType = 1;
        }


        private void Config_Click(object sender, RoutedEventArgs e)
        {
            ConfigurationWindow config = new ConfigurationWindow(this);
            DateTime storeStartDate = new DateTime(_timeSlider.MinimumValue.Year, _timeSlider.MinimumValue.Month,
                _timeSlider.MinimumValue.Day, _timeSlider.MinimumValue.Hour, _timeSlider.MinimumValue.Minute, _timeSlider.MinimumValue.Second);
            DateTime storeEndDate = new DateTime(_timeSlider.MaximumValue.Year, _timeSlider.MaximumValue.Month,
               _timeSlider.MaximumValue.Day, _timeSlider.MaximumValue.Hour, _timeSlider.MaximumValue.Minute, _timeSlider.MaximumValue.Second);
            config._startDatePicker.SelectedDate = storeStartDate;
            config._endDatePicker.SelectedDate = storeEndDate;
            config._startTimePicker.Value = storeStartDate;
            config._endTimePicker.Value = storeEndDate;
            config._typeSelect.SelectedIndex = CurrentType;
            config._numberText.Text = CurrentNumber;
            config._startDatePicker.DisplayDateStart = DefaultTimeExtent.Start;
            config._startDatePicker.DisplayDateEnd = DefaultTimeExtent.End;
            config._endDatePicker.DisplayDateStart = DefaultTimeExtent.Start;
            config._endDatePicker.DisplayDateEnd = DefaultTimeExtent.End;
            config.Show();
        }

        private bool checkDateRange(DateTime start, DateTime end)
        {
            if (start >= DefaultTimeExtent.Start && start <= DefaultTimeExtent.End && end >= DefaultTimeExtent.Start
                && end <= DefaultTimeExtent.End)
            {
                if (start > end)
                {
                    new ErrorWindow("End date/time cannot be before the start date/time.").Show();
                    return false;
                }
            }
            else
            {
                new ErrorWindow("Invalid time extent for the current selected layer.").Show();
                return false;
            }
            return true;
        }

        public bool accessSlider(DateTime start, DateTime end, string number, string type)
        {
            if (!checkDateRange(start, end))
            {
                return false;
            }
            else
            {
                TimeExtent extent = new TimeExtent(start, end);
                IEnumerable<DateTime> intervals = generateIntervals(start, end, number, type, extent);
                updateSlider(intervals, start, end);
                return true;
            }
        }

        private IEnumerable<DateTime> generateIntervals(DateTime start, DateTime end, string number, string type, TimeExtent extent)
        {
            switch (type)
            {
                case "Week":
                    CurrentNumber = number;
                    CurrentType = 0;
                    UpdatedValue = new TimeExtent(start, start.AddDays(Convert.ToInt32(number) * 7));
                    return ESRI.ArcGIS.Client.Toolkit.TimeSlider.CreateTimeStopsByTimeInterval(extent, TimeSpan.FromDays(Convert.ToInt32(number) * 7));
                case "Day":
                    CurrentNumber = number;
                    CurrentType = 1;
                    UpdatedValue = new TimeExtent(start, start.AddDays(Convert.ToInt32(number)));
                    return ESRI.ArcGIS.Client.Toolkit.TimeSlider.CreateTimeStopsByTimeInterval(extent, TimeSpan.FromDays(Convert.ToInt32(number)));
                case "Hour":
                    CurrentNumber = number;
                    CurrentType = 2;
                    UpdatedValue = new TimeExtent(start, start.AddHours(Convert.ToInt32(number)));
                    return ESRI.ArcGIS.Client.Toolkit.TimeSlider.CreateTimeStopsByTimeInterval(extent, TimeSpan.FromHours(Convert.ToInt32(number)));
                case "Minute":
                    CurrentNumber = number;
                    CurrentType = 3;
                    UpdatedValue = new TimeExtent(start, start.AddMinutes(Convert.ToInt32(number)));
                    return ESRI.ArcGIS.Client.Toolkit.TimeSlider.CreateTimeStopsByTimeInterval(extent, TimeSpan.FromMinutes(Convert.ToInt32(number)));
                default:
                    CurrentNumber = "1";
                    CurrentType = 1;
                    UpdatedValue = DefaultSliderValue;
                    return DefaultIntervals;
            }
        }

        private void updateSlider(IEnumerable<DateTime> intervals, DateTime start, DateTime end)
        {
            _timeSlider.MinimumValue = start;
            _timeSlider.MaximumValue = end;
            _timeSlider.Intervals = intervals;
            _timeSlider.Value = UpdatedValue;
        }

        private void _timeSlider_ValueChanged(object sender, ESRI.ArcGIS.Client.Toolkit.TimeSlider.ValueChangedEventArgs e)
        {
            Map.TimeExtent = new TimeExtent();
            Map.TimeExtent.Start = _timeSlider.Value.Start;
            Map.TimeExtent.End = _timeSlider.Value.End;
            _currentTime.Content = "Time: FROM  " + TimeZoneInfo.ConvertTime(_timeSlider.Value.Start, TimeZoneInfo.Utc).ToString() + "  TO  " + TimeZoneInfo.ConvertTime(_timeSlider.Value.End, TimeZoneInfo.Utc).ToString();
        }
    }
}
0 Kudos
Keithzammit
New Contributor
ConfigurationWindow.xaml
<controls:ChildWindow xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"  xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"  x:Class="TimeSlider.AddIns.ConfigurationWindow"
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
           Width="403" Height="321" 
           Title="Time Slider Configuration">
    <Grid x:Name="LayoutRoot" Margin="2">
        
        <Grid.RowDefinitions>
            <RowDefinition Height="245*" />
            <RowDefinition Height="37" />
        </Grid.RowDefinitions>
        
        <toolkit:BureauBlackTheme Margin="0,0,-9,-10" Grid.RowSpan="2" />
        <Button x:Name="CancelButton" Content="Cancel" Click="CancelButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,6,0,8" Grid.Row="1" />
        <Button x:Name="OKButton" Content="OK" Click="OKButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,6,79,8" Grid.Row="1" />

        <StackPanel Height="29" Name="StartPanel" Width="346" Orientation="Horizontal" Margin="18,0,16,170" VerticalAlignment="Bottom">
            <sdk:Label Height="25" Name="_startLabel" Width="76" Content="Start Time:" Foreground="White" />
            <sdk:DatePicker Height="23" Name="_startDatePicker" Width="120" />
            <sdk:Label Height="23" Name="label5" Width="12" Content=" |" />
            <toolkit:TimePicker Height="24" Name="_startTimePicker" PopupMinutesInterval="15" Foreground="White" />
        </StackPanel>

        <StackPanel Height="29" Name="EndPanel" Width="346" Orientation="Horizontal" Margin="18,0,16,135" VerticalAlignment="Bottom">
            <sdk:Label Height="25" Name="_endLabel" Width="76" Content="End Time:" Foreground="White" />
            <sdk:DatePicker Height="23" Name="_endDatePicker" Width="120" />
            <sdk:Label Height="23" Name="label6" Width="12" Content=" |" />
            <toolkit:TimePicker Height="24" Name="_endTimePicker" PopupMinutesInterval="15" Foreground="White" />
        </StackPanel>
        <StackPanel Height="25" HorizontalAlignment="Left" Margin="18,12,0,0" Name="stackPanel1" VerticalAlignment="Top" Width="346">
            <sdk:Label Height="19" Name="label1" Width="116" Content="Time Span" FontSize="14" HorizontalAlignment="Center" FontWeight="SemiBold" Foreground="White" />
        </StackPanel>
        <StackPanel Height="24" HorizontalAlignment="Left" Margin="12,135,0,0" Name="stackPanel2" VerticalAlignment="Top" Width="352">
            <sdk:Label Height="30" Name="label2" Width="185" Content="Time Display Intervals" FontSize="14" FontWeight="SemiBold" HorizontalAlignment="Center" Foreground="White" />
        </StackPanel>
        <StackPanel Height="32" HorizontalAlignment="Left" Margin="18,171,0,0" Name="stackPanel3" VerticalAlignment="Top" Width="346" Orientation="Horizontal">
            <TextBox Height="24" Name="_numberText" Width="36" Text="1" />
            <sdk:Label Height="27" Name="label3" Width="20" Content="  |" DataContext="{Binding}" />
            <ComboBox Height="23" Name="_typeSelect" Width="120" VerticalAlignment="Center">
                <ComboBoxItem Content="Week" />
                <ComboBoxItem Content="Day" />
                <ComboBoxItem Content="Hour" />
                <ComboBoxItem Content="Minute" />
            </ComboBox>
        </StackPanel>
        <Border BorderBrush="White" BorderThickness="2" Height="113" HorizontalAlignment="Left" Margin="8,6,0,0" Name="border1" VerticalAlignment="Top" Width="363">
        </Border>
        <Border BorderBrush="White" BorderThickness="2" Height="99" HorizontalAlignment="Left" Margin="8,125,0,0" Name="border2" VerticalAlignment="Top" Width="363">
        </Border>
    </Grid>
</controls:ChildWindow>

ConfigurationWindow.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using ESRI.ArcGIS.Client.Extensibility;

namespace TimeSlider.AddIns
{
    public partial class ConfigurationWindow : ChildWindow
    {
        private TimeSliderWindow timeSlider;

        public ConfigurationWindow(TimeSliderWindow timeSlider)
        {
            InitializeComponent();
            this.timeSlider = timeSlider;
        }

        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            DateTime selectedStartDateTime = DateTime.MinValue;
            DateTime selectedEndDateTime = DateTime.MaxValue;
            string number;
            string type;

            if (_startDatePicker.SelectedDate != null && _startTimePicker.Value != null)
            {
                DateTime selStartDate = _startDatePicker.SelectedDate.Value;
                DateTime? tempTime = _startTimePicker.Value;
                DateTime selTime = tempTime.Value;
                TimeSpan timeOfStartDay = selTime.TimeOfDay;
                selectedStartDateTime = new DateTime(selStartDate.Year, selStartDate.Month, selStartDate.Day,
                    timeOfStartDay.Hours, timeOfStartDay.Minutes, timeOfStartDay.Seconds);
            }

            if (_endDatePicker.SelectedDate != null && _endTimePicker.Value != null)
            {
                DateTime selEndDate = _endDatePicker.SelectedDate.Value;
                DateTime? tempTime = _endTimePicker.Value;
                DateTime selTime = tempTime.Value;
                TimeSpan timeOfEndDay = selTime.TimeOfDay;
                selectedEndDateTime = new DateTime(selEndDate.Year, selEndDate.Month, selEndDate.Day,
                    timeOfEndDay.Hours, timeOfEndDay.Minutes, timeOfEndDay.Seconds);
            }

            number = _numberText.Text;
            type = _typeSelect.SelectionBoxItem.ToString();

            if (selectedStartDateTime != DateTime.MinValue && selectedEndDateTime != DateTime.MaxValue)
            {
                updateSlider(selectedStartDateTime, selectedEndDateTime, number, type);
            }
        }

        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        private void updateSlider(DateTime start, DateTime end, string inputNo, string inputString)
        {
            bool check = timeSlider.accessSlider(start, end, inputNo, inputString);
            if (check)
            {
                this.Close();
            }
        }
    }
}



ErrorWindow.xaml
<controls:ChildWindow xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"  x:Class="TimeSlider.AddIns.ErrorWindow"
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
           Width="400" Height="155" 
           Title="Error">
    <Grid x:Name="LayoutRoot" Margin="2">
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <toolkit:BureauBlackTheme Grid.RowSpan="2" />
        <Button x:Name="OKButton" Content="OK" Click="OKButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,0,12,12" Grid.Row="1" />
        <StackPanel Height="81" HorizontalAlignment="Left" Name="stackPanel1" VerticalAlignment="Top" Width="378"></StackPanel>
        <StackPanel Name="stackPanel2" Margin="12,11,209,25" Grid.RowSpan="2">
            <Image Height="66" Name="image1" Stretch="Fill" Width="128" Source="http://###/Apps/Test_Air/Images/error.png" />
        </StackPanel>
        <StackPanel Height="71" Name="stackPanel3" Margin="176,6,0,4">
            <TextBlock Height="66" Name="_errorText" Text="Error text goes here" Foreground="White" FontSize="14" TextAlignment="Left" TextTrimming="None" TextWrapping="Wrap" Width="190" />
        </StackPanel>
    </Grid>
</controls:ChildWindow>


ErrorWindow.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace TimeSlider.AddIns
{
    public partial class ErrorWindow : ChildWindow
    {
        public ErrorWindow(String error)
        {
            InitializeComponent();
            _errorText.Text = error;
        }

        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = true;
        }

        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
        }
    }
}
0 Kudos
Keithzammit
New Contributor
Sorry had to split it into 4 posts. This should compile and work but for some reason it doesn't 😞

If you could maybe point me in the right direction or see what I did wrong it would really help!

If I replace the code in TimeSliderTool.cs to one similar to what ESRI provides in its timeslider example, loading of the viewer hangs when it does : GET TimeSlider.AddIns.xap

the code i replaced:

TimeSliderTool.cs
public class TimeSliderTool : ICommand
    {
        private TimeSliderWindow timeSliderUI = new TimeSliderWindow(); //from ESRI EXAMPLE
       
        #region ICommand members
        public void Execute(object parameter)
        {
            timeSliderUI = new TimeSliderWindow(); //from ESRI EXAMPLE
            MapApplication.Current.ShowWindow("Time Slider", timeSliderUI); //from ESRI EXAMPLE
            //MapApplication.Current.ShowWindow("Time Slider", new TimeSliderWindow(),false,null,null,WindowType.Floating);
        }


Thanks
Keith
0 Kudos