IDeploymentStep.CanExecute Method
Determines whether the deployment step can be executed in the current context.
Namespace: Microsoft.VisualStudio.SharePoint.Deployment
Assembly: Microsoft.VisualStudio.SharePoint (in Microsoft.VisualStudio.SharePoint.dll)
Syntax
'Declaration
Function CanExecute ( _
context As IDeploymentContext _
) As Boolean
bool CanExecute(
IDeploymentContext context
)
Parameters
context
Type: Microsoft.VisualStudio.SharePoint.Deployment.IDeploymentContextAn object that provides information you can use to determine the context in which the deployment step is executing.
Return Value
Type: Boolean
true if the deployment step can be executed; otherwise, false.
Remarks
This method is executed from the UI thread when a SharePoint project is retracted by using the Retract option on the Build menu in Visual Studio. This method is executed from a background thread in the following cases:
When a project is automatically retracted after debugging. This occurs when the Auto-retract after debugging property on the SharePoint tab of the project properties is selected.
When a project is deployed.
Some APIs in the Visual Studio object model might not work as expected from a background thread. If you need to call one of these APIs from the CanExecute method, you can marshal the call to the UI thread by using a SynchronizationContext object. In your implementation of the Initialize method, use the Current property to get the SynchronizationContext of the UI thread. Then, in your implementation of the CanExecute method, use the Post or Send methods of the SynchronizationContext object to marshal the call to the UI thread.
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.
See Also
Reference
Microsoft.VisualStudio.SharePoint.Deployment Namespace
Other Resources
Walkthrough: Creating a Custom Deployment Step for SharePoint Projects