Problem with your code !!!

Jun 24, 2009 at 1:41 PM
Edited Jun 24, 2009 at 1:43 PM

Well i am having a little problem in the app.config in SyncComm.Service.Host Project, although i added the right GZipEncoder  i am still having this problem at :

 

 

 

<font size="2" color="#0000ff"><font size="2" color="#0000ff">

<

</font></font><font size="2" color="#0000ff">

 

</font>

binding name="BufferedHttpSampleServer"

><gzipMessageEncoding innerMessageEncoding="textMessageEncoding"

/><httpTransport hostNameComparisonMode="Str.....

He doesnt know the gzipMessageEnconding....

this is the warning i am getting :

Warning1 the element 'binding' has a non valid child'GZipMessageEncoding'. List of possible elements is : 'binaryMessageEncoding, compositeDuplex, oneWay, httpTransport, httpsTransport, msmqIntegration, msmqTransport, mtomMessageEncoding, namedPipeTransport, peerTransport, pnrpPeerResolver, privacyNoticeAt, reliableSession, security, sslStreamSecurity, tcpTransport, textMessageEncoding, windowsStreamSecurity, transactionFlow, unrecognizedPolicyAssertions, useManagedPresentation, webMessageEncoding, context'. C:\Documents and Settings\ahi\Bureau\synccomm0.90b\SyncComm Server\SyncComm.Service.Host\app.config 41 11 SyncComm.Service.Host

Thanks in advance and nice work !!!!

 

 

 

 

 

 

Coordinator
Jun 26, 2009 at 9:27 AM

Hi halawia,

Don't worry. GZipEncoder is considered custom encoder, so VS intellisense can not validate it as it is shown as warning. Execute your project and if all is configured correctly will get no problems. Please let me know if you are able to execute it.

Thanks,

Cheers,

Jun 26, 2009 at 9:56 AM
Edited Jun 26, 2009 at 9:56 AM

hello jtorres,

well if i kept this :

<gzipMessageEncoding innerMessageEncoding="textMessageEncoding"/>

when executing the SyncComm.Service.Host Project the execution stops on :

var hostDefault = new ServiceHost(typeof(SyncService));

saying that there is an unhandeled exception :

 

L'exception System.Configuration.ConfigurationErrorsException n'a pas été gérée
  Message="Le type « Microsoft.ServiceModel.Samples.GZipMessageEncodingElement, \r\nGZipEncoder, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null » inscrit pour l’extension « GZipMessageEncoding » n’a pas pu être chargé. (C:\\Documents and Settings\\ahi\\Bureau\\synccomm0.90b\\SyncComm Server\\SyncComm.Service.Host\\bin\\Debug\\SyncComm.Service.Host.vshost.exe.Config line 41)"
  Source="System.Configuration"
  BareMessage="Le type « Microsoft.ServiceModel.Samples.GZipMessageEncodingElement, \r\nGZipEncoder, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null » inscrit pour l’extension « GZipMessageEncoding » n’a pas pu être chargé."
  Filename="C:\\Documents and Settings\\ahi\\Bureau\\synccomm0.90b\\SyncComm Server\\SyncComm.Service.Host\\bin\\Debug\\SyncComm.Service.Host.vshost.exe.Config"
  Line=41
  StackTrace:
       à System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult)
       à System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject)
       à System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
       à System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
       à System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
       à System.Configuration.BaseConfigurationRecord.GetSection(String configKey, Boolean getLkg, Boolean checkPermission)
       à System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
       à System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName)
       à System.Configuration.ConfigurationManager.GetSection(String sectionName)
       à System.ServiceModel.Configuration.ConfigurationHelpers.UnsafeGetSectionFromConfigurationManager(String sectionPath)
       à System.ServiceModel.Configuration.ConfigurationHelpers.UnsafeGetAssociatedSection(ContextInformation evalContext, String sectionPath)
       à System.ServiceModel.Configuration.ServicesSection.UnsafeGetSection()
       à System.ServiceModel.Description.ConfigLoader.LookupService(String serviceConfigurationName)
       à System.ServiceModel.ServiceHostBase.LoadConfigurationSectionInternal(ConfigLoader configLoader, ServiceDescription description, String configurationName)
       à System.ServiceModel.ServiceHostBase.ApplyConfiguration()
       à System.ServiceModel.ServiceHostBase.InitializeDescription(UriSchemeKeyedCollection baseAddresses)
       à System.ServiceModel.ServiceHost.InitializeDescription(Type serviceType, UriSchemeKeyedCollection baseAddresses)
       à System.ServiceModel.ServiceHost..ctor(Type serviceType, Uri[] baseAddresses)
       à SyncComm.Service.Host.Program.Main(String[] args) dans C:\Documents and Settings\ahi\Bureau\synccomm0.90b\SyncComm Server\SyncComm.Service.Host\Program.cs:ligne 12
       à System.AppDomain._nExecuteAssembly(Assembly 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)
       à System.Threading.ThreadHelper.ThreadStart()
  InnerException: 

 

