This is a migrated thread and some comments may be shown as answers.

Exception on ReadAsync() (RadMap control)

11 Answers 102 Views
Map
This is a migrated thread and some comments may be shown as answers.
טלי
Top achievements
Rank 1
טלי asked on 23 Oct 2017, 12:54 PM

Hi,

We are using the RadMap control (v. 4.0.30319) in a MVVM WPF project .

In some cases we encounter an exception on the AsyncShapeFileReader while calling ReadAsync()

Exception Message: collection was modified; enumeration operation may not execute

Telerik.windows.controls.Map.MapShapeDataVirtualizationSource.QueryItems ( line 440)

I thought it was a cross-threading problem and inserted some changes in my code :

- calling this.Dispatcher.Invoke((Action)(() => AsyncShapeFileReaderObj. ReadAsync() ));       

- using async/ await

but both changes did not solved the problem and the exception still rize.

what could be the problem? Do you have another idea how can i solved it? 

The Main thread is calling the ReadAsync() and the other threads that i could see are background workers of Telerik's Map ...

Thanks,

Tali

 

 

 

11 Answers, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 25 Oct 2017, 08:59 AM
Hi Tali,

Could you please double check your application if it uses any background workers or parallel code ? We have a single similar report for the same exception in the QueryItems method (reproted once in 2014):

private void QueryItems(object state)
        {
            MapItemsRequestEventArgs e = state as MapItemsRequestEventArgs;
 
            var query = from ExtendedDataProvider item in this.InternalCache
                        where MapShapeDataVirtualizationSource.ShouldBeAdded(e.Region, item, e.MinZoom, this.Resolution)
                        select item;
 
            var shapes = query.ToList();
 
            e.CompleteItemsRequest(shapes);
        }

Our client built the source code of the RadMap locally and added a lock:
private void QueryItems(object state)
        {
            MapItemsRequestEventArgs e = state as MapItemsRequestEventArgs;
  
            var query = from ExtendedDataProvider item in this.InternalCache
                        where MapShapeDataVirtualizationSource.ShouldBeAdded(e.Region, item, e.MinZoom, this.Resolution)
                        select item;
 ///put a lock here
lock ((this.InternalCache as ICollection).SynchRoot)
{
            var shapes = query.ToList()
}
  
            e.CompleteItemsRequest(shapes);
        }

......
In other method:
lock ((this.ShapeVirtualSource.InternalCache as ICollection).SynchRoot)
{
this.ShapeReader.Source = readRequest.Shapes;
this.ShapeReader.ReadAsync(readRequest.OnCompleted);
}



Regards,
Petar Mladenov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
טלי
Top achievements
Rank 1
answered on 13 Nov 2017, 09:19 AM

Petar, Thanks for your reply !

I did the changes you recommended locally in the Telerik's Map control source code,

but i am having some compilation error while building the DataVisualization_WPF's  solution:

- On the GenericModern_x.xaml : I got an error description of "The tag 'ModernColors' does not exist in XML namespace..."

- On the Map_Buttons_Office2013_Style.xaml : I got an error description of "The type reference cannot find a public type named 'RadButton'"

The RadControls source code files that we have are of version 2013_3_1316 .
When i replaced the Telerik's dlls reference  to the ones of the 2014 version (2014_2_0721) i got other errors...
How can i fix those errors in order to reproduce the new fixed Telerik's dlls?

Where can i find some documentation about manually updating the Telerik's dlls ?
Thanks in advance for your support!

Regards,

Tali

 

0
Petar Mladenov
Telerik team
answered on 15 Nov 2017, 04:35 PM
Hello Tali,

Please refer to your Telerik UI for WPF installation folder and find ReadMe.rtf file which contains list of steps / instructions for building the source code. Also they refer files from Build\\BuildInstructions folder - so navigate to it too, to find detailed rtf files for every step / instruction. 

Regards,
Petar Mladenov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Hila
Top achievements
Rank 1
answered on 10 Dec 2017, 09:52 AM
Hi Petar,

We have downloaded a new version of Telerik's product - version 2015_1_0401
and changed your source code as recommended (and as described on the BuildInstructions files) in order to solve the exception that arise in our system as a result the rad map using.
we built your dll as needed - the control+data as well as the other controls that are used in our system
but after we replaced the old telerik' dlls with the new one
our system compiled ok and started to run but on beginning of run time some XamlParseException exceptions were thrown.
Our application run OK with the old telerik's dll but with the updated version we have a lot of problems 
and we did not succeeded to make our application run again.
We deleted the bin/obj directories, restarted th Visual Studio, did some clean and rebuild again and again,
even deleted the project's .suo file but unfortunately nothing seems to work.
What should we do in order to make things working??
Thanks,
Tali   

