Home » What We're Thinking » Suleman's Blog
A few weeks back, I was trying to configure Enterprise Library 4.0 for Exception handling and Logging exception into event log but was not able to find any help on internet so it took me long time to do all the configurations for handling and logging exceptions using Enterprise. Library 4.0.
Follow following steps to configure Ent. Lib 4.0 Exception Handling and Logging blocks.
Note: web.config changes are required if you are using Enterprise Library with SharePoint for .Net application you can skip these steps.
a. Microsoft.Practices.EnterpriseLibrary.Common.dll b. Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.dll c. Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.dll d. Microsoft.Practices.EnterpriseLibrary.Logging.dll e. Microsoft.Practices.ObjectBuilder2.dll f. Microsoft.Practices.Unity.dll
a. <SafeControl Assembly="Microsoft.Practices.EnterpriseLibrary.Common, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="Microsoft.Practices.EnterpriseLibrary.Common" TypeName="*" Safe="True" /> b. <SafeControl Assembly="Microsoft.Practices.ObjectBuilder2, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="Microsoft.Practices.ObjectBuilder2" TypeName="*" Safe="True" /> c. <SafeControl Assembly="Microsoft.Practices.Unity, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="Microsoft.Practices.Unity" TypeName="*" Safe="True" /> d. <SafeControl Assembly="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling" TypeName="*" Safe="True" /> e. <SafeControl Assembly="Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="Microsoft.Practices.EnterpriseLibrary.Logging" TypeName="*" Safe="True" /> f. <SafeControl Assembly="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging" TypeName="*" Safe="True" />
Add following references and namespaces in your project
Note: Use Browse tab while adding reference and add above references from “<System Drive>:\Program Files\Microsoft Enterprise Library 4.0 - May 2008\Bin”
User following code snippet for exception handling:
try
{
//CODE
}
catch (Exception ex)
bool rethrow = ExceptionPolicy.HandleException(ex, "My Custom Exception Policy");
// Policy Name should be same as we configured in configuration step 7
if (rethrow)
throw; //Throw Exception if you need to show an error message to end user otherwise no need to throw exception.
finally
// Close/Dispose all objects
You are all done to get benefits of Enterprise Library 4.0 – Enjoy!!!!!
A client has reported an issue that users were not able to upload files larger than 50MB file which we can resolve easily by updating Web Application settings; however, users were getting Timeout exceptions as well. Furthermore, business told us that business requirement is to be able to upload up to 100MB files.
There are few simple configurations setting those needs to do in order to upload large files in to SharePoint document libraries….
1- Go to Start –> All Programs -> Administrative Tools –> SharePoint 3.0 Central Administration -> Applications Management. 2- Go to Web application general settings under SharePoint Web Application Management section. 3- Look for Maximum Upload Size and update that field as required up to 2 GB (2047MB) 4- Click OK to save Settings.
1- Open Command Prompt 2- Navigate to 12 Hive Bin Folder (usually C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\Bin) 3- Run Command: Stsadm.exe –o setproperty –pn large–file–chunk–size –pv <Size in Bytes> 4- After making a change to this property, you must restart IIS. You can restart IIS by typing iisreset on the command line.
By default, timeout for is set to 120 seconds (2 minutes). Depending on your maximum file size and how long it takes for the file to be uploaded, you may not need to change this setting. If, however, IIS is timing out when you upload large files, you can change this property to ensure that larger files can be uploaded successfully.
1- Go to Start –> All Programs -> Administrative Tools –> Internet Information Services (IIS) Manager. 2- Right-click the virtual server you want to configure, and then click Properties. 3- Click the Web Site tab. 4- In the Connections section, in the Connection timeout box, type the number of seconds you want IIS to wait before timing out. 5- Click OK to save settings.
Those who are working in SPS 2003 and want to make changes for web parts, please have a look to this article and find Configuring Large File Support.
If large files needs to be crawl then we need to make following changes in the Registry and central administration.
1- Start Registry Editor (Start –> Run –> Regedit). 2- Locate the following key in the registry: HKEY_LOCAL_MACHINE -> SOFTWARE –> Microsoft –> Office Server -> 12.0 –> Search –> Global –> Gathering Manager 3- If already MaxDownloadSize exits then move to step 5. 4- Right click –> New –> DWORD Value. Name it MaxDownloadSize. 5- Double-click on MaxDownloadSize, change the value to Decimal, and type the maximum size (in MB) for files that the gatherer downloads. 6- Restart the server (this is an important step to do, otherwise changes will not effect). 7- Start Full Crawl.
NOTE: Increasing the file size may cause a timeout exception because the crawler can timeout if the file takes too long to crawl/index (because of its size). To increase timeout value, follow these steps:
1- Go to Start –> All Programs -> Administrative Tools –> SharePoint 3.0 Central Administration -> Applications Management. 2- In the Search section, click Manage search service 3- On the Manage Search Service page, in the Farm-Level Search Settings section, click Farm-level search settings. 4- In the Timeout Settings section change Connection and Request acknowledgement time. (here you need to do your math that how big files are suppose to be index and approximately how long it will take to crawl – for 100MB I haven’t change it so it’s still default 60 seconds for both).
You are all done and ready to test your scenarios :).
Enjoy!!!