Invalid Credentials for bing maps in wpf application

谁说我不能喝 提交于 2019-12-14 00:06:57

问题


Impossible to display the map. I still have a error message: "Invalid Credentials. Sign up for a developer account at: http://www.microsoft.com/maps/developers"

However, I created a account correctly and obtained a valid key:

  • Application name: Geography
  • Key: *My key*
  • Application Url:
  • Key type: Basic / Dev/Test
  • Created date: 08/12/2015
  • Expiration date: None

My xaml code:

<Window x:Class="Geography.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:m="clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <m:Map CredentialsProvider="*My key*">
        </m:Map>
    </Grid>
</Window>

回答1:


It was a proxy whose I ignore the existence.

So, I set the following config in my app.config file and the error message no longer appears:

<system.net>
  <defaultProxy enabled="true" useDefaultCredentials="true">
    <proxy bypassonlocal="True" proxyaddress="http://ProxyAddress:Port"/>
  </defaultProxy>
</system.net>



回答2:


Try this code

<Window x:Class="Geography.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
     xmlns:m="clr-namespace:Microsoft.Maps.MapControl.WPF;assembly=Microsoft.Maps.MapControl.WPF"
    Title="Maps" Height="350" Width="525" Style="{StaticResource OfficeStyle}">
    <Grid>
    <m:Map CredentialsProvider="/*YOUR ID*/" x:Name="myMap" />
    </Grid>
</Window>

Then add it into cs code

   using System;
   using System.Collections.Generic;
   using System.Linq;
   using System.Text;
   using System.Threading.Tasks;
   using System.Windows;
   using System.Windows.Controls;
   using System.Windows.Data;
   using System.Windows.Documents;
   using System.Windows.Input;
   using System.Windows.Media;
   using System.Windows.Media.Imaging;
   using System.Windows.Shapes;
   using Microsoft.Maps.MapControl.WPF;
   namespace Geography
   {
         /// <summary>
         /// Interaction logic for Maps.xaml
         /// </summary>
        public partial class MainWindow : Window
        {
            public MainWindow()
            {
               InitializeComponent();
               myMap.Focus();
               //Set map to Aerial mode with labels
               myMap.Mode = new AerialMode();
            }
        }
    }

go following link to get more details: https://msdn.microsoft.com/en-us/library/hh830433.aspx



来源:https://stackoverflow.com/questions/31981578/invalid-credentials-for-bing-maps-in-wpf-application

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!