Using Enterprise Library 4.1 in SharePoint 2007 development projects


Yes, you CAN use Enterprise Library 4.1 (http://msdn.microsoft.com/en-us/library/cc467894.aspx) in your SharePoint 2007 development projects. Here is how:



  1. Install .NET Framework 3.5 if it is not present on SharePoint servers. EntLib 4.1 is based on 3.5 framework.

  2. Enable 3.5 for MOSS applications. MOSS 2007 was released before 3.5, so even if you have 3.5 on the servers, it won’t know it and take advantages of it until you ask it to. To let MOSS 2007 to leverage 3.5, you need to modify its web application’s web.config. Here is a blog that you can follow: http://blogs.msdn.com/chabrook/archive/2008/06/11/enabling-moss-to-use-net-3-5.aspx

  3. Deploy Enterprise Library bits to the SharePoint servers. I would recommend GAC deployment. You also want to use the out-of-the-box signed DLLs.

  4. Now you can modify web.config of your web applications to use EntLib. I recommend to use the Enterprise Library Configuration Utility to manage your EntLib configurations. Of cause, you need use feature receiver or some other mechanisms to propagate the changes for multi-server farms.

  5. Enjoy EntLib!

I have a webcast on this topic on MSDN China at http://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?culture=en-US&EventID=1032420504&CountryCode=US. You are welcome to watch it if you happen to speak Mandarin Chinese.


Zewei Song, Ph.D.


MCPD, MCTS: .NET 3.5, MOSS AppDev, Configuration


Enterprise Services, Microsoft Corporation


 

Comments (5)

  1. dyananth says:

    Dear Zewei,

           Can Enterprise library 5.0 application blocks be used with SharePoint 2007 & 2010.

    thanks,

    Yoga

  2. Dr. Z says:

    I haven’t tested it yet. But it seems that it would work with both MOSS 2007 and SharePoint 2010.

    From EntLib 5.0’s document: "…In addition, this release has been adapted to work with both Microsoft Visual Studio® 2008 and Microsoft Visual Studio 2010; and with the Microsoft .NET Framework versions 4.0 and 3.5 with Service Pack 1."

  3. PHANI says:

    Sir

    May i know how to use data validation block of Enterprise Library 5.0 with sharepoint 2007 infopath forms?

    Waiting for your response

    Thank you in advance

  4. phani says:

    Sir

    we have done the required settings in sharepoint 2007 config file to make it ready for   Enterprise library 5.0 . For .net applications we haven't faced any problem, but if we are using infopath forms, it is showing in preview but , We are not able to deploy We are getting this error.

    <pre lang="xml">Unable to cast object of type 'Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSyntheticConfigSettings'

    to type 'Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.ITypeRegistrationsProvider'.

    System.InvalidCastException: Unable to cast object of type 'Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSyntheticConfigSettings'

    to type 'Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.ITypeRegistrationsProvider'.

    at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.TypeLoadingLocator.GetRegistrationsInternal(IConfigurationSource configurationSource, Func`3 registrationAccessor)

    at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.TypeLoadingLocator.GetRegistrations(IConfigurationSource configurationSource)

    at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.CompositeTypeRegistrationsProviderLocator.<GetRegistrations>b__0(ITypeRegistrationsProvider l, IConfigurationSource cs)

    at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.CompositeTypeRegistrationsProviderLocator.<>c__DisplayClass5.<GetRegistrationsInternal>b__4(ITypeRegistrationsProvider l)

    at System.Linq.Enumerable.<SelectManyIterator>d__14`2.MoveNext()

    at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.Unity.UnityContainerConfigurator.RegisterAllCore(IConfigurationSource configurationSource, ITypeRegistrationsProvider rootProvider)

    at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.ChangeTrackingContainerConfigurator.RegisterAll(IConfigurationSource configurationSource, ITypeRegistrationsProvider rootProvider)

    at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.EnterpriseLibraryContainer.ConfigureContainer(ITypeRegistrationsProvider locator, IContainerConfigurator configurator, IConfigurationSource configSource)

    at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.EnterpriseLibraryContainer.ConfigureContainer(IContainerConfigurator configurator, IConfigurationSource configSource)

    at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.EnterpriseLibraryContainer.CreateDefaultContainer(IConfigurationSource configurationSource)

    at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.EnterpriseLibraryContainer.SetCurrentContainerIfNotSet()

    at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.EnterpriseLibraryContainer.get_Current()

    at Microsoft.Practices.EnterpriseLibrary.Data.DatabaseFactory.InnerCreateDatabase(String name)

    at Microsoft.Practices.EnterpriseLibrary.Data.DatabaseFactory.CreateDatabase()

    at global_config_ip.FormCode.FormEvents_Loading(Object sender, LoadingEventArgs e) in E:SharePoint ProgrammesInfopathglobal_config_ipglobal_config_ipFormCode.cs:line 73

    at Microsoft.Office.InfoPath.Server.SolutionLifetime.FormEventsHost.<>c__DisplayClass6.<>c__DisplayClassa.<add_Loading>b__3()

    at Microsoft.Office.InfoPath.Server.Util.DocumentReliability.InvokeBusinessLogic(Thunk thunk)

    at Microsoft.Office.InfoPath.Server.SolutionLifetime.FormEventsHost.<>c__DisplayClass6.<add_Loading>b__2(Object sender, LoadingEventArgs e)

    at Microsoft.Office.InfoPath.Server.SolutionLifetime.FormEventsHost.<>c__DisplayClass34.<FireLoadingEvent>b__30()

    at Microsoft.Office.InfoPath.Server.DocumentLifetime.OMExceptionManager.CallFormCodeWithExceptionHandling(UserMessages userMessages, OMCall d)

    An entry has been added to the Windows event log of the server.

    Log ID:5337</pre>

    Can you help us

    Thank u in advance

  5. phani says:

    Hi

    can i know whether Entlib 4.1 supports sharepoint 2010 also?

    any idea?