GridGain Developers Hub

GridGain Quick Start Guide for .NET/C#

This chapter explains how to use .NET Core to build and run a simple Hello World example that starts a node, puts a value into the cache, and then gets the value.

Prerequisites

GridGain.NET was officially tested on:

JDK

Oracle JDK 8 or 11, Open JDK 8 or 11, IBM JDK 8 or 11

.NET

.NET Core 2.0+, .NET Framework 4.0+

Running a Simple .NET Example

  1. Use the CLI (unix shell, Windows CMD or PowerShell, etc.) to run the following two commands:

    > dotnet new console

    This creates an empty project, which includes a project file with metadata and a .cs file with code.

    And:

    > dotnet add package GridGain.Ignite
    > dotnet add package GridGain

    This modifies the project file - .csproj - to add dependencies.

  2. Open Program.cs in any text editor and replace the contents as follows:

    using System;
    using Apache.Ignite.Core;
    
    namespace GridGain.GettingStarted
    {
        class Program
        {
            static void Main(string[] args)
            {
              var ignite = Ignition.Start();
              var cache = ignite.GetOrCreateCache<int, string>("my-cache");
              cache.Put(1, "Hello, World");
              Console.WriteLine(cache.Get(1));
            }
        }
    }
    using System;
    using Apache.Ignite.Core;
    using GridGain.Core;
    
    namespace GridGain.GettingStarted
    {
        class Program
        {
            static void Main()
            {
                var cfg = new IgniteConfiguration
                {
                    PluginConfigurations = new[]
                    {
                        // Enable GridGain plugin.
                        new GridGainPluginConfiguration()
                    }
                };
    
                IIgnite ignite = Ignition.Start(cfg);
    
                var cache = ignite.GetOrCreateCache<int, string>("my-cache");
                cache.Put(1, "Hello, World");
                Console.WriteLine(cache.Get(1));
    
                IGridGain gridGain = ignite.GetGridGain();
                Console.WriteLine(gridGain.GetProduct().GetLicense());
            }
        }
    }
  3. Save and then run the program:

    > dotnet run

As a result, you should see a node launch and the "Hello, World" text displayed right after the launch.

Next Steps

From here, you may want to: