Hi, I am sorry if I am making this topic at the wrong place or if there is already one I couldn't find.
Anyway, I am very new to Silverlight and RadMap and I am trying to read a shapefile. The scenario has just an empty RadMap that works fine (I use BingMaps as provider) - "MapAM".
I want to press a button, which opens a file dialog and chooses the shapefile. When the file is chosen to be displayed on the map.
I have followed the tutorials on the matter and I came up with the following:
This code results in the following error:
{System.Net.WebException: An exception occurred during a WebClient request. ---> System.NotSupportedException: The URI prefix is not recognized.
в System.Net.WebRequest.Create(Uri requestUri)
в System.Net.WebClient.GetWebRequest(Uri address)
в System.Net.WebClient.OpenReadAsync(Uri address, Object userToken)
--- Край на вътрешното проследяване на стека за грешки ---}
In order to be able to open files, as I understand is not an easy task in Silverlight, I set the Silverlight project to be opened out of browser and checked the 'Require elevated trust ...' . This resolves the exception I get for file permissions.
So far so good, but the mentioned exception occurs at the PreviewReadCompleted event.
By the way the files I test it with are correct. Meaning that I have two files - "18099.shp" and "18099.dbf", that have the same name but different extension. And I open them through file dialog so, (and i've checked) my uri's are correct.
I've spent a lot of time reading about this exception in internet and the only solution I seem to find says that to resolve this problem I need to set the start-up project to the hosting application. Which means that the Silverlight project will no longer open under Out of browser and I get stuck with the File permissions exception.
I am kind of hoping I am doing something wrong or using a methodology that is incorrect.
I am of hope that you could provide sample code or at least a mentioning of what is going wrong :)
thank you in advance,
Anyway, I am very new to Silverlight and RadMap and I am trying to read a shapefile. The scenario has just an empty RadMap that works fine (I use BingMaps as provider) - "MapAM".
I want to press a button, which opens a file dialog and chooses the shapefile. When the file is chosen to be displayed on the map.
I have followed the tutorials on the matter and I came up with the following:
private
void
btnOpenShape_Click(
object
sender, RoutedEventArgs e)
{
OpenFileDialog openFileDialog =
new
OpenFileDialog();
bool
? clickedOk = openFileDialog.ShowDialog();
// Process input if the user clicked OK.
if
(clickedOk ==
true
)
{
string
strShpUri = openFileDialog.File.FullName;
string
strDbfUri = strShpUri.Substring(0, strShpUri.Length - 3) +
"dbf"
;
//because the shp and dbf files have the same name
Uri shapeUri =
new
Uri(strShpUri, UriKind.Absolute);
Uri dbfUri =
new
Uri(strDbfUri, UriKind.Absolute);
MapShapeReader shpReader =
new
MapShapeReader();
shpReader.PreviewReadCompleted += shpReader_PreviewReadCompleted;
shpReader.Read(
new
Uri(strShpUri, UriKind.Absolute),
new
Uri(strDbfUri, UriKind.Absolute));
InformationLayer layer =
new
InformationLayer();
layer.ShapeFill =
new
MapShapeFill();
layer.ShapeFill.Fill =
new
SolidColorBrush(Colors.Green);
layer.ShapeFill.Stroke =
new
SolidColorBrush(Colors.Red);
layer.Reader = shpReader;
MapAM.Items.Add(layer);
}
}
void
shpReader_PreviewReadCompleted(
object
sender, PreviewReadShapesCompletedEventArgs e)
{
if
(e.Error !=
null
)
{
MessageBox.Show(e.Error.Message);
}
}
This code results in the following error:
{System.Net.WebException: An exception occurred during a WebClient request. ---> System.NotSupportedException: The URI prefix is not recognized.
в System.Net.WebRequest.Create(Uri requestUri)
в System.Net.WebClient.GetWebRequest(Uri address)
в System.Net.WebClient.OpenReadAsync(Uri address, Object userToken)
--- Край на вътрешното проследяване на стека за грешки ---}
In order to be able to open files, as I understand is not an easy task in Silverlight, I set the Silverlight project to be opened out of browser and checked the 'Require elevated trust ...' . This resolves the exception I get for file permissions.
So far so good, but the mentioned exception occurs at the PreviewReadCompleted event.
By the way the files I test it with are correct. Meaning that I have two files - "18099.shp" and "18099.dbf", that have the same name but different extension. And I open them through file dialog so, (and i've checked) my uri's are correct.
I've spent a lot of time reading about this exception in internet and the only solution I seem to find says that to resolve this problem I need to set the start-up project to the hosting application. Which means that the Silverlight project will no longer open under Out of browser and I get stuck with the File permissions exception.
I am kind of hoping I am doing something wrong or using a methodology that is incorrect.
I am of hope that you could provide sample code or at least a mentioning of what is going wrong :)
thank you in advance,