0
Stefan
Telerik team
answered on 14 Dec 2017, 07:25 AM
Hello Hila,

Generally, in case the XamlParseExceptions are raised for a given assembly, most probably the binaries are not with the same version. Can you please double check this? Also, can you also verify that there aren't references added to both standard and NoXAML binaries?

Best Regards,
Stefan
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Hila
Top achievements
Rank 1
answered on 17 Dec 2017, 11:53 AM

Hi Stefan,

Thanks for your reply!

I have checked all the Telerik's references in all our projects and all the control's version are of 2015.1.2403.45 and are of NoXaml

binaries except Telerik.Windows.Controls.Charting.dll that when building it had no option to build as NoXaml.

Also, regards to the theme's dlls - when i build the Themes.Implicit_WPF as Realese345.NoXaml all the dlls are of version 0.0.0.0 

and in their file description there is no "(No Xaml)"  addition.

Is this wrong??

I think the problem might be regards to the Themes since it says that the ResourceDictionary cannot be resolved.

What can i do to fix that?

 

 

 

 

0
Petar Mladenov
Telerik team
answered on 20 Dec 2017, 01:12 PM
Hello Hila,

What was the previous version of UI for WPF that you used ? Could you please double check the following that you don't replace current version with older one ? This might be a possible reason that some custom styles do not work with older API (properties / commands / keys in XAML dictionaries). Also you can check the output of Visual Studio for more meaningful error messages.

Regards,
Petar Mladenov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Hila
Top achievements
Rank 1
answered on 24 Dec 2017, 10:46 AM

Hi Petar,

The old version of the control's and the themes dlls that we used before was 2014.2.0721.45. They were all also of a NoXaml type. 

We removed those old references since we discovered a bug in the Telerik's Map control.

We reproduced the new dlls based on version 2015.1.401 - We changed the source code and built it all to get the new dlls   . The dlls that we finally used were rebuilt for WPF45 NoXaml Binaries and are of version 2015.1.2403.45  . 

We are using the MVVM architecture

We first built the source of the Core_WPF solution in order to get the 
Telerik.Windows.Controls.dll and Telerik.Windows.Data.dll and afterwards we build the needed controls that are being used in our  solution. All the sources of the controls are for WPF configured as Release45.NoXaml

We added those new references to our solution and added the themes references as well (The themes were also created by the new built using the source code of Themes_Implicit_WPF):

Telerik.Windows.Themes.Summer, Telerik.Windows.Themes.Office_Black etc..

Our application worked before with the old version but with the new version after some changing it compiled well but on running we can an exception in the first line of app.xaml line1.

We cleaned again and again our solution, rebuilt , closed VS and even restarted the computer for some times.

We removed all the references and deleted all the bin and obj folders and tried adding everything from the start but it doesn't work yet.

While running our application i am getting an error of:

(On Run Time -) XamlParseException: Shared attribute in namespace 'http://schemas.microsoft.com/winfx/2006/xaml' can be used only in compiled resource dictionaries.- this exception is regards to a resource dictionary (in our sources called ThemeBase.xaml) that defined in the merged dictionaries section in the app.xaml file:

in App.xaml:

<Application x:Class="MyApp"

....

<Application.Resources>

<ResourceDictionary>

<ResourceDictionary.MergedDictionaries>

<ResourceDictionary Source=".../Styles/ThemeBase.xaml"/>

</ResourceDictionary.MergedDictionaries>

</ResourceDictionary>

</Application.Resources>

</Application>

ThemeBase.xaml (Build Action=Page):  

<ResourceDictionary xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"

xmlns:dac="clr-namespace:XXX;assembly=XXX"

xmlns:ribbonProps="clr-namespace:YYY.Properties;assembly=YYY"

<ResourceDictionary.MergedDictionaries>

<ResourceDictionary Source=".../Telerik.Windows.Themes.Summer;component/Themes/Telerik.Windows.Controls.xaml"/>

<ResourceDictionary Source=".../Telerik.Windows.Themes.Summer;component/Themes/System.Windows.xaml"/>

<ResourceDictionary Source=".../Telerik.Windows.Themes.Summer;component/Themes/Telerik.Windows.Controls.Input.xaml"/>

<ResourceDictionary Source=".../Telerik.Windows.Themes.Summer;component/Themes/Telerik.Windows.Controls.Navigation.xaml"/>

