Search code examples
c#aws-sdkaws-ssm

C# program missing reference to SSM of AWS SDK


We are trying to understand a C# example of connecting to AWS through its SDK, and the project .csproj file is like the following:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net7.0</TargetFramework>
    <RootNamespace>aws_connect_poc_7._0</RootNamespace>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="AWSSDK.SimpleSystemsManagement" Version="3.7.402.5" />
  </ItemGroup>

</Project>

And, the Program.cs file is like the following:

using Amazon.SSM;
using System;

class Program
{
    static void Main(string[] args)
    {
        var ssmClient = new AmazonSSMClient();
        Console.WriteLine("SSM Client created successfully.");
    }
}

We are getting the following compiling errors:

  • CS0234: The type or namespace name 'SSM' does not exist in the namespace 'Amazon' (are you missing an assembly reference?)
  • CS0246 The type or namespace name 'AmazonSSMClient' could not be found (are you missing a using directive or an assembly reference?)

We highly appreciate any hints and suggestions.


Solution

  • The namespace and class name you're using don't appear to be correct. Looking at some documentation it looks like you might have meant Amazon.SimpleSystemsManagement and AmazonSimpleSystemsManagementClient, respectively.

    The following should clear up those errors:

    using Amazon.SimpleSystemsManagement;
    using System;
    
    class Program
    {
        static void Main(string[] args)
        {
            var ssmClient = new AmazonSimpleSystemsManagementClient();
            Console.WriteLine("SSM Client created successfully.");
        }
    }