Tuesday, February 17, 2009

A solution to "An unexpected error has occurred" in WSS v3

Debugging SharePoint can be problematic at times, it does like to hide debugging information from you. The bain of my life recently has been “An unexpected error has occurred” with nothing written to log files, trace or the event log.


Normally I can debug the problem with a little commenting & narrowing down of the problem, but today I have managed to get rid of that error screen completely.


The solution is to change a single entry in web.config, by modifying the line…


<SafeMode MaxControls=“200“ CallStack=“false“…


to…


<SafeMode MaxControls=“200“ CallStack=“true“…



You will also need to set custom errors to 'Off' .


<customErrors mode=“Off“/>


You will no longer see the “An unexpected error has occurred” error page and instead you get a lovely ’standard ASP.Net error page’ with the stack trace and everything…development has got that little bit easier!!

Monday, February 9, 2009

Event 10016: The application-specific permission settings do not grant Local Launch permission for the COM Server application


  1. Go to Start - Run, and type regedit, and press enter

  2. Locate and then click the following registry subkey:

    HKEY_CLASSES_ROOT\CLSID\CLSID value

    Note In this subkey, “CLSID value” is a placeholder for the CLSID information that appears in the event error. I.e. in case of Sharepoint, the CLSID would be {61738644-F196-11D0-9953-00C04FD919C1},

  3. Double-click on AppID in the right pane, .

    A dialog box appears. Leave this box open

  4. Go to Start - Run, and type dcomcnfg, and press enter

  5. In the Component Services window, go to Component Services, go to Computers, go to My Computer, and then click DCOM Config.

  6. In the details pane, locate the program by using the friendly name, then choose Properties by right clicking on it

  7. At the Security tab, in the Launch and Activation Permissions area, click Customize, and then click the Edit button.

  8. Add the Local Service or Network Service account by clicking the Add button, typing the user’s account name (Local Service or Network Service, this depends on whats in your event error), and then clicking OK.

  9. Select the account name you just added, click to select the Allow check boxes for the following items:

    • Local Launch

    • Remote Launch

    • Local Activation

    • Remote Activation

  10. Click OK two times and quit the registry editor

Wednesday, February 4, 2009

Save and retrive the value in ViewState object before the PostBack

//Save the value in ViewState object before the PostBack
ViewState["SomeVar"] = txtFirstName.text;

//Retrieve the value from ViewState object after the PostBack
String strFirstName = ViewState["SomeVar"].ToString();