Visualizzazione post con etichetta Microsoft Practices Enterprise Library. Mostra tutti i post
Visualizzazione post con etichetta Microsoft Practices Enterprise Library. Mostra tutti i post

martedì 16 luglio 2013

Could not load file or assembly Microsoft.Practices.EnterpriseLibrary.Logging exception

C# 4.0, MS Practices Enterprise Library 5.0

I have used the Enterprise Library Configuration tool for creating a Logging Application Block and I have obtained a configuration file like this:

<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
<loggingConfiguration name="" tracingEnabled="true" defaultCategory="General">
                …
                …
</loggingConfiguration>

Unfortunately, I got the following exception while trying to use the Enterprise Library Logging Application Block:

“An error occurred creating the configuration section handler for validation: Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)”

I solved this problem by setting to null the PublicKeyToken.


PublicKeyToken=null

lunedì 1 luglio 2013

Rebuild Enterprise Library 5.0 (script error)

Windows 7 Professional 64 bit

After I ‘ve downloaded the Microsoft Enteprise Libray 5.0, I wanted to rebuild all assemblies by ..\EntLib50Src\Scripts\BuildLibrary.bat script, but I received following error: “The specified solution configuration Debug|BPC is invalid. Please specify a valid solution configuration using the Configuration and Platform properties (e.g. MSBuild.exe Solution.sln /p:Configuration=Debug /p:Platform=”Any CPU”) or leave those properties blank to use the default solution configuration."

So, in the 2013 if you want resolve this problem you MUST delete a key registry.

Using regedit.exe navigate to the registry path

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment

and select the key Platform. Platform had the value BPC.
Then you delete only the value BPC. After this, the key Platform was still there but empty. Close Regedit, restart your PC and run the BuildLibrary.bat script.

giovedì 30 maggio 2013

Daily log file using the Microsoft Practices Enterprise Library Logging

C# 4.0, Microsoft Practices Enterprise Library 5.0

When you implement a Microsoft Practices Enterprise Library Logging, maybe you could need to distinguish  the file logging by date and for to do this you can follow these traces.

1.       Open the configuration file (like app.config) and search the “listeners” element near “loggingConfiguration”, set the “add” element’s attribute “fileName” in this way.

<add fileName="C:\Project\logs\Project.log" header="----------------------------------------" footer="----------------------------------------" formatter="Text Formatter" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" traceOutputOptions="DateTime" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="RollingFile TraceListener" rollFileExistsBehavior="Increment" rollInterval="Day" rollSizeKB="0" timeStampPattern="yyyy-MM-dd"/>

2.       Search the “listeners” element near “categorySources”, set the “add” element’s attribute “name” to “RollingFile TraceListener”.

<add name="RollingFile TraceListener"/>

3.       Search the “listeners” element near “specialSources”, set the “add” element’s attribute “name” to “RollingFile TraceListener”.

<add name="RollingFile TraceListener"/>

In this way you obtain a log file similar this:
Project.2012-08-20.1.log