another newbie question

Mar 23, 2011 at 8:51 AM

Here's a frustrating little problem that perhaps you can help me with.

 

I'm having a problem getting this wrapper to work in a "medium-trust" server environment. In full-trust it works great.

The C# statement pingreturn = mailchimp.Ping();  elicits the following exception:

 

System.Security.SecurityException:

That assembly does not allow partially trusted callers.

 

I guess the question is can I run this in medium-trust?

 

thanks, Tom

Coordinator
Mar 23, 2011 at 9:06 AM
Edited Mar 23, 2011 at 9:12 AM

Hi Tom,

U'll need to recompile the library:

1) Go to Properties/AssemblyInfo.fs

2) Add the next lines (marked bold):

 


...
open System.Reflection;
open System.Security;
open System.Runtime.CompilerServices;
open System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[<assembly: AssemblyTitle("MailChimp")>]
[<assembly: AssemblyDescription("")>]
[<assembly: AssemblyConfiguration("")>]
[<assembly: AssemblyCompany("")>]
[<assembly: AssemblyProduct("MailChimp")>]
[<assembly: AssemblyCopyright("Copyright © DK 2010")>]
[<assembly: AssemblyTrademark("")>]
[<assembly: AssemblyCulture("")>]

// Security section
[<assembly: AllowPartiallyTrustedCallers>]
...


3) Build the project

 

Hope, this will solve your problem....

May 16, 2011 at 8:21 PM

I'm having the same issue getting this to work in a shared hosting environment. I have added the suggested lines to the AssemblyInfo file, recompiled and re-deployed, but I am still receiving the same error. Could there be anything further to add?

 

thanks,
-brit 

Coordinator
May 17, 2011 at 7:14 AM
bmzero wrote:

I'm having the same issue getting this to work in a shared hosting environment. I have added the suggested lines to the AssemblyInfo file, recompiled and re-deployed, but I am still receiving the same error. Could there be anything further to add?

 

thanks,
-brit 

Please, post exception message.

May 17, 2011 at 11:38 AM

Unfortunately, I gave up on getting this to work in my hosting environment. I chose to go with a different wrapper.

If memory serves me, the error was being thrown at the buildQueryString method.

Oct 23, 2012 at 7:46 PM

I've got the same problem and a medium trust component is a must for me. Is it possible for you to just compile mcapi with [<assembly: AllowPartiallyTrustedCallers>] and release this as your nuget package going forward?

Coordinator
Oct 23, 2012 at 8:27 PM
Why not?

On Tue, Oct 23, 2012 at 9:47 PM, troelsrichter <notifications@codeplex.com> wrote:

From: troelsrichter

I've got the same problem and a medium trust component is a must for me. Is it possible for you to just compile mcapi with [<assembly: AllowPartiallyTrustedCallers>] and release this as your nuget package going forward?

Read the full discussion online.

To add a post to this discussion, reply to this email (mcapinet@discussions.codeplex.com)

To start a new discussion for this project, email mcapinet@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com




--
Denis K
Mar 10, 2013 at 1:04 PM
Did anyone get this to work? Unfortunately I am stuck using a Godaddy IIS6 shared host. I have downloaded the source, followed the above instructions (open System.Security; was already present and I removed the comment from [<assembly: AllowPartiallyTrustedCallers>]) and also those in the how to compile for .NET 3.5 page. After uploading the new dll, I am still receiving this error.

Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

Exception Details: System.Security.SecurityException: That assembly does not allow partially trusted callers.

The only stack trace I have is this:

[SecurityException: That assembly does not allow partially trusted callers.]
MailChimp.MCApi..ctor(String apiKey, Boolean secure) +0
MailChimpWrapper..cctor() +29

This implies it is crashing right when I call:

Dim api As New MailChimp.MCApi("my_key_here", True)

Any thoughts? I also waited overnight just to be sure the shared application pool flushed and that I really was using my new code. Perhaps I need to do something to the MailChimp project settings outside of simply enabling [<assembly: AllowPartiallyTrustedCallers>]?

Thank you!
Coordinator
Mar 10, 2013 at 1:11 PM
Mar 10, 2013 at 2:28 PM
OK, thanks for the pointer. Unfortunately I am new to this and what I have tried in this area does not work. First off, I see there is a key.snk in the resources folder, I assume that is OK to use?

So here is what I have done:

In AssemblyInfo.fs
// Security section
[<assembly: AllowPartiallyTrustedCallers>]
[<assembly: AssemblyKeyFile(@"D:\MailChimp\Resources\Key.snk")>]
I then built and used the SN command to get the public token from the dll:
sn -T D:\MailChimp\bin\Debug\MailChimp.dll

Microsoft (R) .NET Framework Strong Name Utility  Version 3.5.30729.1
Copyright (c) Microsoft Corporation.  All rights reserved.

Public key token is 1fc125decc69e2d5
Finally, I uploaded the new dll and added an assembly line to application web.config:
<add assembly="MailChimp, Version=1.3.1.2, Culture=neutral, PublicKeyToken=1fc125decc69e2d5"/>
I am fairly certain the above line is correct and being used as I initially had the assembly name wrong and the application would not run. It is loading just fine now.

So, after all that I still have this error:
[SecurityException: That assembly does not allow partially trusted callers.]
   MailChimp.MCApi..ctor(String apiKey, Boolean secure) +0
   MailChimpWrapper..cctor() +29
Am I missing something?