zoukankan      html  css  js  c++  java
  • (转)Support answers on sandboxed solutions in SharePoint 2010

    This article details some aspects of sandbox solution usage with Sharepoint 2010 RTM.

    Detailed steps to setup sandbox solutions are available at http://technet.microsoft.com/en-us/library/ee704543(office.14).aspx

    Process and SandBoxing

    Q: In which process does a sandbox solution execute?

    A: executable is C:\program files\Common Files\Microsoft Shared\Web Server Extensions\14\UserCode\SPUCWorkerProcess.exe

    Q: In VisualStudio, I receive “Error occurred in deployment step 'Activate Features': Cannot start service SPUserCodeV4 on computer '<myserver>'.

    A: Verify that the service “Microsoft SharePoint Foundation Sandboxed Code Service” is running. Its status can be verified in Central Administration \ System Settings \ Manage Services on this server.

    Q: How to check if a solution was sandboxed when an exception occurred?

    A: if call stack contains

    SPUCWorkerProcess.exe!Microsoft.SharePoint.UserCode.SPUserCodeApplicationHostAppDomainRef.ExecuteWrapper

    The solution ran in a sandbox.

    Q: How to recycle the sandbox process ?

    A: the SPUCWorkerProcess.exe process is recycled when stopping & restarting the “Microsoft SharePoint Foundation Sandboxed Code Service” service.

    Sandboxing and DLLs…

    Q: How to visualize the object model available for a sandbox solution?

    A: the object model is viewable with object explorer on c:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\UserCode\assemblies\Microsoft.SharePoint.dll. Only available methods are displayed. For example, the non-authorized method Microsoft.SharePoint.Utilities.SPUtility.SendEmail() is not displayed. But the available Microsoft.SharePoint.Utilities.SPUtility.StringToUInt64() is displayed.

    Q: From which folder is my DLL loaded when my solution runs in a sandbox?

    A: the DLL is loaded from C:\ProgramData\Microsoft\SharePoint\UCCache\<some characters>\<myassembly>.dll

    Q: What happens when a non-authorized method is called ?

    A: an exception is generated. For example, in a webpart, you see:

    Web Part Error: Unhandled exception was thrown by the sandboxed code wrapper's Execute method in the partial trust app domain: An unexpected error has occurred.

    Detailed error below (the exception is in maroon color) :

    [SPUserCodeSolutionExecutionFailedException: Une exception non gérée a été générée par la méthode Execute du wrapper de code en mode bac à sable dans le domaine d’application de confiance partielle : Une erreur inattendue s'est produite.]
    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)
    [MissingMethodException: Method not found: 'Void Microsoft.SharePoint.Utilities.SPUtility.GetNTFullNameandEmailfromLogin(Microsoft.SharePoint.SPWeb, System.String, System.String ByRef, System.String ByRef)'.]
      at SBWebPArt5_Login_Sable.Login_WebPArt5_Sable.Login_WebPArt5_Sable.<>c__DisplayClass1.b__0(Object , EventArgs )
      at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
      at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
      at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
      at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
      at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

    ULS log contains an entry for SPUCWorkerProcess.exe and also an entry for SPUCHostService.exe:

    04/29/2010 16:47:46.22     SPUCWorkerProcess.exe (0x1530)              0x1780    SharePoint Foundation             Sandboxed Code Service     

          fe8s    Medium       -  - Unhandled exception was thrown by the sandboxed code wrapper's Execute method in the partial trust

    app domain: An unexpected error has occurred. - userCodeWrapperType = "Microsoft.SharePoint.UserCode.SPUserCodeWebPartWrapper",

    userAssemblyGroupId = "3F74E8EE99624C358005954B7BD10334-idjGV+/yzfqv3u+SsMvNh/QyrYW23cR2ErgVPMa+clc=", siteCollectionId = "22b46f56-a5c1-

    47cc-b55f-fdb9b369ca19" - Inner Exception: Microsoft.SharePoint.UserCode.SPUserCodeSolutionProxiedException: Exception of type

    'System.Web.HttpUnhandledException' was thrown. ---> Microsoft.SharePoint.UserCode.SPUserCodeSolutionProxiedException: Method not found:

    'Void Microsoft.SharePoint.Utilities.SPUtility.GetNTFullNameandEmailfromLogin(Microsoft.SharePoint.SPWeb, System.String, System.String

    ByRef, System.String ByRef)'.
    at SBWebPArt5_Login_Sable.Login_WebPArt5_Sable.Login_WebPArt5_Sable.<>c__DisplayClass1.<CreateChildControls>b__0(Object , EventArgs )    

    at System.Web.UI.WebControls.Button.OnClick(EventArgs e)     at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)  

      at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)    
    at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)    
    at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)    

    --- End of inner exception stack trace ---   

    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)    

    04/29/2010 16:47:46.29     SPUCHostService.exe (0x0548)                0x13B8    SharePoint Foundation             Sandboxed Code Service     

          fe3r    Medium       -  - Unhandled exception was thrown by the sandboxed code wrapper's Execute method in the partial trust

    app domain: An unexpected error has occurred. - Monitored process "ipc://ef45c9b0-c020-4920-a200-434242116856:7000" has encountered an

    unhandled exception while executing user code. - Inner Exception: Microsoft.SharePoint.UserCode.SPUserCodeSolutionProxiedException:

    Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> Microsoft.SharePoint.UserCode.SPUserCodeSolutionProxiedException:

    Method not found: 'Void Microsoft.SharePoint.Utilities.SPUtility.GetNTFullNameandEmailfromLogin(Microsoft.SharePoint.SPWeb, System.String,

    System.String ByRef, System.String ByRef)'.    
    at SBWebPArt5_Login_Sable.Login_WebPArt5_Sable.Login_WebPArt5_Sable.<>c__DisplayClass1.<CreateChildControls>b__0(Object , EventArgs )    

    at System.Web.UI.WebControls.Button.OnClick(EventArgs e)    
    at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)    
    at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)    
    at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)    
    at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)    
    --- End of inner exception stack trace ---   

    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)

    Note: GetNTFullNameandEmailfromLogin is the method called in this example.

    转:http://blogs.msdn.com/b/vincent_runge/archive/2010/05/12/support-answers-on-sandboxed-solutions-in-sharepoint-2010.aspx

  • 相关阅读:
    中台微服务了,那前端如何进行架构设计?
    单体架构&微服务架构&中台服务架构
    SpringCloud oauth2 jwt gateway demo
    SpringCloud-技术专区-认证服务操作
    SpringBoot集成SpringSecurity+CAS
    内核空间与用户空间的通信方式
    函数调用的细节实现
    Kmalloc可以申请的最大内存
    内核调试和系统调用劫持
    stm32最小系统制作(原理图,PCB图,焊接等)
  • 原文地址:https://www.cnblogs.com/KingStar/p/1934614.html
Copyright © 2011-2022 走看看