Random Quote

Datemi sei righe scritte dal più onesto degli uomini, e vi troverò una qualche cosa sufficiente a farlo impiccare.

— Cardinale Richelieu

Stack Exchange

profile for Andrea Girardi on Stack Exchange, a network of free, community-driven Q&A sites


Send message from C# to rabbitMQ

For first download and install the .NET/C# AMQP client library

On Visual Studio, include the RabbitMQ.Client reference import the library into the class:

using RabbitMQ.Client;
using RabbitMQ.Client.Framing.v0_8;

At this point initialise the queue and connection to the RabbitMQ broker in the constructor:

var connectionFactory = new ConnectionFactory();
connectionFactory.HostName = HostName;
Connection = connectionFactory.CreateConnection();
Model = Connection.CreateModel();
Model.QueueDeclare(QueueName, false, false, false, null);

Now the connection factory and model are definied and is possible to send a message to the queue called “QueueName”:

IBasicProperties basicProperties = Model.CreateBasicProperties();
System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
Model.BasicPublish("", QueueName, basicProperties, encoding.GetBytes(message));

Note that BasicPublish use byte[] for the message. The parameters are:

BasicPublish(String exchange, String routingKey, IBasicProperties basicProperties, byte[] body)

ClickOnce fails: Value does not fall within the expected range.

I finally found out the “Value does not fall within the expected range” problem with a ClickOnce install application. This was the error log:

 Below is a summary of the errors, details of these errors are listed later in the log.
 * Activation of http://srvweb.bccpojana.bccvicentino.it/BCCAlert/BCCAlert.application resulted in exception. Following failure messages were detected:
  + Value does not fall within the expected range.

This problem was related to a user profile corruption and recreating it solve the problem but it’s not always possible recreate the user so, to fix that error, just execute this:

rundll32 %windir%\system32\dfshim.dll CleanOnlineAppCache