views:

117

answers:

1

Hi, i'm building a small Twitter web app for myself. I am using TweetSharp but I keep getting an error:

Server Error in '/test' Application.

Security Exception

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: You cannot use TweetSharp in partial trust without a policy that allows connecting to API endpoints.
The following policy information (or equivalent) must be added to your trust policy:
<IPermission class="System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1">
<ConnectAccess>
<URI uri="http://twitter\.com/.*"/&gt;
<URI uri="http://api.twitter\.com/.*"/&gt;
<URI uri="http://search.twitter\.com/.*"/&gt;
</ConnectAccess>
</IPermission>


Source Error: 


[No relevant source lines]

Source File: App_Web_kiqglk9p.1.cs    Line: 0 

Stack Trace: 


[SecurityException: You cannot use TweetSharp in partial trust without a policy that allows connecting to API endpoints.
The following policy information (or equivalent) must be added to your trust policy:
<IPermission class="System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1">
<ConnectAccess>
<URI uri="http://twitter\.com/.*"/&gt;
<URI uri="http://api.twitter\.com/.*"/&gt;
<URI uri="http://search.twitter\.com/.*"/&gt;
</ConnectAccess>
</IPermission>

I've done some research on the topic and have found that all I have to do is add the URI's that I need to access to the .NET Trust Level that I am using. So i switced to MEDIUM and altered:

C:\Windows\Microsoft.NET\Framework64\v2.0.50727\CONFIG\web_mediumtrust.config

... like so:

ORIGINAL:

   <IPermission class="WebPermission" version="1">
       <ConnectAccess>
             <URI uri="$OriginHost$"/>
       </ConnectAccess>
   </IPermission>

ALTERED:

   <IPermission class="WebPermission" version="1">
        <ConnectAccess>
             <URI uri="$OriginHost$"/>
             <URI uri="http://twitter\.com/.*"/&gt;
             <URI uri="http://api.twitter\.com/.*"/&gt;
             <URI uri="http://search.twitter\.com/.*"/&gt;
         </ConnectAccess>
    </IPermission>

However, I still keep getting the same error. Any ideas?

PS: I wasn't sure if this belong on ServerFault or here, so I am starting here :)

A: 

Sorry for not spotting this sooner.

Is there a reason you can't use full trust? I'm not sure why this is occurring but you could file a bug. TweetSharp attempts to demand the WebPermission ahead of time to avoid running into the problem at runtime later.

Daniel Crenna
Hi, I was using full trust and it was doing the same thing. So I tried doing I this way. Same result. :(
Tomaszewski