System.Net.WebException: The remote server returned an error: NotFound.

Answered System.Net.WebException: The remote server returned an error: NotFound.

  • 17 สิงหาคม 2554 8:01
     
      มีโค้ด

    Hi

    I am using Sync Framework 4.0 CTP Release and i created application for synchronising between two SQL server 2008 database. I was following the steps given in the forum http://msdn.microsoft.com/en-us/library/gg299026(v=SQL.110).aspx with slight changes like i didnt use filter conditions and also i am using "SyncSvcUtilHelper.exe" to create the Sync configuration and provisioning the database and for code generation also.

    As mentioned i created a Silver light application on my client side but when iam trying to run the application i am getting this error

    {System.Net.WebException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound.
       at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
       at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClass5.<EndGetResponse>b__4(Object sendState)
       at System.Net.Browser.AsyncHelper.<>c__DisplayClass4.<BeginOnUI>b__1(Object sendState)
       --- End of inner exception stack trace ---
       at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
       at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
       at Microsoft.Synchronization.ClientServices.HttpCacheRequestHandler.OnDownloadGetResponseCompleted(IAsyncResult asyncResult)} System.Exception {System.Net.WebException}

    Below is the my xaml code which is used in my Silverlight application.

    using System;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using DestinationScope;
    using Microsoft.Synchronization.ClientServices.IsolatedStorage;
    
    namespace SyncClientSilverlight
    {
      public partial class MainPage : UserControl
      {
        DestinationScopeOfflineContext context = null;
        public MainPage()
        {
          InitializeComponent();
          context = new DestinationScopeOfflineContext("Client", new Uri(new Uri(new WebClient().BaseAddress), "../SourceScopeSyncService.svc/"));      
          context.LoadCompleted += new EventHandler<LoadCompletedEventArgs>(context_LoadCompleted);
          this.Loaded += new RoutedEventHandler(MainPage_Loaded);
          context.CacheController.RefreshCompleted += (sender, args) =>
          {
            if (args.Error != null)
            {
              Dispatcher.BeginInvoke(
                delegate
                {
                  MessageBox.Show(args.Error.ToString());
                });
            }
          };
        }
    
        void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
          context.LoadAsync();
        }
    
        void context_LoadCompleted(object sender, LoadCompletedEventArgs e)
        {
          Dispatcher.BeginInvoke(delegate
          {
            TagsGrid.ItemsSource = context.SourceCollection;
          });
        }
    
        private void Button_Click(object sender, RoutedEventArgs e)
        {
          // saves any outstanding changes made by the application
          context.SaveChanges();
    
          // refreshes the cache by uploading all modified changes and then by downloading the server changes
          context.CacheController.RefreshAsync();
        }
      }
    }
    
    

    Below is my Server Side Sync Configuration

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
        <configSections>
            <section name="SyncConfiguration" type="Microsoft.Synchronization.ClientServices.Configuration.SyncConfigurationSection, SyncSvcUtil, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" allowLocation="true" allowDefinition="Everywhere" allowExeDefinition="MachineToApplication" overrideModeDefault="Allow" restartOnExternalChanges="true" requirePermission="true" />
        </configSections>
        <SyncConfiguration>
            <SyncScopes>
                <SyncScope Name="SourceScope" SchemaName="" IsTemplateScope="false"
                    EnableBulkApplyProcedures="false">
                    <SyncTables>
                        <SyncTable Name="[Source]" GlobalName="Source" SchemaName=""
                            IncludeAllColumns="true" FilterClause="">
                            <SyncColumns>
                                <SyncColumn Name="Contact_id" GlobalName="Contact_id" SqlType="int"
                                    IsPrimaryKey="true" IsNullable="false" />
                                <SyncColumn Name="first_name" GlobalName="first_name" SqlType="nvarchar"
                                    IsPrimaryKey="false" IsNullable="false" />
                                <SyncColumn Name="last_name" GlobalName="last_name" SqlType="nvarchar"
                                    IsPrimaryKey="false" IsNullable="false" />
                            </SyncColumns>
                        </SyncTable>
                    </SyncTables>
                </SyncScope>
            </SyncScopes>
            <Databases>
                <TargetDatabase Name="Source" DbServer="IIS08TOPSDEVDB1\IIS08TOPSDEVDB1"
                    DbName="SyncSource" UserName="asapteam" Password="welcome"
                    UseIntegratedAuth="false" />
            </Databases>
        </SyncConfiguration>
    </configuration>

    Below is my Client Side Sync Configuration

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <configSections>
        <section name="SyncConfiguration" type="Microsoft.Synchronization.ClientServices.Configuration.SyncConfigurationSection, SyncSvcUtil, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" allowLocation="true" allowDefinition="Everywhere" allowExeDefinition="MachineToApplication" overrideModeDefault="Allow" restartOnExternalChanges="true" requirePermission="true" />
      </configSections>
      <SyncConfiguration>
        <SyncScopes>
          <SyncScope Name="DestinationScope" SchemaName="" IsTemplateScope="false"
            EnableBulkApplyProcedures="false">
            <SyncTables>
              <SyncTable Name="[Source]" GlobalName="Source" SchemaName=""
                IncludeAllColumns="true" FilterClause="">
                <SyncColumns>
                  <SyncColumn Name="Contact_id" GlobalName="Contact_id" SqlType="int"
                    IsPrimaryKey="true" IsNullable="false" />
                  <SyncColumn Name="first_name" GlobalName="first_name" SqlType="nvarchar"
                    IsPrimaryKey="false" IsNullable="false" />
                  <SyncColumn Name="last_name" GlobalName="last_name" SqlType="nvarchar"
                    IsPrimaryKey="false" IsNullable="false" />
                </SyncColumns>
              </SyncTable>
            </SyncTables>
          </SyncScope>
        </SyncScopes>
        <Databases>
          <TargetDatabase Name="Destination" DbServer="IIS08TOPSDEVDB1\IIS08TOPSDEVDB1"
            DbName="SyncDestination" UserName="asapteam" Password="welcome"
            UseIntegratedAuth="false" />
        </Databases>
      </SyncConfiguration>
    </configuration>
    

    NOTE: The service indivisually is working fine.

    Can you guys help me in fixing this. Please free to ask me if you need any more files for viewing or the source code for that matter.

ตอบทั้งหมด