2

I created an assembly for SharePoint 2010, which is deployed into the GAC. It contains SPWebCollection.Add method. When the "STS#1" is used as template, there is no exception, the site is created successfully.

newSite = subSites.Add(siteUrl, siteTitle, siteDescription, 1033, "STS#1", true, false);

However when I use a custom site template, there is an error: "That assembly does not allow partially trusted callers."

newSite = subSites.Add(siteUrl, siteTitle, siteDescription, 1033, WorkspaceTemplate, true, false);

As this is a shared/hosted environment, it's not allowed to change the trustlevel.

Any help is much appreciated.

Regards, Andre

  • Can you add a Workspace from the UI? – Per Jakobsen May 31 '12 at 18:16
  • Yes, I can create from UI. Also from PowerShell. – Dre May 31 '12 at 20:55
1

Is your code dll signed? and can you also check if your AssemblyInfo.cs has

[assembly: AllowPartiallyTrustedCallers()] 

If above doesn't help then try to change the trust level from “Minimal trust” to “Medium trust” or other higher level. More info: http://www.ben-morris.com/allow-partially-trusted-callers-asp-net-shared-hosting-environments

  • As this is a hosted environment, it is not allowed to change this trust level in the web.config. APTC has also been added. – Dre May 31 '12 at 20:56
-2

You can set your web application to run in a medium trust environment, by adding the following line to your web.config file:

<trust level=”Medium”/>

Try this and it should work.

  • As this is a hosted environment, it is not allowed to change this trust level in the web.config. – Dre May 31 '12 at 20:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.