Asked by:
Assembly does not Allow Partially Trusted Callers

Question
-
Hi,
I have register the plug-in for Online CRM. Since the plug-in being deployed to the Sandbox,it is running as a partially trusted caller. To overcome this, i added the APTC attribute in AssemblyInfo.cs.still the plugin is throwing the error(Assembly does not Allow Partially Trusted Callers) .Can anyone help me in this. thanks in advance.
Below are the code of AssemblyInfo.cs
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
[assembly: AssemblyTitle("Testupload")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AllowPartiallyTrustedCallers]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("Testupload")]
[assembly: AssemblyCopyright("Copyright
© Microsoft 2012")][assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("7286c218-7d15-4189-8ba1-3d8691b612d2")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
senthilkumar.m
Monday, February 20, 2012 1:42 PM
All replies
-
Hi kumar,
It is due to the CRM online run in sandbox environment.
Try this to fix: http://msdn.microsoft.com/en-us/library/ms182297.aspx
thanks
regards,http://eastoceantechnical.blogspot.com/
Toong Yang
Tuesday, February 21, 2012 8:31 AM -
Thanks for your reply. ya its because of sandbox only. But how to fix it. I already tried using APTCA in my assemblyinfo.cs.
[assembly: AllowPartiallyTrustedCallers] .
But still throwing the same error.
senthilkumar.m
Tuesday, February 21, 2012 9:37 AM -
I don't think you need to add the APTC attribute to your assembly - why do you think you need it ?
When do you get the error - compile time, when registering the assembly in CRM, or when the plugin executes ?
Microsoft CRM MVP - http://mscrmuk.blogspot.com http://www.excitation.co.uk
- Edited by DavidJennawayMVP, Moderator Tuesday, February 21, 2012 12:46 PM
Tuesday, February 21, 2012 12:46 PMModerator -
Hi David
Crm throwing this error at the time of plugin execution. since the plugin is registered as sandbox , outside URL cannot accessed through my plugin code because partial trust. This error is actually occurring at the time of accessing sharepoint URL in my plugin.
senthilkumar.m
Tuesday, February 21, 2012 2:29 PM -
Is the assembly signed with a strong-named key (.SNK) file?
Jamie Miley
Check out my about.me profile!
http://mileyja.blogspot.com
Linked-In Profile
Follow Me on Twitter!Tuesday, February 21, 2012 3:54 PMModerator -
Yes.
senthilkumar.m
Wednesday, February 22, 2012 6:47 AM -
How are you accessing the SharePoint url ? I.e. what is the code, and are you calling any other assemblies ? It looks to me like your assembly allows partially trusted callers, but it could be that you're trying to use another assembly that doesn't.
CRM will allow access from the sandbox to web pages using the WebClient class, and you should be able to call web services if you register a ServiceEndpoint, but I think other methods won't be allowed
Microsoft CRM MVP - http://mscrmuk.blogspot.com http://www.excitation.co.uk
- Edited by DavidJennawayMVP, Moderator Wednesday, February 22, 2012 2:44 PM
Wednesday, February 22, 2012 2:43 PMModerator -
Not only the sharepoint Url causing this Issue,any webservice which is hosted in public server cannot get accessed through plugin...
Below are the plugin Code which accessing webservice:
DocumentToSP.DoctoSP_doc = newDocumentToSP.DoctoSP();
_doc.Url = "http://203.129.223.218/DoctoSP.asmx";
_doc.UploadtoSP(Documentbody, FileName, SharePointUrl, UserName, Password,
SharepointFolderUri);
senthilkumar.m
Wednesday, February 22, 2012 3:13 PM -
It looks like DocumentToSp is a custom class that wraps around the SharePoint web services, and I expect it is using .Net framework classes that do not allow partially trusted callers (for example, the .Net 2.0 system.web.services.dll does not support partially trusted callers, but the .Net 4.0 version does). You may need to rewrite the code to use classes that will work. As stated previously, you should be able to use the WebClient class, or you could use WCF for the communication
Microsoft CRM MVP - http://mscrmuk.blogspot.com http://www.excitation.co.uk
- Edited by DavidJennawayMVP, Moderator Wednesday, February 22, 2012 5:23 PM
Wednesday, February 22, 2012 5:23 PMModerator -
Did you get this figured out?
Jamie Miley
Check out my about.me profile!
http://mileyja.blogspot.com
Linked-In Profile
Follow Me on Twitter!Wednesday, September 19, 2012 5:10 PMModerator