Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Settings must be of the form "name=value". No idea what to do

So I'm parsing a connection string for an Azure Storage Account and when I get to the page of the app that uses the connection string, the compiler catches an exception stating, "Settings must be of the form "name=value".

Does this mean that I should correct something in the app.config file where I set the appSettings? If so can you immediately spot something wrong with my format that would cause this exception?

<?xml version="1.0" encoding="utf-8"?>
    <configuration>
        <appSettings>
            <add key="StorageConnectionString" value="DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=mykey" />
        <appSettings>
    </configuration>

Here's the code for creating an instance of CloudStorage object:

CloudStorageAccount storageaccount = CloudStorageAccount.Parse ("StorageConnectionString");

        CloudTableClient tableClient = storageaccount.CreateCloudTableClient ();

        CloudTable austinBowlingAthletes = tableClient.GetTableReference ("austinBowlingAthletesTable");
like image 413
michael__sloan Avatar asked Apr 18 '16 15:04

michael__sloan


1 Answers

Add a reference to System.Configuration.dll and add using System.Configuration; in the file.

Then change your first line to this:

CloudStorageAccount storageaccount = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["StorageConnectionString"]);

You need to get the value, not just pass the key to Parse.

like image 144
juunas Avatar answered Sep 22 '22 04:09

juunas