I started using VSeWSS as a support tool to develop a WSS/SharePoint application and I had to face some common issues. Sometimes when you try to ‘build and deploy’ - hum...this sentence sounds somewhat familiar :D - your solution you’ll get this exception reported (in the detailed log that VSeWSS emits):
System.Security.SecurityException: Access denied.
at Microsoft.SharePoint.Tools.Reflection.ReflectionUtility.InvokeMethod(MethodBase method, Object instance, Object parameters)
at Microsoft.SharePoint.Tools.Reflection.ReflectionUtility.InvokeMethod(Type type, String methodName, Object instance, Object parameters)
at Microsoft.SharePoint.Tools.SharePointProxies.SPProxy.InvokeMethod(String name, Object parameters)
at Microsoft.SharePoint.Tools.SharePointProxies.SPSolutionCollectionProxy.Add(String path)
at Microsoft.SharePoint.Tools.SharePointProxies.SPSolutionFacade.AddSolution(String url, String solutionFilePath, Boolean solutionContainsWebApplicationResource)
at VSeWSS.Server.Services.SPService.AddSolution(String url, String solutionFilePath, Boolean solutionContainsWebApplicationResource)
The Zone of the assembly that failed was:
As you can see you do not have many clues on what’s going on under the hood...It must be a problems related to the permissions under which the User related to the application pool under which the VSeWSS web service runs. In my case it runs with the same application pool of the SharePoint Central Administration Console, and it uses a custom user I called SharePointDB (take a look at my old series of articles about how to setup WSS/SharePoint).
For the things to work correctly this user must be a member of the following groups: Administrators, WSS_ADMIN_WPG, WSS_RESTRICTED_WPG.
Edit: Romeo Pruno (http://www.nonaka.eu/) pointed me out that the same problem can happen if the current user (or the account under which you run Visual Studio) is not a WSS/SharePoint Farm administrator.
After changing the Groups to which the user is associated to, perform an ‘iisreset’ and then try to deploy the project again.