Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 749409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:25:53+00:00 2026-05-14T14:25:53+00:00

I’ve an ASCX control (WebParts aren’t used in this solution) which interrogates CRM 4’s

  • 0

I’ve an ASCX control (WebParts aren’t used in this solution) which interrogates CRM 4’s data via the API provided by Microsoft.Crm.Sdk and Microsoft.Crm.SdkTypeProxy.

The solution works until it’s deployed to Sharepoint.

Initially I received the following error:

[SecurityException: That assembly does not allow partially trusted callers.]
   MyApp.SharePoint.Web.Applications.MyAppUtilities.RefreshUserFromCrm(String login) +0
   MyApp.SharePoint.Web.Applications.MyApp_LoginForm.btnLogin_Click(Object sender, EventArgs e) +30
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111

Then I tried wrapping the calling code in the ASCX with SPSecurity.RunWithElevatedPrivileges:

SPSecurity.RunWithElevatedPrivileges(delegate()
{
   // FBA user may not exist yet or require refreshing
   MyAppUtilities.RefreshUserFromCrm(txtUser.Text);
});

But this resulted in the following error (I’m thinking RunWithElevatedPrivileges isn’t for this sort of thing anyway, but someone suggested it):

[SecurityException: Request for the permission of type 'Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' failed.]
   MyApp.SharePoint.Web.Applications.MyApp_LoginForm.btnLogin_Click(Object sender, EventArgs e) +0
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111

When I elevate the trust level in the Sharepoint site to full everything works fine, however I need to come up with a solution that uses minimal trust (or a customised minimal trust). I’m also trying to stay clear of adding anything to the GAC. Any ideas?

I assume the issue is occuring when trying to call functionality from Microsoft.Crm.*.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T14:25:54+00:00Added an answer on May 14, 2026 at 2:25 pm

    I would use the GAC.

    I understand where you are coming from. I tried to avoid using the GAC when I first started with SharePoint development. But it’s really the way to go.

    Add the following into the manifest.xml of your solution package:

    <Assemblies>
        <Assembly Location="MyApp.SharePoint.Web.Applications.dll" DeploymentTarget="GlobalAssemblyCache" />
    </Assemblies>
    

    And then deploy your package using:

    stsadm.exe -o deploysolution -name MyApp.wsp -immediate -allowgacdeployment -force
    

    If you still want to stay out of the GAC, you can try adding the following to AssemblyInfo.cs:

    [assembly: AllowPartiallyTrustedCallers]
    

    But if you are then going to call DLLs (like Microsoft.Crm) and if those DLLs don’t allow Partially Trusted Callers, then you are stuck.

    In addition, if you haven’t already, you will probably need to create a custom policy file. It was the manual creation and registration of a custom policy file that granted privileges too broadly that finally convinced me to move to the GAC. Haven’t looked back since.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.