Implementing Exception Handling Application Block in custom web parts, event receivers

hi,
  I am currently implementing try {} catch(Exception expp) { throw expp;} to handle exceptions in my intranet appln.
I have several custom web parts, event receivers, few console applciations as timer jobs etc. If i want to implement a  robust exception handling what should be  the approach. by searching, i saw, ms patterns n practices provides the
appln blocks.
But I think[ pls correct me if i am wrong ] those  appln blocks are meant for asp.net applns ONLY.
if not, anyone has implemented those appln blocks in SP development? if yes, can anyone provide one sample /  link to implement Exception Handling in SP.
help is appreciated! 

Hi,
Here are some articles for your reference:
Handling Error Centrally in a SharePoint Application
http://www.codeproject.com/Articles/26236/Handling-Error-Centrally-in-a-SharePoint-Applicati
Using Microsoft Enterprise Library Application Block in SharePoint
http://www.codeproject.com/Articles/21389/Using-Microsoft-Enterprise-Library-Application-Blo
Exception Handling in SharePoint
http://spmatt.wordpress.com/2012/02/01/exception-handling-in-sharepoint/
Best Regards
Dennis Guo
TechNet Community Support

Similar Messages

  • Best Practice for Implementing Exception Handling in BPEL

    Hi All,
    what is the best practice and the approach to follow Exception Handling in BPEL.
    1) Do we need to implement Exception Handling in BPEL as we do in Java, means
         method 3 throws error to method 2 (if any) and
         method 2 throws error to method 1 (if any) and
         finally method 1 throws error to the main Class.
    If we replicate the above scenario to BPEL
    In BPEL main Scope have Custom Fault, Catch ALL
         Each Invoke is surrounded by a Scope Activity with Remote Fault, Binding Fault & Custom Fault
    and follow the paradigm of Java, assuming we have Inner Scopes
         [ OR ]
    2) In BPEL main Scope have all exceptions defined like
         Remote Fault,
         Binding Fault,
         anyOther System Fault (selectionFailure / forcedTermination),
         Custom Fault (if required) and
         CatchALL
         and also
         each Invoke is surrounded by a Scopes Acitivity with Custom Fault (business fault) exception Handling
    I feel 1st one may not be a good practice, may be i am wrong...
    Any Suggestions from experts.
    Thanks in Advance
    anvv sharma

    Hi-
    In you can create different scope and use catch branch to catch binding, remote, custom faults, business faults etc. If an error happens in a scope it will not move to the next scope( eg: you have 3 scope, error occured in 2nd scope then it will not propogate to the 3rd scope. One thing to be noticed here is your transaction in the 1st scope doesnt gets commited when an error happens in 2d scope).
    You can have a catch all to catch error which are not being caught at catch level. So if any error happens which is not defined in catch block then then it will be caught in catch all branch.
    Edited by: 333333 on Apr 12, 2011 9:39 AM

  • Never implemented exception handling  in Stored Procedures

    I have lots of stand alone stored procedures callled from .NET 20 programs that follow the following pattern. They runn against Oracle 10.2 on Win2003. The only deviiation is a couple where I insert to temptables. I specify a parameter for messages but don't know the best way to implement for Oracle as well as any tips on ODP.NET/oracle interactions error handling.
    1. Is it recommended to implement exception handling in With Clauses?
    2. If there is an exception in one cursor's SQL, how do I still execute the second?
    3. Is it best in some circumstances to pass a null back to client and check for null in program?
    From .NET programs I have run into a couple of problems.
    4. TNS packet failure.
    Anyways any suggestions or experiences are welcome.
    CREATE OR REPLACE  PROCEDURE   GET_SALES_DATA
                      ,   p_businessdate      in   date                 
                      ,   p_message         out varchar2     
                      ,   p_rcSales             out sys_refcursor
                      ,   p_rInventory            out sys_refcursor
    ) is
    open p_rcSales for
    with somedata as (select ...)
    , someMoreData as (selct ...)
    -- Main select
    Select * from somedata sd inner join somemoredata  smd on smd.key   = sd.key;
    open p_rcInventory for
    with somedata as (select ...)
    , someMoreData as (selct ...)
    -- Main select
    Select * from somedata sd inner join somemoredata  smd on smd.key   = sd.key;
    -- CODE NOT IMPLEMENTED
    -- exception 
    -- when TOO_MANY_ROWS  then  select 'Error handling for future implementations' into p_message from dual ;
    -- when NO_DATA_FOUND  then  select 'Error handling for future implementations. No data'  into p_message from dual;
    -- when others         then  raise_application_error(-20011,'Unknown Exception in GET_SALES_DATA Function');
    -- WHEN invalid_business_date then  select 'Invalid: Business date is in the current work week.' into p_message from dual ;
    END GET_SALES_DATA;Pseudocode'ish because Module level variables and properties have not been defined here for brevity.
    Public Class WebPage1
    PAge_Load
       GetData
    End Class Data Access Layer
    Public Class DAL
    Public Sub GetOracleData()
                Dim conn As OracleConnection
                    Try
                        conn = New OracleConnection
                    Catch ex As Exception
                        Throw ex
                    End Try
                    Dim cmd As New OracleCommand
                    With cmd
                        conn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings("MyConnectionString").ToString
                        cmd.CommandText = DATABASE.GetSalesData
                        cmd.CommandType = CommandType.StoredProcedure
                        cmd.Connection = conn
                    End With
                    cmd.Connection = conn
                    Dim oparam As OracleParameter
                    oparam = cmd.Parameters.Add("p_businessdate", OracleDbType.Date)
                    oparam.Value = BusinessDate.ToString("dd-MMM-yy")
                    oparam = cmd.Parameters.Add("p_message", OracleDbType.Varchar2, ParameterDirection.Output)
                    oparam = cmd.Parameters.Add("p_rc_inven_csv", OracleDbType.RefCursor, ParameterDirection.Output)
                    oparam = cmd.Parameters.Add("p_rcSales", OracleDbType.RefCursor, ParameterDirection.Output)
                    oparam = cmd.Parameters.Add("p_rcInventory", OracleDbType.RefCursor, ParameterDirection.Output)
                    Dim Adapter As New OracleDataAdapter(cmd)
                    Try
                        Adapter.TableMappings.Add("Table", Sales)
                        Adapter.TableMappings.Add("Table1", Inventory)              
                        Adapter.Fill(dsOracleData)
                    Catch ex As OracleException
                        HandleError("Exception Retrieving Oracle Data", ex, MethodInfo.GetCurrentMethod.Name, True)
                     Finally
                        If conn.State = ConnectionState.Open Then
                            conn.Close()
                        End If
                    End Try
                    dbMessages = cmd.Parameters("p_message").ToString
                End If
                arrStatusMessages.Add("Retrieved Oracle Data Successfully")
            End Sub
           ' Original Implementation ; No longer used
            Public function GetOracleData
               Dim conn As New OracleConnection
                conn.ConnectionString = dbconn.Connectionstring
                 Dim cmd As New OracleCommand
                    With cmd
                        conn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings("MyConnectionString").ToString
                        cmd.CommandText = DATABASE.GetSalesData
                        cmd.CommandType = CommandType.StoredProcedure
                        cmd.Connection = conn
                    End With
                    cmd.Connection = conn
                    Dim oparam As OracleParameter
                    oparam = cmd.Parameters.Add("p_businessdate", OracleDbType.Date)
                    oparam.Value = BusinessDate.ToString("dd-MMM-yy")
                    oparam = cmd.Parameters.Add("p_message", OracleDbType.Varchar2, ParameterDirection.Output)
                                 oparam = cmd.Parameters.Add("p_rcSales", OracleDbType.RefCursor, ParameterDirection.Output)
                    oparam = cmd.Parameters.Add("p_rcInventory", OracleDbType.RefCursor, ParameterDirection.Output)
                    Dim Adapter As New OracleDataAdapter(cmd)
                    Try
                        Adapter.TableMappings.Add("Table", Sales)
                        Adapter.TableMappings.Add("Table1", Inventory)              
                        Adapter.Fill(dsOracleData)
                    dim dt as datatable = dsoracledata.tables("sales")
                    If IsDataNull(dt) Then
                         _errorType = DBErrorType.NullData
                    End If
                    If isDataEmpty(dt) Then
                         _errorType = DBErrorType.EmptyData
                    End If
                    _hasError = False
                Catch oraEx As OracleException
                      _ExceptionText = oraEx.Message.ToString
                    _errorType = DBErrorType.OracleException
    #If DEBUG Then
                    Throw oraEx
    #End If
                Catch zeroEx As DivideByZeroException
                    _ExceptionText = zeroEx.Message.ToString
                    _errorType = DBErrorType.DivideByZeroException
    #If DEBUG Then
                    Throw zeroEx
    #End If
                Catch oflowEx As OverflowException
                    _ExceptionText = oflowEx.Message.ToString
                    _errorType = DBErrorType.OverflowException
    #If DEBUG Then
                    Throw oflowEx
    #End If
                Catch argEx As InsufficientMemoryException
                    _ExceptionText = argEx.Message.ToString
                    _errorType = DBErrorType.InsufficientMemoryException
    #If DEBUG Then
                    Throw argEx
    #End If
                Catch nomemEx As OutOfMemoryException
                    _ExceptionText = nomemEx.Message.ToString
                    _errorType = DBErrorType.OutOfMemoryException
    #If DEBUG Then
                    Throw nomemEx
    #End If
                Catch Ex As Exception
                    _ExceptionText = Ex.Message.ToString
                    _errorType = DBErrorType.GenericException
    #If DEBUG Then
                    Throw Ex
    #End If
                Finally
                    If conn.State = ConnectionState.Open Then
                        conn.Close()
                    End If
                End Try
    End class Error Class
    Public Class Errors
           Public Sub ExitClass()
                Return
            End Sub
            ' 'blnWriteNow says when Error is critical and no further processing needs to be done by class, then write to event logs or text files and call exit class
            '  to return control back to webpage. This is my first time trying this way.
            Public Sub HandleError(ByVal friendlyMsg As String, ByVal objEx As Exception, ByVal methodInfo As String, Optional ByVal blnWriteNow As Boolean = False)
                If Not blnWriteNow Then Exit Sub
                Dim strMessages As String
                strMessages = arrStatusMessages
                'Send error email
                If  blnSendEmails Then
                     SendMail("[email protected],  strMessages. applicationname, " has thrown  error. ")
                End If
              'Throw error for   debugging
                If  blnThrowErrors Then  
                            Throw New Exception(strMessages & vbCrLf & objEx.Message)
                End If
               ' Write to event log and if not available (shared hosting environment), write to text log
                If blnWriteNow Then
                    If  blnWriteToEvtLog Then
                        If  blnCanWriteToEvtLog Then    'Program has write permission to log
                             WriteToEventLog(strMessages, _appname, EventLogEntryType.Error,  appname)
                        Else
                            If Not Directory.Exists( appPath & "\log") Then
                                Try
                                    Directory.CreateDirectory( appPath & "\log")
                                Catch ex As Exception
                                    arrStatusMessages.Add("Cant't write to event log or create a directory")
                                End Try
                            End If
                        End If
                    End If
                End If          
            End Sub
    End Class

    I have lots of stand alone stored procedures callled from .NET 20 programs that follow the following pattern. They runn against Oracle 10.2 on Win2003. The only deviiation is a couple where I insert to temptables. I specify a parameter for messages but don't know the best way to implement for Oracle as well as any tips on ODP.NET/oracle interactions error handling.
    1. Is it recommended to implement exception handling in With Clauses?
    2. If there is an exception in one cursor's SQL, how do I still execute the second?
    3. Is it best in some circumstances to pass a null back to client and check for null in program?
    From .NET programs I have run into a couple of problems.
    4. TNS packet failure.
    Anyways any suggestions or experiences are welcome.
    CREATE OR REPLACE  PROCEDURE   GET_SALES_DATA
                      ,   p_businessdate      in   date                 
                      ,   p_message         out varchar2     
                      ,   p_rcSales             out sys_refcursor
                      ,   p_rInventory            out sys_refcursor
    ) is
    open p_rcSales for
    with somedata as (select ...)
    , someMoreData as (selct ...)
    -- Main select
    Select * from somedata sd inner join somemoredata  smd on smd.key   = sd.key;
    open p_rcInventory for
    with somedata as (select ...)
    , someMoreData as (selct ...)
    -- Main select
    Select * from somedata sd inner join somemoredata  smd on smd.key   = sd.key;
    -- CODE NOT IMPLEMENTED
    -- exception 
    -- when TOO_MANY_ROWS  then  select 'Error handling for future implementations' into p_message from dual ;
    -- when NO_DATA_FOUND  then  select 'Error handling for future implementations. No data'  into p_message from dual;
    -- when others         then  raise_application_error(-20011,'Unknown Exception in GET_SALES_DATA Function');
    -- WHEN invalid_business_date then  select 'Invalid: Business date is in the current work week.' into p_message from dual ;
    END GET_SALES_DATA;Pseudocode'ish because Module level variables and properties have not been defined here for brevity.
    Public Class WebPage1
    PAge_Load
       GetData
    End Class Data Access Layer
    Public Class DAL
    Public Sub GetOracleData()
                Dim conn As OracleConnection
                    Try
                        conn = New OracleConnection
                    Catch ex As Exception
                        Throw ex
                    End Try
                    Dim cmd As New OracleCommand
                    With cmd
                        conn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings("MyConnectionString").ToString
                        cmd.CommandText = DATABASE.GetSalesData
                        cmd.CommandType = CommandType.StoredProcedure
                        cmd.Connection = conn
                    End With
                    cmd.Connection = conn
                    Dim oparam As OracleParameter
                    oparam = cmd.Parameters.Add("p_businessdate", OracleDbType.Date)
                    oparam.Value = BusinessDate.ToString("dd-MMM-yy")
                    oparam = cmd.Parameters.Add("p_message", OracleDbType.Varchar2, ParameterDirection.Output)
                    oparam = cmd.Parameters.Add("p_rc_inven_csv", OracleDbType.RefCursor, ParameterDirection.Output)
                    oparam = cmd.Parameters.Add("p_rcSales", OracleDbType.RefCursor, ParameterDirection.Output)
                    oparam = cmd.Parameters.Add("p_rcInventory", OracleDbType.RefCursor, ParameterDirection.Output)
                    Dim Adapter As New OracleDataAdapter(cmd)
                    Try
                        Adapter.TableMappings.Add("Table", Sales)
                        Adapter.TableMappings.Add("Table1", Inventory)              
                        Adapter.Fill(dsOracleData)
                    Catch ex As OracleException
                        HandleError("Exception Retrieving Oracle Data", ex, MethodInfo.GetCurrentMethod.Name, True)
                     Finally
                        If conn.State = ConnectionState.Open Then
                            conn.Close()
                        End If
                    End Try
                    dbMessages = cmd.Parameters("p_message").ToString
                End If
                arrStatusMessages.Add("Retrieved Oracle Data Successfully")
            End Sub
           ' Original Implementation ; No longer used
            Public function GetOracleData
               Dim conn As New OracleConnection
                conn.ConnectionString = dbconn.Connectionstring
                 Dim cmd As New OracleCommand
                    With cmd
                        conn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings("MyConnectionString").ToString
                        cmd.CommandText = DATABASE.GetSalesData
                        cmd.CommandType = CommandType.StoredProcedure
                        cmd.Connection = conn
                    End With
                    cmd.Connection = conn
                    Dim oparam As OracleParameter
                    oparam = cmd.Parameters.Add("p_businessdate", OracleDbType.Date)
                    oparam.Value = BusinessDate.ToString("dd-MMM-yy")
                    oparam = cmd.Parameters.Add("p_message", OracleDbType.Varchar2, ParameterDirection.Output)
                                 oparam = cmd.Parameters.Add("p_rcSales", OracleDbType.RefCursor, ParameterDirection.Output)
                    oparam = cmd.Parameters.Add("p_rcInventory", OracleDbType.RefCursor, ParameterDirection.Output)
                    Dim Adapter As New OracleDataAdapter(cmd)
                    Try
                        Adapter.TableMappings.Add("Table", Sales)
                        Adapter.TableMappings.Add("Table1", Inventory)              
                        Adapter.Fill(dsOracleData)
                    dim dt as datatable = dsoracledata.tables("sales")
                    If IsDataNull(dt) Then
                         _errorType = DBErrorType.NullData
                    End If
                    If isDataEmpty(dt) Then
                         _errorType = DBErrorType.EmptyData
                    End If
                    _hasError = False
                Catch oraEx As OracleException
                      _ExceptionText = oraEx.Message.ToString
                    _errorType = DBErrorType.OracleException
    #If DEBUG Then
                    Throw oraEx
    #End If
                Catch zeroEx As DivideByZeroException
                    _ExceptionText = zeroEx.Message.ToString
                    _errorType = DBErrorType.DivideByZeroException
    #If DEBUG Then
                    Throw zeroEx
    #End If
                Catch oflowEx As OverflowException
                    _ExceptionText = oflowEx.Message.ToString
                    _errorType = DBErrorType.OverflowException
    #If DEBUG Then
                    Throw oflowEx
    #End If
                Catch argEx As InsufficientMemoryException
                    _ExceptionText = argEx.Message.ToString
                    _errorType = DBErrorType.InsufficientMemoryException
    #If DEBUG Then
                    Throw argEx
    #End If
                Catch nomemEx As OutOfMemoryException
                    _ExceptionText = nomemEx.Message.ToString
                    _errorType = DBErrorType.OutOfMemoryException
    #If DEBUG Then
                    Throw nomemEx
    #End If
                Catch Ex As Exception
                    _ExceptionText = Ex.Message.ToString
                    _errorType = DBErrorType.GenericException
    #If DEBUG Then
                    Throw Ex
    #End If
                Finally
                    If conn.State = ConnectionState.Open Then
                        conn.Close()
                    End If
                End Try
    End class Error Class
    Public Class Errors
           Public Sub ExitClass()
                Return
            End Sub
            ' 'blnWriteNow says when Error is critical and no further processing needs to be done by class, then write to event logs or text files and call exit class
            '  to return control back to webpage. This is my first time trying this way.
            Public Sub HandleError(ByVal friendlyMsg As String, ByVal objEx As Exception, ByVal methodInfo As String, Optional ByVal blnWriteNow As Boolean = False)
                If Not blnWriteNow Then Exit Sub
                Dim strMessages As String
                strMessages = arrStatusMessages
                'Send error email
                If  blnSendEmails Then
                     SendMail("[email protected],  strMessages. applicationname, " has thrown  error. ")
                End If
              'Throw error for   debugging
                If  blnThrowErrors Then  
                            Throw New Exception(strMessages & vbCrLf & objEx.Message)
                End If
               ' Write to event log and if not available (shared hosting environment), write to text log
                If blnWriteNow Then
                    If  blnWriteToEvtLog Then
                        If  blnCanWriteToEvtLog Then    'Program has write permission to log
                             WriteToEventLog(strMessages, _appname, EventLogEntryType.Error,  appname)
                        Else
                            If Not Directory.Exists( appPath & "\log") Then
                                Try
                                    Directory.CreateDirectory( appPath & "\log")
                                Catch ex As Exception
                                    arrStatusMessages.Add("Cant't write to event log or create a directory")
                                End Try
                            End If
                        End If
                    End If
                End If          
            End Sub
    End Class

  • Best Practices in SharePoint 2010 ( Out of the box feature vs Custom Web Part, development )

    Hi
    How do we differentiate on when to allow custom web parts and when to use out of the box.
    What are the performance issues involved when we deploy a custom web part into the SharePoint server. 
    Why do some companies prefer to allow only out of the box features, and no custom work is done?

    SharePoint is a powerful, flexible server product that can provide a wealth collaboration environment right out of box.
    Best answer for your question is depend upon your requirement. Sometime Out of Box features will solve all the problem with little designing. But sometime your requirement need a Custom Web part / solution.
    With OOTB implementation the big advantage is easy to trouble shoot & fix the issues. You will also found tons of blogs on internet for OOTB features. In custom development, its hard to troubleshoot & identifying whether its SharePoint issue or Custom
    code issue.
    check the below article for more ideas.
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/1e7845ef-61e0-4d01-bb6c-92519e6d7139/sharepoint-2010-outofbox-best-practices?forum=sharepointgeneralprevious
    http://www.cdh.com/media/articles/Pages/SharePoint-out-of-the-box---To-customize-or-not-to-customize.aspx
    Master List of SharePoint 2010 On-Premises Custom Development Best Practices
    http://i.zdnet.com/whitepapers/Quest_WPW_SharepointDev_Custom_US_KS_v3.pdf
    Please remember to mark your question as answered &Vote helpful,if this solves/helps your problem. ****************************************************************************************** Thanks -WS MCITP(SharePoint 2010, 2013) Blog: http://wscheema.com/blog

  • Custom web parts in SharePoint 2013 becomes inactive when the session is idle for long time.

    Hi,
    We have a search center site with custom web parts and custom master pages. When the session is inactive for long time all the custom web parts in the page doesn't work, unless we close the browser and open it. Where as this is not the case with the
    OOB web parts. We are not able to identify the root cause as it works with OOB web parts and not the custom web parts.We were able to find that by increasing the session timeout of the web application we can avoid this issue.We do not want to increase the
    session timeout as the OOB web part works perfectly even when the user session is idle for long time.Is there any other alternative where we can acheive the same for custom web parts when the session is idle for long time?
    Thanks,
    Saranya

    Hi Saranya,
    According to your descirption, my understanding is that when the session is long time idle ,then custom web part will not work.
    I suggest you check if you have enable the session in the Page Level in the web.config. By default SharePoint disable the session state.
    In the web.config, you will see <page enableSessionState> tag. You can modify like below and test if it works.
    <pages enableSessionState=”true” ….. />
    Here is a detailed thread for your reference:
    Use Session State in SharePoint
    Best Regards
    Zhengyu Guo
    TechNet Community Support

  • Error:System.Web.HttpUnhandledException in Custom Web part for Sandbox solution

    Please Help...
    I have a sandbox solution for Custom Web part which has a 'Visual Web Part(sandbox)'.
    The solution builds, Packages & deploys successfully.
    But when adding this custom web part on a Sharepoint 'Web Part Page' it throws up the below Error:
    Same code when deployed as a Farm Solution works all well.
    Only difference between the two solutions being Farm solution has  'Visual web part'
    and Sandbox solution has 'Visual web part(sandbox)'
    ERROR:
    ======================================================
    [SPUserCodeSolutionExecutionFailedException: Unhandled exception was thrown by the sandboxed code wrapper's Execute method in the partial trust app domain: An unexpected error has occurred.]
     Server stack trace:
      at Microsoft.SharePoint.UserCode.SPUserCodeApplicationHostAppDomainRef.Execute(Type userCodeWrapperType, SPUserCodeCachedAssemblyGroup userAssemblyGroup, Guid siteCollectionId, Byte[] binaryUserCodeToken, Byte[] proxyOperationToken, SPUserCodeExecutionContext
    executionContext)
      at Microsoft.SharePoint.UserCode.SPUserCodeApplicationHostAppDomainRef.Execute(Type userCodeWrapperType, SPUserCodeCachedAssemblyGroup userAssemblyGroup, Guid siteCollectionId, Byte[] binaryUserCodeToken, Byte[] proxyOperationToken, SPUserCodeExecutionContext
    executionContext)
      at Microsoft.SharePoint.UserCode.SPUserCodeAppDomain.Execute(Type userCodeWrapperType, SPUserCodeCachedAssemblyGroup userAssemblyGroup, Guid siteCollectionId, Byte[] binaryUserCodeToken, Byte[] proxyOperationToken, SPUserCodeExecutionContext executionContext)
      at Microsoft.SharePoint.UserCode.SPUserCodeWorkerProcessProxyForShim.ExecuteInternal(Type userCodeWrapperType, SPUserCodeCachedAssemblyGroup userAssemblyGroup, Guid siteCollectionId, Byte[] binaryUserCodeToken, Byte[] proxyOperationToken, SPUserCodeExecutionContext
    executionContext)
      at Microsoft.SharePoint.UserCode.SPUserCodeWorkerProcessProxy.Execute(Type userCodeWrapperType, SPUserCodeCachedAssemblyGroup userAssemblyGroup, Guid siteCollectionId, Byte[] binaryUserCodeToken, Byte[] proxyOperationToken, SPUserCodeExecutionContext
    executionContext)
      at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
      at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)
     Exception rethrown at [0]:
      at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
      at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
      at Microsoft.SharePoint.UserCode.SPUserCodeWorkerProcess.ExecuteDelegate.EndInvoke(IAsyncResult result)
      at Microsoft.SharePoint.UserCode.SPUserCodeWorkerProcess.Execute(Type userCodeWrapperType, SPUserCodeCachedAssemblyGroup userAssemblyGroup, Guid siteCollectionId, SPUserToken userToken, String currentAffinity, SPUserCodeExecutionContext executionContext)
      at Microsoft.SharePoint.UserCode.SPUserCodePoolableProcessConnection.Execute(Type userCodeWrapperType, SPUserCodeCachedAssemblyGroup userAssemblyGroup, Guid siteCollectionId, SPUserToken userToken, String affinity, SPUserCodeExecutionContext executionContext)
      at Microsoft.SharePoint.UserCode.SPUserCodeExecutionHost.Execute(Type userCodeWrapperType, Guid siteCollectionId, SPUserToken userToken, String affinity, SPUserCodeExecutionContext executionContext)
      at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
      at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)
     Exception rethrown at [1]:
      at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
      at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
      at Microsoft.SharePoint.Administration.ISPUserCodeExecutionHostProxy.Execute(Type userCodeWrapperType, Guid siteCollectionId, SPUserToken userToken, String affinityBucketName, SPUserCodeExecutionContext executionContext)
      at Microsoft.SharePoint.UserCode.SPUserCodeExecutionManager.Execute(Type userCodeWrapperType, SPSite site, SPUserCodeExecutionContext executionContext)
      at Microsoft.SharePoint.UserCode.SPUserCodeWebPartRemoteExecutionHelper.<>c__DisplayClassa.b__9()
      at Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode)
      at Microsoft.SharePoint.UserCode.SPUserCodeWebPartRemoteExecutionHelper.ExecuteRequestInSandBox(HttpContext context, SPWeb web, SPWebPartManager manager, SPUserCodeWebPart userCodeWebPart)
    [HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown.]
     Server stack trace:
      at System.Web.UI.Page.HandleError(Exception e)
      at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
      at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
      at System.Web.UI.Page.ProcessRequest()
      at System.Web.UI.Page.ProcessRequest(HttpContext context)
      at Microsoft.SharePoint.UserCode.SPUserCodeWebPartWrapper.ExecuteHttpRequest(SPUserCodeWebPartHttpRequestContext webPartExecutionContext, SPUserCodeWebPartHttpResponse httpRequestResponse)
      at Microsoft.SharePoint.UserCode.SPUserCodeWebPartWrapper.Execute(SPUserCodeExecutionContext executionContext)
      at Microsoft.SharePoint.UserCode.SPUserCodeApplicationHostAppDomainRef.ExecuteWrapper(SPUserCodeWrapper wrapper, SPUserCodeExecutionContext executionContext)
      at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
      at System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink)
     Exception rethrown at [0]:
      at System.Runtime.Remoting.Proxies.RealProxy.EndInvokeHelper(Message reqMsg, Boolean bProxyCase)
      at System.Runtime.Remoting.Proxies.RemotingProxy.Invoke(Object NotUsed, MessageData& msgData)
      at Microsoft.SharePoint.UserCode.SPUserCodeApplicationHostAppDomainRef.CodeToExecuteWrapper.EndInvoke(IAsyncResult result)
      at Microsoft.SharePoint.UserCode.SPUserCodeApplicationHostAppDomainRef.Execute(Type userCodeWrapperType, SPUserCodeCachedAssemblyGroup userAssemblyGroup, Guid siteCollectionId, Byte[] binaryUserCodeToken, Byte[] proxyOperationToken, SPUserCodeExecutionContext
    executionContext)
    [InvalidOperationException: Using Menu.DynamicHoverStyle requires Page.Header to be non-null (e.g. <head runat="server" />).]
      at System.Web.UI.WebControls.Menu.EnsureRenderSettings()
      at System.Web.UI.WebControls.Menu.OnPreRender(EventArgs e, Boolean registerScript)
      at System.Web.UI.Control.PreRenderRecursiveInternal()
      at System.Web.UI.Control.PreRenderRecursiveInternal()
      at System.Web.UI.Control.PreRenderRecursiveInternal()
      at System.Web.UI.Control.PreRenderRecursiveInternal()
      at System.Web.UI.Control.PreRenderRecursiveInternal()
      at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

    Hi!!
    Sure, Please find .cs and .ascx script below
    ==========.ascx===========================
    <%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
    <%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Import Namespace="Microsoft.SharePoint" %>
    <%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="DynamicMenuWP.ascx.cs" Inherits="MenuWebPartProject.DynamicMenuWP.DynamicMenuWP" %>
    <asp:Menu ID="siteStructure" runat="server" Orientation="Horizontal"  StaticPopOutImageTextFormatString="" DynamicHoverStyle-BackColor="#CBE3F0" SkipLinkText=""
                                            StaticSubMenuIndent="10px"
    BackColor="#000000" CssClass="BIMenu" Font-Names="Verdana" Font-Size="1em"  DynamicHorizontalOffset="2" onmenuitemclick="siteStructure_MenuItemClick" Target="_blank">
                                            <StaticSelectedStyle
    BackColor="#507CD1" />
              <StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" CssClass="BIMenuStaticformenu" />
              <DynamicHoverStyle BackColor="#CBE3F0" />
              <DynamicMenuStyle BackColor="#F2F3F4" BorderColor="#A7B4CE" ForeColor="Black" />
              <DynamicSelectedStyle BackColor="#507CD1" />
              <DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" CssClass="BIMenuDynamicForMenu" />
            <StaticHoverStyle BackColor="#284E98" ForeColor="White" />
    </asp:Menu>
    ==========.cs===========================
    using System;
    using System.ComponentModel;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using Microsoft.SharePoint;
    using Microsoft.SharePoint.WebControls;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    namespace MenuWebPartProject.DynamicMenuWP
        [ToolboxItem(false)]
        public partial class DynamicMenuWP : System.Web.UI.WebControls.WebParts.WebPart
            protected override void OnInit(EventArgs e)
                base.OnInit(e);
                InitializeControl();
            protected void Page_Load(object sender, EventArgs e)
                if (!IsPostBack)
                    ScorecardStructure ss;
                    List<ScorecardStructure> listSS = new List<ScorecardStructure>();
                        using (SPWeb web = SPContext.Current.Web)
                            SPList lists = web.Lists["MenuItems"];
                            if (lists.ItemCount > 0)
                                foreach (SPListItem item in lists.Items)
                                    ss = new ScorecardStructure();
                                    ss.title = Convert.ToString(item["Title"]);
                                    ss.ParentID = Convert.ToInt32(Convert.ToString(item["Parent ID"]));
                                    ss.ParentName = Convert.ToString(item["Parent Name"]);
                                    ss.MenuID = Convert.ToInt32(Convert.ToString(item["Menu ID"]));
                                    ss.menuName = Convert.ToString(item["Menu Name"]);
                                    ss.url = Convert.ToString(item["URL"]);
                                    ss.friendlyName = Convert.ToString(item["Friendly Name"]);
                                    listSS.Add(ss);
                    if (listSS.Count > 0)
                        List<ScorecardStructure> y = listSS.Where(s => s.ParentID == 0).ToList<ScorecardStructure>();
                        foreach (var x in y)
                            MenuItem newMenuItem = new MenuItem(x.menuName.ToString(), x.MenuID.ToString());
                            siteStructure.Items.Add(newMenuItem);
                            AddChildMenuItems(listSS, newMenuItem);
            private void AddChildMenuItems(List<ScorecardStructure> menuData, MenuItem parentMenuItem)
                if (menuData.Count > 0)
                    List<ScorecardStructure> childItems = menuData.Where(s => s.ParentID == Convert.ToInt32(parentMenuItem.Value)).ToList<ScorecardStructure>();
                    foreach (var v in childItems)
                        MenuItem newMenuItem = new MenuItem(v.menuName.ToString(), v.MenuID.ToString());
                        newMenuItem.NavigateUrl = v.url.ToString();
                        parentMenuItem.ChildItems.Add(newMenuItem);
                        // This code is used to recursively add child menu items filtering by ParentID
                        AddChildMenuItems(menuData, newMenuItem);
            protected void siteStructure_MenuItemClick(object sender, MenuEventArgs e)
                string st = e.Item.NavigateUrl;
                if (!(st.Equals(string.Empty)))
                    HttpContext.Current.Response.Redirect(st);
            class ScorecardStructure
                public string title { get; set; }
                public int ParentID { get; set; }
                public string ParentName { get; set; }
                public int MenuID { get; set; }
                public string menuName { get; set; }
                public string url { get; set; }
                public string friendlyName { get; set; }
            public bool IsPostBack { get; set; }

  • Custom web part in SharePoint Online for "User segments"

    Hi Experts,
    I was refferd here from the SharePoine Online community. http://community.office365.com/en-us/f/148/p/278071/851153.aspx 
    I was following this article to implement user segment in SharePoint Online http://blogs.msdn.com/b/adaptive_experiences_in_sharepoint_2013/archive/2012/11/14/set-up-user-segmentation-to-drive-adaptive-experiences-in-a-product-catalog-in-sharepoint-2013.aspx 
    However, this seems to require a custom web part to be build and deployed in SharePoint Online.
    Anyone has made user segment work in SharePoint Online? Anyone has done this custom web part before?
    Thank you,
    Aswath NS

    By default the Site Users web part shows all the users and groups who have been give direct permission to the site.  That would not include anyone who was given permission by being added to a group.  You can modify the web part settings to show
    a list of people in the Members group of the site or any other specific group.  But there is no setting to show all the users who have access.
    Paul Stork SharePoint Server MVP
    Principal Architect: Blue Chip Consulting Group
    Blog: http://dontpapanic.com/blog
    Twitter: Follow @pstork
    Please remember to mark your question as "answered" if this solves your problem.

  • How to enable a custom web part class file to be refreshed at regular interval of time, without affecting the entire page where its placed.

    Hi,
    I am calling a web service in the web part class file where it gets the data. I need to call the service at regular intervals of time which is in the web part, is there a way to get the web part refreshed automatically at certain intervals of time.
    Rayudu

    You can use Ajax for automatic refreshing.
    Add a timer control into an Ajax Update panel within your custom web part and execute your code to refresh the field values within the Timer_Tick() event.
    You can also control the timer interval to 10 minutes or so using the Timer.Interval property.
    This will always enable your page to remain with only the web parts getting refreshed.
    I just found
    a blog post which describes this in detail with screenshots.

  • SharePoint 2013 RSS Viewer not loading when other Custom web part using Update Panel or Ajax Timer control

    Hi,
    SharePoint 2013 RSS
    Viewer web part failing to complete loading when the page loads.
    This happens when having RSS Viewer and then adding a Custom webpart with an updatepanel and timer control.
    I  had used Ajax update panel and timer control to load the web part asynchronously after the main page is fully loaded.
    The RSS-Viewer web part hangs in loading state while the custom webpart loads just fine.
    The issue occurs when an like button click or Timer Tick event fires after the page
    is loaded.
    Haven't been able to track the issue.
    Couple of workaround I tried to call a server side button click event from the custom web part after the page gets fully loaded using JQuery shown below did not work out either.
     $(document).ready(function () {
                $('#<%= netButton2.ClientID %>').click();
    And 
    document.onreadystatechange = function () {
                if (document.readyState == "complete") {
                    $('#<%= netButton2.ClientID %>').click();
    Please let me know how to resolve this issue.
    Thanks,
    Franklin

    Hi Johan,
    The assignment of this user on the given task might be corrupted. Try to remove the resource from the task, publish the project, assign the resource again and publish again the project. If it is not working, try to unpublish the task (column "publish")
    and publih it again.
    Hope this helps,
    Guillaume Rouyre, MBA, MVP, P-Seller |

  • 2013 Custom Web Parts in Page Layouts not showing for users

    Custom Web Parts in Page Layouts not showing for users
    I have created a master page in the root site collection for a subsite I am developing. I created content types and custom page layouts for the pages within the subsite.
    I used the snippet tool in the design manager to create web parts and page field markup which I copied into the custom layout HTML pages in the root site collection. For instance I have an image viewer web part that I place there to serve as a section title.
    The problem is that I can see all these customer layout page parts no problem but my users cannot. This leads me to believe its permissions, I am site owner of both the subsite and root site collection.
    The users that cannot see the web parts are site members of the site and restricted read users on the root site collection (where the layouts are stored).
    What gives I'm finding it hard to understand why a snipet generated web part wouldn't show in all pages created from that layout page.
    Any help would be appreciated, Havent found anything on this issue online. weird.

    It is a permission issue indeed. Fix is simple, make sure you check out the page layout page, then check it back in as published version.
    John Architect

  • How to play share point library video in custom web part

    Hi  ,i want to play my share point library videos and computer videos  in custom web part , how can i do this ,playing static video and library video both are common.
    Thanks,
    Madhu.

    Do you want to create a player from scratch or use eg. the Silverlight media player:
    http://jomit.blogspot.de/2009/12/using-silverlight-media-player-of.html
    or   alternatively html5 and the <video> element (will probably require a couple of tweaks in the master page) ?
    Kind Regards
    Bjoern
    http://spviking.com
    Twitter: Follow @bjoern_rapp

  • How to fix javascript error/bug on custom web part of SharePoint 2013

    I have a custom web part with serveral business fields. This web part is installed on DispForm, EditForm an NewForm.
    But, I click on Attach File button and a javascrit error is throw on my browser's status bar.
    Line: 5279
    Character: 5
    Code: 0
    URI: http://mysite:4000/_layouts/15/form.debug.js?rev=vyMg8qjZfJ8La1jn7bQ2cg%3D%3D
    How to solve this problem? I think it is a javascript conflict
    Tarcísio Corte [email protected]

    Hi,
    1. You can create a simple demo web part without your custom code firstly, then insert it into your form pages to see if the similar issue would occur. If it works, then add your
    other code into it one after one. By doing this, it will be easier to find out the root cause of this issue.
    2. What browser do you use? Please try to use IE 10(SharePoint 2013), IE8(SharePoint2010).
    3. You can also debug your code using IE F12 Developer Tools.
    http://blogs.msdn.com/b/kaevans/archive/2011/04/25/debugging-javascript-with-the-ie-developer-tools.aspx
    If the issue still exists, I can suggest you provide more information for further research.
    Thanks,
    Dennis Guo
    TechNet Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Dennis Guo
    TechNet Community Support

  • Create custom web-part page with OOTB page layout using CSOM (Javascript)

    Hi,
    I need to create a custom webpart page with a OOTB page layout (eg. Header 3 column footer) using JSOM.
    I found a link to do this using CSOM: http://spdevlab.com/2013/03/28/creating-wiki-web-part-and-publishing-pages-via-csom-in-sharepoint-2010/
    But here i have to copy the page template from 15 hive and store it in a resource file and I am also getting error as "The request message is too big" and to fix this I need to run a powershell script but I need the code to run in SharePoint online
    also.
    Isn't there a simpler piece of code in which I can enter the name of the page layout(OOTB/Custom) while creating a page in JSOM as we have in SSOM?
    Thanks for the help
    sunny

    Hi,
    According to your post, my understanding is that you want to create a custom web part page layout template.
    There are some articles about how to create the custom web part page layout template, you can refer to them.
    http://www.manageprojectsonsharepoint.com/blog/2011/03/14/creating-your-own-web-part-page-layout-template/
    http://sandeeppawar.blogspot.com/2012/06/create-custom-web-part-page-template.html
    http://doitwithsharepoint.blogspot.com/2011/08/create-web-part-pages-with-custom.html
    Thanks & Regards,
    Jason
    Jason Guo
    TechNet Community Support

  • SP 2013 - Use PowerShell to Add a Custom Web Part to a Page

    Hello Community,
    I need to add a custom web part to a page using PowerShell - has anyone done this and if so please provide guidance and code examples.
    Thanks!
    Tom
    Tom Molskow - Senior SharePoint Architect - Microsoft Community Contributor 2011 and 2012 Award -
    Linked-In - SharePoint Gypsy

    BTW, here is my current code:
    #$web= Get-SPWeb -Identity "http://c4968397007/sites/BRE"
    $Url = "http://c4968397007/sites/BRE"
    $pageUrl = "/SitePages/Home"
    $webpartzone = 2
    $index = 0
    $fileName = "wp_DistrictHomePage_VisualWebPart1.webpart"
    $web = Get-SPWeb $Url
    $web.AllowUnsafeUpdates=$true
     $webPartGallery = $web.Lists["Web Part Gallery"]
     Write-Host "Searching webpart $fileName in web part gallery"
      if($webPartGallery -eq $null)
       Write-Host("Unable to retrieve Webpartgallery");
     $webpart = $null;
     $webpart=$webPartGallery.Items | ? { $_.Title -eq $fileName}
      if($webpart -eq $null) {
       Write-Host("Unable to retrieve webpart: $fileName") -ForegroundColor Red
     else {
      Write-Host("----------Adding Webpart--------")-ForegroundColor Yellow
      $webpartmanager=$web.GetLimitedWebPartManager($pageUrl, [System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)
      $errorMsg = "";
      $xmlReader = New-Object System.Xml.XmlTextReader($webpart.File.OpenBinaryStream());
      $webpart = $webpartmanager.ImportWebPart($xmlReader,[ref]"Error")
      $webpartmanager.AddWebPart($webpart, $webpartzone, $index);
      Write-Host("Webpart is added successfully") -ForegroundColor Green ;
    $SiteURL =$Url
    #---------------Test Page----------------------------
    $PageName="Test.aspx"
    $page=$web.lists["Pages"].Items | ? {$_.Name -eq $PageName}
    $page.File.CheckOut();
    Add-WebPartToPage "$SiteURL/Pages/$PageName" "Header" 0 "My Custom WebPart"
    $page.File.CheckIn("Added Web part to a page");
    $page.File.Approve("Added Web part to a page");
    Tom Molskow - Senior SharePoint Architect - Microsoft Community Contributor 2011 and 2012 Award -
    Linked-In - SharePoint Gypsy

  • How to implement Exception Handling error in IDoc to File and RFC to File

    Hi,
    We are implementing the two below scenarios :
    1. IDOC to File
    2. RFC to File
    We have to implement the Exception Handling for the above two cases. Kindly could you provide the inputs to implement the Exception Handling for the above two cases.
    Please provide the precious inputs to implement this.
    Thanks,
    Ramesh

    Hi Ramesh,
    The exception handling for idocs
    http://help.sap.com/saphelp_nw04/helpdata/en/dc/6b7f1543d711d1893e0000e8323c4f/frameset.htm
    Exception handling in File to IDoc Scenario
    For RFCs
    Re: Passing SAP Exceptions to a sync SOAP Call
    Error Handling when using RFC
    Exception Handling while Calling RFC - BPM
    handle exceptions in remote function modules
    Regards,
    Prateek

Maybe you are looking for

  • Trouble in writing Chinese Characters into database

    I'm developing a JSP web site using ACCESS2002, Tomcat4.0.4 and J2EE 1.4.1. I found my data(chinese chatacters) in mess when I wrote it in to database through sun's own JDBC-ODBC driver though it is displayed correctly in web-browser. I tried in JSP,

  • Fios install service to all the rooms in your house

    We have been fios customers for 9 Months now and Originally had just two boxes activated... Now we have decided to add a box to our daughters bedroom.. I ordered the box  set it up and activated it and nothing... Called Verizon and got the answer the

  • Type Messages and Objects turned from white to black in PDF

    When I exported my Keynote presentation to a PDF the Type Messages and Objects turned from white to black. The display in "Preview" is ok but in Acrobat PDF Viewer it looks black instead of white. Only happens on some slides. I could not find a reaso

  • Authentication Error with portal Tools

    I'm using WLS 6.1 SP1 and Portal 4.0 SP1 on solaris. I've modified everything in my configuration files to work with Oracle 8.17 instead of Cloudscape. The database has been correctly created (I've followed all the items as described in the doc) with

  • Word 2007 COM object

    I am having a heck of a time finding a good example of a word COM object. I just upgraded from word 2000 to word 2007, in hopes that would suddenly work for me (which honestly I didn't expect...). In word 2000, this line worked fine, but not in 2007: