RSS

Tag Archives: C#

Using RabbitMQ in C# (I) Installation of RabbitMQ


image image

 

  • Select the server software on the desired platform and download the setup package. In this example, I will use windows installer.
  • Run the windows installer, and you will be prompted to install Erlang, follow the links and download install Erlang:

image

image image

Read the rest of this entry »

Advertisements
 
2 Comments

Posted by on August 13, 2015 in Dotnet/C#, Programming

 

Tags: , , , , , , , , ,

C# Websocket programming: the simplest example


Create a winform Application:

image

Read the rest of this entry »

 
13 Comments

Posted by on July 23, 2015 in Dotnet/C#, Programming

 

Tags: , , , , , , , ,

Using Redis with C# (II): Coding


Now that you have installed Redis on your system, let’s jump to the actual coding using C#. If you wish to get the detailed procedures to install Redis, click here.

  • Create a winform project in Visual Studio
  • Install the nuget package by running the following command in the Package Manager Console

PM> Install-Package ServiceStack.Redis

Add a button and a button click event handler:

              private void button1_Click(object sender, EventArgs e)
        {
            string elementKey = “TableId”;
            using (var redisClient = new RedisClient(host, port, password))
            {
                if (redisClient.Get<string>(elementKey) == null)
                {
                    redisClient.Set(elementKey, “12345678”);
                }
                else
                    redisClient.Set(elementKey, “87654321”);
                // get value from the cache by key
                var message = “Item value is: “ + redisClient.Get<string>(elementKey);
                MessageBox.Show(message);
            }
        }

Read the rest of this entry »

 
Leave a comment

Posted by on July 14, 2015 in Dotnet/C#, Programming

 

Tags: , , , , , ,

Using MySQL with C# (III): Coding in C#


  • Install the nuget package: in the nuget management console, type below line and run

Install-Package MySql.Data

  • Let’s create a class SqlUtils, and in the static constructor, type below code:
                
                  static
    SqlUtils()
            {
                try
                {
                    con = new MySqlConnection(connectionStr);
                    con.Open(); //open the connection
                    Console.WriteLine(“Successfully opened database.”);
                }
                catch (MySqlException err) //Catch MySql errors
                {
                    Console.WriteLine(“Error: “ + err.ToString());
                }
            }

where the connection string is:

Read the rest of this entry »

 
1 Comment

Posted by on July 13, 2015 in Dotnet/C#, Programming

 

Tags: , , , , , ,

Using MySQL with C# (II): Creating a DB for programming


You might be interested in how to install MySQL in windows, check up this link for details.

  • Run MySQL workbench after clicking Finish

image_thumb[23]  image_thumb[24]

  • In the MySQL workbench, copy below scripts to create a new database called “MyBooks”:

create database MyBooks

  • Select the above script line, then click the thunder icon to execute the sql statement
  • A new DB is created, as shown in the left DB group:

image   image

Read the rest of this entry »

 
1 Comment

Posted by on July 13, 2015 in Dotnet/C#, Programming

 

Tags: , , , , , ,

Using MySQL with C# (I): MySQL Installation


MySQL is a free database and can be easily used in your .Net Applications. This quick-start goes through the typical process that involves installation, up and running your “Hello MySQL” application.

If you are not interested in the MySQL installation, skip this and go directly to the below topics:

Using MySQL with C# (II): Creating a DB for programming
Using MySQL with C# (III): Coding in C#

  • Download MySQL server here or if you already had an oracle account, go directly here.
  • Accept the license, and select the product/platform to download, click “Go”
  • Download the installer

image  image

  • Unzip and run the installer, follow the instructions.
  • Select the options, in my case, I choose “Full”

Read the rest of this entry »

 
1 Comment

Posted by on July 13, 2015 in Dotnet/C#, Programming

 

Tags: , , , , , , ,

Embedding web browsers in Winform applications


Winform ships with a built-in WebBrowser control where you can use it to embed a web browser in a Winform Application. It is relatively trivial to implement it:

  • In Visual Studio Toolbox, Search “Web Browser”, and you will find the WebBrowser control

    image

  • Drag it to the winform designer
  • In Form Load event handler, add below code:

browser.Navigate(Github.com);

  • Now if you run the application, a browser is embedded into your winform application:

    image

 

There are several problems using this approach:

  • This browser control is based on IE browser, which has many limitations that IE has. 
  • It is not easy to implement the zoom-fit or Zoom-content features to make sure the web page is all visible in this embedded browser

Read the rest of this entry »

 
5 Comments

Posted by on July 4, 2015 in Dotnet/C#, Programming

 

Tags: , , , , , , , , , , , , ,