Using SharePoint with Enterprise Library 4.0 under Partial trust

Posted Wednesday, October 1, 2008 10:52 AM by CoreyRoth

Last year, I posted on how to use Enterprise Library 3.1 with SharePoint under partial trust.  It was incredibly difficult to get it to work with SharePoint when using partial trust because none of the DLLs had the AllowPartiallyTrustedCallers attribute on them.  This meant in order to get it to work, you had to add it to every AssemblyInfo.cs in the solution, sign it with your own strong name key, and then build and deploy it.  It was a lot of effort.

Enterprise Library 4.0 has been out for a few months now, but I have yet to comment on it.   I am pleased to report that with this new release, none of this overhead is required.  All of the DLLs, have the AllowPartiallyTrustedCallers attribute which means all you have to do is reference the DLLs and assign appropriate permissions.  I recommend putting Enterprise Library DLLs in a solution package which will make setting permissions easier.  Last year's post should have most of the settings that you will need.

If you got turned off trying to implement Enterprise Library in the past with SharePoint, you might give it another try.  With the APTCA change, it should make it much easier to use entlib for logging, exception handling, data access, or whatever.

Comments

# re: Using SharePoint with Enterprise Library 4.0 under Partial trust

Thursday, March 10, 2011 1:45 AM by phani

Sir

we have done the same setting in sharepoint 2007 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 &#39;Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSyntheticConfigSettings&#39;

to type &#39;Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.ITypeRegistrationsProvider&#39;.

System.InvalidCastException: Unable to cast object of type &#39;Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSyntheticConfigSettings&#39;

to type &#39;Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.ITypeRegistrationsProvider&#39;.

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.&lt;GetRegistrations&gt;b__0(ITypeRegistrationsProvider l, IConfigurationSource cs)

at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.CompositeTypeRegistrationsProviderLocator.&lt;&gt;c__DisplayClass5.&lt;GetRegistrationsInternal&gt;b__4(ITypeRegistrationsProvider l)

at System.Linq.Enumerable.&lt;SelectManyIterator&gt;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 Programmes\Infopath\global_config_ip\global_config_ip\FormCode.cs:line 73

at Microsoft.Office.InfoPath.Server.SolutionLifetime.FormEventsHost.&lt;&gt;c__DisplayClass6.&lt;&gt;c__DisplayClassa.&lt;add_Loading&gt;b__3()

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

at Microsoft.Office.InfoPath.Server.SolutionLifetime.FormEventsHost.&lt;&gt;c__DisplayClass6.&lt;add_Loading&gt;b__2(Object sender, LoadingEventArgs e)

at Microsoft.Office.InfoPath.Server.SolutionLifetime.FormEventsHost.&lt;&gt;c__DisplayClass34.&lt;FireLoadingEvent&gt;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

Leave a Comment

(required)
(required)
(optional)
(required)