[rabbitmq-discuss] Security Exception in IIS using RabbitMQ Client

Tim Watson watson.timothy at gmail.com
Fri Jul 20 19:31:33 BST 2012


http://stackoverflow.com/questions/4925331/system-security-permissions-fileiopermission-when-accessing-folder-outside-web-s



On 20 Jul 2012, at 19:28, Tim Watson <watson.timothy at gmail.com> wrote:

> 
> On 20 Jul 2012, at 19:06, Dave Seltzer <dseltzer at tveyes.com> wrote:
> 
>> I'm having a bit of trouble using the .NET RabbitMQ client in IIS, maybe
>> someone knows what I'm running into.
>> 
>> Here's the code I'm trying to run:
>> 
>>   ConnectionFactory rabbitConFactory = new ConnectionFactory();
>>   rabbitConFactory.Address = "hostname";
>>   rabbitConFactory.VirtualHost = "/path";
>>   rabbitConFactory.UserName = "user";
>>   rabbitConFactory.Password = "password";
>> 
>>   IConnection connection = rabbitConFactory.CreateConnection();
>> 
>>   IModel channel = connection.CreateModel();
>> 
>>   Dictionary<String, Object> args = new Dictionary<string, object>();
>>   args.Add("x-ha-policy", "all");
>>   String ExchangeName = "SearchInstructions";
>>   channel.ExchangeDeclare(ExchangeName, "topic", true, false, args);
>> 
>>   Guid myId = new Guid();
>>   String RoutingKey = myId.ToString() + ".Instruction";
>>   IBasicProperties MessageProperties = channel.CreateBasicProperties();
>>   MessageProperties.SetPersistent(true);
>>   MessageProperties.ContentEncoding = "UTF-8";
>>   MessageProperties.ContentType = "text/xml";
>>   MessageProperties.Headers.Add("x-origin",
>> Request.ServerVariables["ServerName"]);
>> 
>>   String messageContent = "<foo />";
>>   byte[] data = System.Text.Encoding.UTF8.GetBytes(messageContent);
>>   channel.BasicPublish(ExchangeName,RoutingKey, MessageProperties,
>> data);
>> 
>>   channel.Close();
>>   connection.Close();
>> 
>> When I run the code in an ASPX page I receive the following Security
>> Exception:
>>   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.FileIOPermission,
>> mscorlib, Version=2.0.0.0, Culture=neutral,
>> PublicKeyToken=b77a5c561934e089' failed.
>> 
>> I'm not really sure how to proceed. This sounds like an IIS issue, but
>> someone here must have tackled this problem before.
>> 
> 
> This is indeed an IIS configuration issue. You need to grant the assembly the appropriate code access permissions. It's been a long time since I looked at IIS, so I can't tell you exactly where to set this up until I'm in front of a browser, but checking msdn for Code Access, FileIOPermission, assemblies and IIS is where I'd start if you want to get a head start. Post the list if you figure it out first please! :)
> 
>> Thanks much!
>> 
>> -Dave
>> _______________________________________________
>> rabbitmq-discuss mailing list
>> rabbitmq-discuss at lists.rabbitmq.com
>> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss


More information about the rabbitmq-discuss mailing list