locked
Bing Map RRS feed

  • Question

  • hi,

    I am doing bing map application

    I added below code in XAML and added this 2 .dll file in references folder

    Microsoft.Maps.MapControl.dll & Microsoft.Maps.MapControl.Common.dll

     

    Here is the XAML code

    <UserControl x:Class="SilverlightTestApplication.MainPage"
        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;assembly=Microsoft.Maps.MapControl">
        <Grid x:Name="LayoutRoot" Background="White">
            <m:Map CredentialsProvider="Ako_8dgRjkfbv3DBH-aWCu29zFjE_0lzNir04NRNqteBFMnlq-Te-PTaDddTCpW5" Mode="Aerial" />
        </Grid>
    </UserControl>

     

    i think this enough to run the the project but while running i  m getting this error (The name 'InitializeComponent' does not exist in the current context )

     

    here is my Mainpage.xaml.cs code

    using System;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Ink;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;

    namespace BINGMAP1
    {
        public partial class MainPage : UserControl
        {
            public MainPage()
            {
                // Required to initialize variables
                InitializeComponent();
            }
        }
    }

     

     

     

    PLEASE HELP ME..................:(

     

    & IF YOU HAVE ANY MORE INFORMATION TO DEVELOPE BING APPLICATION PLEASE HELP ME.....:(

    Saturday, October 16, 2010 11:40 AM

All replies

  • This is probably because the x:Class attribute in App.xaml doesn't match the class name in App.xaml.cs. Please follow these steps and let us know if it works for you.

    1. Open App.xaml and check x:Class attribute (Ex: SilverlightApplication101.App)
    2. Open App.xaml.cs and check if the namespace and class name match (namespace: SilverlightApplication101, class: App), if not fix it.
    3. Build

    My .NET Blog: http://michaelcrump.net
    Sunday, October 17, 2010 2:23 PM
  • below is code in files but still i m facing same problem. pls help me

     

    My App.xaml

     

    <Application
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        x:Class="bingmap_02.App">
        <Application.Resources>
            <!-- Resources scoped at the Application level should be defined here. -->
        </Application.Resources>
    </Application>

     

    My App.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 bingmap_02
    {
        public partial class App : Application
        {
            public App()
            {
                this.Startup += this.Application_Startup;
                this.Exit += this.Application_Exit;
                this.UnhandledException += this.Application_UnhandledException;

                InitializeComponent();
            }

            private void Application_Startup(object sender, StartupEventArgs e)
            {
                this.RootVisual = new MainPage();
            }

            private void Application_Exit(object sender, EventArgs e)
            {
            }

            private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
            {
                // If the app is running outside of the debugger then report the exception using
                // the browser's exception mechanism. On IE this will display it a yellow alert
                // icon in the status bar and Firefox will display a script error.
                if (!System.Diagnostics.Debugger.IsAttached)
                {

                    // NOTE: This will allow the application to continue running after an exception has been thrown
                    // but not handled.
                    // For production applications this error handling should be replaced with something that will
                    // report the error to the website and stop the application.
                    e.Handled = true;
                    Deployment.Current.Dispatcher.BeginInvoke(delegate { ReportErrorToDOM(e); });
                }
            }

            private void ReportErrorToDOM(ApplicationUnhandledExceptionEventArgs e)
            {
                try
                {
                    string errorMsg = e.ExceptionObject.Message + e.ExceptionObject.StackTrace;
                    errorMsg = errorMsg.Replace('"', '\'').Replace("\r\n", @"\n");

                    System.Windows.Browser.HtmlPage.Window.Eval("throw new Error(\"Unhandled Error in Silverlight Application " + errorMsg + "\");");
                }
                catch (Exception)
                {
                }
            }
        }
    }

    Monday, October 18, 2010 4:34 AM
  • hey i got got d answer.... :)
    Monday, October 18, 2010 5:01 AM
  • can you post it?
    Wednesday, October 20, 2010 2:17 PM
  • i removed the map & then from asset panel i select map asset & dragged a map on artboard.

    so in my code

     

    Microsoft_Maps_MapControl        this text added instead of        Mymap

    Tuesday, October 26, 2010 4:13 AM