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

Dave Seltzer dseltzer at tveyes.com
Fri Jul 20 19:06:55 BST 2012


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.

Thanks much!

-Dave


More information about the rabbitmq-discuss mailing list