Talvolta l'installazione di "Windows Communication Foundation" (a.k.a. Indigo) su Windows XP può fallire almeno in parte, anche se il setup dichiara che è tutto ok. Da cosa ce ne accorgiamo? Indubbiamente dal fatto che qualcosa va storto ...  

Infatti, mi si è presentato questo errore in fase di compilazione:

Unhandled Exception: System.TypeInitializationException: The type initializer for 'System.ServiceModel' threw an exception. ---> System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize ---> System.Configuration.ConfigurationErrorsException: Unrecognized configuration
 section system.serviceModel. ()
   at System.Configuration.BaseConfigurationRecord.ThrowIfInitErrors()
   at System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey
)
   --- End of inner exception stack trace ---
   at System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey
)
   at System.Configuration.ClientConfigurationSystem.System.Configuration.Intern
al.IInternalConfigSystem.GetSection(String sectionName)
   at System.Configuration.ConfigurationManager.GetSection(String sectionName)
   at System.Configuration.ConfigurationManager.get_AppSettings()
   at System.ServiceModel.DiagnosticTrace..cctor()
   --- End of inner exception stack trace ---
   at System.ServiceModel.DiagnosticTrace.ShouldTrace(TraceEventType type)
   at System.ServiceModel.ServiceHost.TraceCreation(TraceEventType eventType)
   at System.ServiceModel.ServiceHost..ctor(Uri[] baseAddresses)
   at System.ServiceModel.ServiceHost`1..ctor(Uri[] baseAddresses)
   at Service.Program.Main(String[] args) ....

Questo perchè l'installazione non è riuscita a registrare le sezioni di indigo nel machine.config. E' sufficiente aggiungere al machine.config, nella sezione configSections, il seguente codice:

<sectionGroup name="microsoft.indigoListener" type="Microsoft.Indigo.IndigoListener.Configuration.IndigoListenerSectionGroup, System.ServiceModel, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
    <section 
name="diagnostics" type="Microsoft.Indigo.IndigoListener.Configuration.DiagnosticSection, System.ServiceModel, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
    <section 
name="net.pipe" type="Microsoft.Indigo.IndigoListener.Configuration.NetPipeSection, System.ServiceModel, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
    <section 
name="net.tcp" type="Microsoft.Indigo.IndigoListener.Configuration.NetTcpSection, System.ServiceModel, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<
/sectionGroup>
<sectionGroup 
name="system.runtime.serialization" type="System.Runtime.Serialization.Configuration.SerializationSectionGroup, System.Runtime.Serialization, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
    <section 
name="xmlFormatter" type="System.Runtime.Serialization.Configuration.XmlFormatterSection, System.Runtime.Serialization, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<
/sectionGroup>
<sectionGroup 
name="system.serviceModel" type="System.ServiceModel.Configuration.ServiceModelSectionGroup, System.ServiceModel, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
    <section 
name="behaviors" type="System.ServiceModel.Configuration.BehaviorsSection, System.ServiceModel, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
    <section 
name="client" type="System.ServiceModel.Configuration.ClientSection, System.ServiceModel, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
    <section 
name="diagnostics" type="System.ServiceModel.Configuration.DiagnosticSection, System.ServiceModel, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
    <section 
name="extensions" type="System.ServiceModel.Configuration.ServiceModelExtensionsSection, System.ServiceModel, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
    <section 
name="serviceHostingEnvironment" type="System.ServiceModel.Configuration.ServiceHostingEnvironmentSection, System.ServiceModel, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
    <section 
name="services" type="System.ServiceModel.Configuration.ServicesSection, System.ServiceModel, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
    <sectionGroup 
name="bindings" type="System.ServiceModel.Configuration.BindingsSectionGroup, System.ServiceModel, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
        <section 
name="basicProfileBinding" type="System.ServiceModel.Configuration.BasicProfileBindingSection, System.ServiceModel, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
        <section 
name="customBinding" type="System.ServiceModel.Configuration.CustomBindingSection, System.ServiceModel, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
        <section 
name="intermediaryBinding" type="System.ServiceModel.Configuration.IntermediaryBindingSection, System.ServiceModel, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
        <section 
name="msmqIntegrationBinding" type="System.ServiceModel.Configuration.MsmqIntegrationBindingSection, System.ServiceModel, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
        <section 
name="netProfileDualTcpBinding" type="System.ServiceModel.Configuration.NetProfileDualTcpBindingSection, System.ServiceModel, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
        <section 
name="netProfileMsmqBinding" type="System.ServiceModel.Configuration.NetProfileMsmqBindingSection, System.ServiceModel, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
        <section 
name="netProfileNamedPipeBinding" type="System.ServiceModel.Configuration.NetProfileNamedPipeBindingSection, System.ServiceModel, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
        <section 
name="netProfileTcpBinding" type="System.ServiceModel.Configuration.NetProfileTcpBindingSection, System.ServiceModel, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
        <section 
name="wsProfileBinding" type="System.ServiceModel.Configuration.WSProfileBindingSection, System.ServiceModel, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
        <section 
name="wsProfileDualHttpBinding" type="System.ServiceModel.Configuration.WSProfileDualHttpBindingSection, System.ServiceModel, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
    <
/sectionGroup>
<
/sectionGroup>

La versione è Microsoft® WinFX™ Software Development Kit (SDK) for Microsoft Pre-Release Software Code Named "Avalon" and "Indigo" Beta 1 RC.

E' giusto citare (e ringraziare) la fonte: http://turtle.net.nz/blog/PermaLink,guid,398d0c3e-09ff-4004-9039-0505e6ab3e48.aspx

powered by IMHO 1.2