IN :

<gzipMessageEncoding innerMessageEncoding="textMessageEncoding"/>

the gzipMessageEncoding has an underlined blue !!

Thanks,

Cheers !!

Jun 26, 2009 at 9:59 AM

Hello again ,

I forgot to mention that if put this in comment:

 

// <gzipMessageEncoding innerMessageEncoding="textMessageEncoding"/>

The Serivce runs normaly !!! will it affect anything ?

Coordinator
Jun 26, 2009 at 10:18 AM

Hi again,

Did you downloaded GZipEncoder and referenced it on ServiceHost.Service.Host project?? It seems like such assembly is missing...

Jun 26, 2009 at 10:37 AM

Hi,

Actually i dont know why i did not add the reference i have so many projects opened !!


This solved this problem !!

I Have another question if iwant to use the Methods for Conflicts where can i insert this code for example !! :

 

/// <summary> 
        /// Resolver de conflits 
        /// Les règles de résolutions sont : 
        ///   * ClientDeleteServerUpdate : Le client l'emporte. La suppression coté client est maintenue. On suppose qu'un employé sur le terrain
        ///                                qui supprime un client l'emporte sur le marketing bureau qui l'aurait mis à jour.
        ///   * ClientUpdateServerDelete : Le Serveur l'emporte. La mise à jour coté client est annulée.
        ///   * ClientInsertServerInsert : Le Serveur l'emporte. L'insertion client est annulée.
        ///   * ClientUpdateServerUpdate : Résolution conditionnelle.
        /// </summary> 
        private void ServerApplyChangeFailed(object sender, ApplyChangeFailedEventArgs e)
        {
            if (e.TableMetadata.TableName == "Client")
                ResolveTableClientConflict(e);
        }

        private void ResolveTableClientConflict(ApplyChangeFailedEventArgs e)
        {

            //
            // ClientUpdateServerUpdate
            //
            // Ici Résolution conditionnelle
            // Le retour ou non vers le client d'une ligne en conflit dépend d'une règle métier imposée
            if (e.Conflict.ConflictType == ConflictType.ClientUpdateServerUpdate)
            {
                ResolveSimpleConditionalConflict(e);
                //ResolveComplexConditionalConflict(e);
                return;
            }

            //
            // ClientDeleteServerUpdate
            //
            // Ici le client l'emporte
            // La suppression coté cliente l'emporte, les données modifiées coté serveur sont effacées
            // On force donc la suppression
            if (e.Conflict.ConflictType == ConflictType.ClientDeleteServerUpdate)
            {
                e.Action = ApplyAction.RetryWithForceWrite;
                return;
            }

            //
            // ClientUpdateServerDelete
            //
            // Ici le serveur l'emporte
            // Les changements devront bien être appliqués coté client
            // Le serveur ayant raison, on applique pas la mise à jour, on continue donc.
            if (e.Conflict.ConflictType == ConflictType.ClientUpdateServerDelete)
            {
                e.Action = ApplyAction.Continue;
                return;
            }

            //
            // ClientInsertServerInsert
            //
            // Ici le serveur l'emporte
            // Les changements devront bien être appliqués coté client
            // Le serveur ayant raison, on ne garde que l'insertion coté serveur
            if (e.Conflict.ConflictType == ConflictType.ClientInsertServerInsert)
            {
                e.Action = ApplyAction.Continue;
                return;
            }

        }

 

Thank you a lot for your help !!! i love this project i hope it will move forwoard on and on !!

Coordinator
Jun 26, 2009 at 11:09 AM

Hi,

 

The code showed corresponds on Server side, so you have to put it on SyncApp.RemoteProvider project, CustomRemoteProviderSample class, into the constructor as follows:

        /// <summary>
        /// Initializes the sync adapters.
        /// </summary>
        public override void InitializeSyncAdapters()
        {
            AddSyncAdapter("Sales.Customer", SyncDirection.Bidirectional);
            AddSyncAdapter("Sales.CustomerContact", SyncDirection.UploadOnly);

            // here...
            this.ApplyChangeFailed += new System.EventHandler<ApplyChangeFailedEventArgs>(ServerApplyChangeFailed);
        }

Hope it'd be helpfull...

 

Jun 26, 2009 at 11:36 AM

Thank you so much !!!!

i'll get back for more feedback !! :D

Arigato (thank you in Japanese) :D