'error activating .wsp file in sharepoint server 2010

I developed a sample application in visual studio 2010. I created an Empty SharePoint Project and gave the local site url for debugging. Checked "Deploy as Farm" as the trust level of the SharePoint solution. Added a visual webpart and also a class to the solution. I am able to build and successfully run the application using visual studio. In my local machine am using SharePoint foundation 2010 to debug the SharePoint application. Now i want to deploy this application in the SharePoint server 2010 which is in a virtual machine. 1. I copied the .wsp file of the application i created to the virtual machine. 2. From the central administrator in the VM I created a web application and the site collection. 3. Then using Site Actions -> Site Settings -> Solution(Galleries), choose the .wsp file for uploading. it showed a "Warning: You should only activate this solution if you trust this solution. An activated solution can read, modify and delete your data. " and the activate button is disabled.

Then I tried to do same in my local machine on a different site collection. Here Activate button is enabled but when clicked it threw exception

Server Error in '/' Application.

This solution contains invalid markup or elements that cannot be deployed as part of a sandboxed solution. Solution manifest for solution 'aee60282-765d-4c9f-b67a-5981f18a6d3b' failed validation, file manifest.xml, line 10, character 4: The element 'Solution' in namespace 'http://schemas.microsoft.com/sharepoint/' has invalid child element 'TemplateFiles' in namespace 'http://schemas.microsoft.com/sharepoint/'. List of possible elements expected: 'FeatureManifests, ActivationDependencies' in namespace 'http://schemas.microsoft.com/sharepoint/'.

What could be this error?



Solution 1:[1]

The "TemplateFiles" element refers to items that will be copied onto the web server. This is allowed for farm solutions (which are deployed via CentralAdmin), but is not allowed for sandboxed solutions (which are deployed via the Solution Gallery).

Solution 2:[2]

When you deploy your wsp with visual studio, you deploy it as farm solution. When you deploy your wsp from site settings into solution galery, you deploy it as user solution (sandbox solution) with some limitations : first, avoid using out of the box visual webparts, it's prohibited ! Deploy your wsp by writing powershell script. A good starting point here : patrickboom.wordpress.com/2010/05/31/using-powershell-to-deploy-sharepoint-solutions-wsp-2/

Solution 3:[3]

Le_Fredo is correct here, when attempting to deploy a WSP file into the site collection directly under the site settings, you won't be able to. I found this article from microsoft to be extermely helpful http://technet.microsoft.com/en-us/library/ff607688(v=office.14).aspx

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 John Holliday
Solution 2 Le_Fredo
Solution 3 ByronAQ