locked
WPF et webservice RRS feed

  • Question

  • I want to assign an address to geographical coordinates, here is my code;

    private string ReverseGeocodePoint(double lat,double log)
            {
                string results = "";
                string key = "ApPI99TCrKmWDJ1IcPj9PI1oHlsjZY3sEdsvYWXsT68_lcJk4R2161hEDSCEPEzh";
                ReverseGeocodeRequest reverseGeocodeRequest = new ReverseGeocodeRequest();

                reverseGeocodeRequest.Credentials = new GeocodeService.Credentials();
                reverseGeocodeRequest.Credentials.ApplicationId = key;

                GeocodeService.Location point = new GeocodeService.Location();

                point.Latitude = lat;
                point.Longitude = log;

                reverseGeocodeRequest.Location = point;

                GeocodeServiceClient geocodeService = new GeocodeServiceClient();
                GeocodeResponse geocodeResponse = geocodeService.ReverseGeocode(reverseGeocodeRequest);

                if (geocodeResponse.Results.Length > 0)
                    results = geocodeResponse.Results[0].DisplayName;
                else
                    results = "No Results found";

                return results;
            }

    +++++++++++++++++++++++++++++

    private void addPush(double lat,double log)
            {
                Microsoft.Maps.MapControl.WPF.Location pinlocation = new Microsoft.Maps.MapControl.WPF.Location();
                pinlocation.Latitude = lat;
                pinlocation.Longitude = log;
                locat=lat+","+log;
                Pushpin pin = new Pushpin();
               ReverseGeocodePoint(46.589069,5.031738);
                var tooltipText = "Unkown";
                tooltipText = adresse;
                System.Windows.Controls.ToolTipService.SetToolTip(pin, tooltipText);
                pin.Location = pinlocation;
                MyMap.Children.Add(pin);
            }

    but the appeal of reverseGeocode generates this error:

    L'exception System.Windows.Markup.XamlParseException n'a pas été gérée
      Message='L'invocation du constructeur sur le type 'WpfWPF.MainWindow' qui correspond aux contraintes de liaison spécifiées a levé une exception.' numéro de ligne '4' et position de ligne '9'.
      Source=PresentationFramework
      LineNumber=4
      LinePosition=9
      StackTrace:
           à System.Windows.Markup.XamlReader.RewrapException(Exception e, IXamlLineInfo lineInfo, Uri baseUri)
           à System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
           à System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
           à System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
           à System.Windows.Application.LoadBamlStreamWithSyncInfo(Stream stream, ParserContext pc)
           à System.Windows.Application.LoadComponent(Uri resourceLocator, Boolean bSkipJournaledProperties)
           à System.Windows.Application.DoStartup()
           à System.Windows.Application.<.ctor>b__1(Object unused)
           à System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
           à MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
           à System.Windows.Threading.DispatcherOperation.InvokeImpl()
           à System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
           à System.Threading.ExecutionContext.runTryCode(Object userData)
           à System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
           à System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
           à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
           à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           à System.Windows.Threading.DispatcherOperation.Invoke()
           à System.Windows.Threading.Dispatcher.ProcessQueue()
           à System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
           à MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
           à MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
           à System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
           à MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
           à System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
           à MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
           à MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
           à System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
           à System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
           à System.Windows.Application.RunDispatcher(Object ignore)
           à System.Windows.Application.RunInternal(Window window)
           à System.Windows.Application.Run(Window window)
           à System.Windows.Application.Run()
           à WpfWPF.App.Main() dans C:\Users\nassim\Documents\Visual Studio 2010\Projects\WpfWPF\WpfWPF\obj\x86\Debug\App.g.cs:ligne 0
           à System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
           à System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
           à Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
           à System.Threading.ThreadHelper.ThreadStart_Context(Object state)
           à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
           à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           à System.Threading.ThreadHelper.ThreadStart()
      InnerException: System.InvalidOperationException
           Message=Une section de configuration du point de terminaison du contrat 'GeocodeService.IGeocodeService' n'a pas pu être chargée car plusieurs configurations de point de terminaison pour ce contrat ont été détectées. Indiquez la section de configuration du point de terminaison préférée par son nom.
           Source=System.ServiceModel
           StackTrace:
                à System.ServiceModel.Description.ConfigLoader.LookupChannel(ContextInformation configurationContext, String configurationName, ContractDescription contract, EndpointAddress address, Boolean wildcard, Boolean useChannelElementKind, ServiceEndpoint& serviceEndpoint)
                à System.ServiceModel.Description.ConfigLoader.LookupEndpoint(String configurationName, EndpointAddress address, ContractDescription contract, ContextInformation configurationContext)
                à System.ServiceModel.Description.ConfigLoader.LookupEndpoint(String configurationName, EndpointAddress address, ContractDescription contract)
                à System.ServiceModel.ChannelFactory.InitializeEndpoint(String configurationName, EndpointAddress address)
                à System.ServiceModel.ChannelFactory`1..ctor(String endpointConfigurationName, EndpointAddress remoteAddress)
                à System.ServiceModel.ChannelFactory`1..ctor(String endpointConfigurationName)
                à System.ServiceModel.EndpointTrait`1.CreateSimplexFactory()
                à System.ServiceModel.EndpointTrait`1.CreateChannelFactory()
                à System.ServiceModel.ClientBase`1.CreateChannelFactoryRef(EndpointTrait`1 endpointTrait)
                à System.ServiceModel.ClientBase`1.InitializeChannelFactoryRef()
                à System.ServiceModel.ClientBase`1..ctor()
                à WpfWPF.GeocodeService.GeocodeServiceClient..ctor() dans C:\Users\nassim\Documents\Visual Studio 2010\Projects\WpfWPF\WpfWPF\Service References\GeocodeService\Reference.cs:ligne 1522
                à WpfWPF.MainWindow.ReverseGeocodePoint(Double la, Double lo) dans C:\Users\nassim\Documents\Visual Studio 2010\Projects\WpfWPF\WpfWPF\MainWindow.xaml.cs:ligne 77
                à WpfWPF.MainWindow.addPush(Double lat, Double log) dans C:\Users\nassim\Documents\Visual Studio 2010\Projects\WpfWPF\WpfWPF\MainWindow.xaml.cs:ligne 54
                à WpfWPF.MainWindow.load(Point[] str) dans C:\Users\nassim\Documents\Visual Studio 2010\Projects\WpfWPF\WpfWPF\MainWindow.xaml.cs:ligne 43
                à WpfWPF.MainWindow..ctor() dans C:\Users\nassim\Documents\Visual Studio 2010\Projects\WpfWPF\WpfWPF\MainWindow.xaml.cs:ligne 34
           InnerException: 


    • Moved by Jie Bao Wednesday, August 1, 2012 7:40 AM (From:Windows Presentation Foundation (WPF))
    • Edited by nhmidi Wednesday, August 1, 2012 8:18 AM
    Wednesday, August 1, 2012 12:03 AM

All replies

  • Hi nhmidi,

    This is WPF forum of English language.

    You can consider posting your question in the WPF forum of your local language for getting better support.

    Thanks,


    Kee Poppy [MSFT]
    MSDN Community Support | Feedback to us

    Wednesday, August 1, 2012 7:08 AM