<ResourceDictionary Source=".../Telerik.Windows.Themes.Summer;component/Themes/Telerik.Windows.Controls.Data.xaml"/>

<ResourceDictionary Source=".../Telerik.Windows.Themes.Summer;component/Themes/Telerik.Windows.Controls.Documents.xaml"/>

<ResourceDictionary Source=".../Telerik.Windows.Themes.Summer;component/Themes/Telerik.Windows.Controls.Cloud.Controls.xaml"/>

Source=".../Telerik.Windows.Themes.Summer;component/Themes/Telerik.Windows.Controls.Chart.xaml"/>

Source=".../Telerik.Windows.Themes.Summer;component/Themes/Telerik.Windows.Controls.Docking.xaml"/>

Source=".../Telerik.Windows.Themes.Summer;component/Themes/Telerik.Windows.Controls.GridView.xaml"/>

Source=".../Telerik.Windows.Themes.Summer;component/Themes/Telerik.Windows.Controls.RibbonView.xaml"/>

Source=".../Telerik.Windows.Themes.Summer;component/Themes/Telerik.Windows.Controls.RichTextBoxUI.xaml"/>

Source=".../Telerik.Windows.Themes.Summer;component/Themes/Telerik.Windows.Controls.DataVisualization.xaml"/>

</ResourceDictionary.MergedDictionaries>

<Style TargetType="telerik:RadRibbonButton" BasedOn="{staticResource RadRibbonButtonStyle}">

<Setter Property="MinWidth" Value="{Binding Source={x:Static ribbonProps:Settings.Default}, Path=MinRibbonButtonWidth}"/>

For the Value setting above it shows warning in design time : The name "Setting" does not exist in the namespace

</Style>

<Style TargetType="dac:GroupedRadContextMenu" BasedOn="{staticResource RadContextMenuStyle}"/>

It shows warning in design time : The name "GroupedRadContextMenu" does not exist in the namespace "clr-namespace:XXX;assembly=XXX" Although that control exists on that assembly.

 

P.S.

When we tried to create a new project using your dlls of version 2015.1.401  without any change we saw the control on design time but could not see the map even though we ran the exact source code of the demo represented on the web (FileSystemMapProvider)

What can we do about it? Do you have any idea how can we solve that error?

Please help us, we must fix that isuue but we can't figure out what can be wrong and it's very frustrated.

Thanks in advanced,

Tali

 

 

0
Dilyan Traykov
Telerik team
answered on 27 Dec 2017, 03:30 PM
Hello Tali,

Thank you for the provided clarifications and code snippets.

Although this information does provide us with some insights on your exact setup, it is insufficient for us to suggest a specific cause for the errors you're getting. Would it be possible for you to send over a small sample project where these errors are present so that we can further investigate and assist you? You can either open a new support ticket from an active Telerik account or upload the project to a storage provider of your choice.

If you do not find this possible, the only suggestion I can give you with the current information I have is to check the following thread and see if it applies to your scenario.

Regards,
Dilyan Traykov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Mateusz
Top achievements
Rank 1
answered on 25 Jan 2018, 09:21 AM

Hello Petar,

We run into the same issue. Our application may run MapShapeDataVirtualizationSource.ReadAsync multiple times in short time. Unfortunately, ReadAsync doesn't return any task so we don't know if the previous request is already finished. We added some locking before running RunAsync (we use ReadShapeDataCompleted event to know when reading is finished). It helped a lot but still, in some rare cases the exception is thrown. This is hard for us, because there is no way to catch this exception so the application crashes. 

QueryItems clearly misses a lock. Are there any plans to include your fix in next release? We'd like to avoid building sources on our own as this makes our dev-ops process much more complicated. Also, making some methods virtual would alllow us to troubleshoot such problems much faster (that's a generic remark we have after using the library for some time).

Best Regards,

Mateusz

0
Petar Mladenov
Telerik team
answered on 30 Jan 2018, 07:57 AM
Hi Mateusz,

We will be glad to improve our product, however reproducing an exception (or locking issue) at our end is of high importance before planning a code changes. Can you isolate your application and send it in a new support thread ? Or bring more details on how you call ReadAsync() method in short periods of time, this might help us isolate the scenario too. Thank you in advance.

Regards,
Petar Mladenov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
Map
Asked by
טלי
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
טלי
Top achievements
Rank 1
Hila
Top achievements
Rank 1
Stefan
Telerik team
Dilyan Traykov
Telerik team
Mateusz
Top achievements
Rank 1
Share this question
or