Security exception when adding SignalR 0.4.0 to Nearforums

Feb 29, 2012 at 11:30 AM

Hi,

This is doing my head in a bit. I use Nearforums as a base and i based my site on the output web project (copied it).
When i install SignalR 0.4.0 through Nuget, i get no errors. But when i run the website i get a securityexception about security permission
The stacktrace states that it has something to do with the bootstrapper and aspshutdowndetector from SignalR's HostAsp library
The exception also states that i could add a level of trust in the web.config. No affect when i set it to 'full' <trust level="full">

Now when i just create a new mvc project and add signalr, i do not get this error

Could it have something to do with some low level hook/strapper/baseviewpage Nearforums uses that prevents

I know that this may not be directly related to Nearforums, but i would be very happy with any suggestion

Coordinator
Feb 29, 2012 at 12:51 PM

Hi,

I'm not sure if I can help you with this...

Are you using the Visual Studio dev server or IIS?

Try by removing the <trust > element from the web.config

Copy the exception detail and I could have a look to try n' guess :)

 

Kind Regards,

Jorge

Feb 29, 2012 at 9:16 PM

This is the detail

I get it straight after starting the site. And i dissapears when i remove the SignalR.Hosting.Aspnet reference

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: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace:

[SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
   System.Web.Hosting.HostingEnvironment.RegisterObject(IRegisteredObject obj) +24
   SignalR.Hosting.AspNet.AspNetShutDownDetector..ctor(Action onShutdown) +55
   SignalR.Hosting.AspNet.AspNetBootstrapper..cctor() +113

Coordinator
Mar 1, 2012 at 7:55 AM

I don't have a clue... It is definitely not related to Nearforums...

Did you tried to get support from SignalR team?

Mar 1, 2012 at 10:54 AM

Well.. no, not yet. I thought i would first try it here because it does not happen with a clean project

May be due to some settings in the webconfig..

 

I will try at SignalR to see if they have a clue

Thanks for the trouble taken

Mar 6, 2012 at 8:14 AM

I've done some searching and asking at SignalR's and i have solved this issue. Turnsout it was a combination of web.config settings

the most important one wat the trust level. it must be set to full (default). Mine was set to medium (Nearforums default?)

Coordinator
Mar 6, 2012 at 8:29 AM

Hi,

We use medium trust level in development, to ensure that what we are developing works in medium trust or above.

On release, we remove this config entry.

 

Kind Regards,

Jorge

Mar 6, 2012 at 8:30 AM

Ah, so is it safe to set that to full in development or am i breaking parts of NF that way?

Coordinator
Mar 6, 2012 at 8:33 AM

Yes, it is not problem to use full trust with Nearforums.

Mar 6, 2012 at 8:35 AM

Thank you very much.