Entlib 5.0 silverlight Remoteloggingservice compiling

Topics: Logging Application Block, Silverlight Integration Pack
Mar 14, 2012 at 10:46 PM

I have other WCF and WCF RIA service in my silverlight project, when I added LoggingService.svc, the compiler will generate a folder called:

generatedWCFClientCode, and have a file under this folder:  servicereference.cs

it has a function :

 

private System.IAsyncResult OnBeginAdd(object[] inValues, System.AsyncCallback callback, object

asyncState)

{

Microsoft.Practices.EnterpriseLibrary.Logging.Service.LogEntryMessage[] entries = ((Microsoft.Practices.EnterpriseLibrary.Logging.Service.LogEntryMessage[])(inValues[0]));

 

return ((ServiceReference.Microsoft.Practices.EnterpriseLibrary.Logging.Service.LoggingService.ILoggingService)(this

)).BeginAdd(entries, callback, asyncState);

}

Then the compiler will complain:

 The type or namespace name 'LogEntryMessage' does not exist in the namespace 'ServiceReference.Microsoft.Practices.EnterpriseLibrary.Logging.Service' (are you missing an assembly reference?) 

Can you help me with this problem ?????



Thank you !!!

Mar 15, 2012 at 2:43 AM

Does your project reference the following assemblies?

Microsoft.Practices.EnterpriseLibrary.Common.Silverlight.dll
Microsoft.Practices.EnterpriseLibrary.Logging.Silverlight.dll
Microsoft.Practices.ServiceLocation.dll
Microsoft.Practices.Unity.Silverlight.dll

--
Randy Levy
Enterprise Library support engineer
entlib.support@live.com 

Mar 15, 2012 at 1:20 PM

Yes, it references all of them in silverlight project.  Thanks

Mar 15, 2012 at 3:09 PM
randylevy wrote:

Does your project reference the following assemblies?

Microsoft.Practices.EnterpriseLibrary.Common.Silverlight.dll
Microsoft.Practices.EnterpriseLibrary.Logging.Silverlight.dll
Microsoft.Practices.ServiceLocation.dll
Microsoft.Practices.Unity.Silverlight.dll

--
Randy Levy
Enterprise Library support engineer
entlib.support@live.com 


Hi, Randy:

If I change it to using extendedlogginservice as follows in the guide:

 

public class LoggingService2: LoggingService

protected override void CollectInformation(Microsoft.Practices.EnterpriseLibrary.Logging.LogEntry    

entry)

 

 // NOTE. This information can easily be spoofed by the caller. Use this information only

 

 // for diagnostic puposes, not for authentication or auditing purposes.

 

 var messageProperties = OperationContext

.Current.IncomingMessageProperties;  

 var endpoint = messageProperties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty 

;
 

 string clientAddress = endpoint != null ? endpoint.Address : string.

Empty;  

entry.ExtendedProperties.Add("ClientIPAddress" 

, clientAddress);
 

 // Also add the client host address as a category. This allows you to turn on server side logging for a single client

 

 

  (!string

IsNullOrEmpty(clientAddress))

{

entry.Categories.Add(clientAddress);

}

 

 

 

 

 

base

.CollectInformation(entry);

}

}

 

then I got error like this:

System.Windows.Markup.XamlParseException occurred
  Message=Failed to create a 'Microsoft.Practices.EnterpriseLibrary.Logging.Service.ILoggingServiceFactory' from the text 'CustomBinding_ILoggingService1'. [Line: 7 Position: 70]
  LineNumber=7
  LinePosition=70
  StackTrace:
       at MS.Internal.XcpImports.CreateFromXaml(String xamlString, Boolean createNamescope, Boolean requireDefaultNamespace, Boolean allowEventHandlers, Boolean expandTemplatesDuringParse)
       at MS.Internal.XcpImports.CreateFromXaml(String xamlString, Boolean createNamescope, Boolean requireDefaultNamespace, Boolean allowEventHandlers)
       at System.Windows.Markup.XamlReader.Load(String xaml)
       at OperationalGraphSL4.MainPage.InitializeEnterpriseLibrary()
  InnerException: System.InvalidOperationException
       Message=Could not find endpoint element with name 'CustomBinding_ILoggingService1' and contract 'Microsoft.Practices.EnterpriseLibrary.Logging.Service.ILoggingService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this name could be found in the client element.
       StackTrace:
            at System.ServiceModel.Description.ConfigLoader.LoadChannelBehaviors(ServiceEndpoint serviceEndpoint, String configurationName)
            at System.ServiceModel.ChannelFactory.ApplyConfiguration(String configurationName)
            at System.ServiceModel.ChannelFactory.InitializeEndpoint(String configurationName, EndpointAddress address)
            at System.ServiceModel.ChannelFactory`1..ctor(String endpointConfigurationName, EndpointAddress remoteAddress)
            at System.ServiceModel.ChannelFactory`1..ctor(String endpointConfigurationName)
            at Microsoft.Practices.EnterpriseLibrary.Logging.Service.LoggingServiceFactory.set_EndpointConfigurationName(String value)
            at Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingServiceFactoryEndpointConfigurationNameConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
            at MS.Internal.XamlManagedRuntimeRPInvokes.CreateFromValue(IntPtr inServiceContext, XamlTypeToken inTs, XamlQualifiedObject& qoValue, XamlPropertyToken inProperty, XamlTypeToken inType, XamlQualifiedObject& qoRootInstance, XamlQualifiedObject& qo)
       InnerException:

{

 // Get the user IP address and add it as an extended property.

Mar 15, 2012 at 3:24 PM

LoggingService is meant to be exposed as a WCF service on the server. 

On the Silverlight client side the WCF is usually kept in the ServiceReferences.ClientConfig.  The file is automatically generated when adding a service reference.

Based on the Inner Exception it looks like there is no configuration set up.

--
Randy Levy
Enterprise Library support engineer
entlib.support@live.com