Questa settimana un cliente mi ha segnalato un problema relativo all’utilizzo di log4net con Visual Studio 2010 e il Framework 4.0.
In pratica creando un’app
licazione console e referenziando log4net in versione 1.2.10 in fase di build si riceve questo errore:
“The referenced assembly “log4net” could not be resolved because it has a dependency on “System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a” which is not in the currently targeted framework “.NETFramework,Version=v4.0,Profile=Client”. Please remove references to assemblies not in the targeted framework or consider retargeting your project.”
Come esplicitato d
al messaggio il problema risiede nel fatto che la console application targettizza il Framework 4 Client Profile.
Il Client Profile è il target predefinito per i nuovi progetti Windows Forms, Console Application, WPF e Window Service. L’idea di base del Client Profile è quella di ridurre le dimensioni del Framework .Net rimuovendo tutte le assembly che in certi progetti non servono.
Nello specifico il client profile non contiene:
- ASP.NET
- alcune funzionalità avanzate di Windows Communication Foundation (WCF)
- il .NET Framework Data Provider per Oracle
- MSBuild
3.5 SP1 | 4.0 RTM | |
32 bit Client Profile | Online: 28 MB Offline: 255MB |
28.8 MB |
32 + 64 bit Client Profile | N/A | 41 MB |
32 bit Full | N/A | 35.3 MB |
32 + 64 bit Full | N/A | 48.1 MB |
32 + ia64 bit Full | N/A | 51.7 MB |
32 + 64 + ia64 bit Full | 231 MB | N/A |
In pratica la differenza di dimensioni si attesta sui 7 mega quindi secondo me non sostanziale.
L’accento probabilmente va posto su due punti:
- concettualmente gli applicativi desktop è corretto che non abbiano riferimenti ad assembly relative al mondo web
- il Framework 4 Client Profile è il framework che viene distribuito sui desktop tramite Windows Update
.NET Framework Client Profile
Towards a Smaller .NET 4 – Details on the Client Profile and Downloading .NET
What’s new in .NET Framework 4 Client Profile RTM