Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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

share|improve this question
    
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
add comment

2 Answers

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

share|improve this answer
    
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
add comment

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.

share|improve this answer
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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