This is code for NserviseBus bus i got error when running that code. Error "mscorlib.dll Could not extract 'MySqlPassword' from Environment variables"please help me. Thank you....
using System;
using System.Threading.Tasks;
using MySql.Data.MySqlClient;
using NServiceBus;
using NServiceBus.Persistence.Sql;
class Program
{
static async Task Main()
{
Console.Title = "Samples.SqlPersistence.EndpointMySql";
#region MySqlConfig
var endpointConfiguration = new EndpointConfiguration("Samples.SqlPersistence.EndpointMySql");
var transport = endpointConfiguration.UseTransport<MsmqTransport>();
transport.Transactions(TransportTransactionMode.SendsAtomicWithReceive);
var persistence = endpointConfiguration.UsePersistence<SqlPersistence>();
var password = Environment.GetEnvironmentVariable("root");
if (string.IsNullOrWhiteSpace(password))
{
throw new Exception("Could not extract 'MySqlPassword' from Environment variables.");
}
var username = Environment.GetEnvironmentVariable("root");
if (string.IsNullOrWhiteSpace(username))
{
throw new Exception("Could not extract 'MySqlUserName' from Environment variables.");
}
var connection = $"server=localhost;user=
{username};database=sqlpersistencesample;port=3306;password=
{password};AllowUserVariables=True;AutoEnlist=false";
persistence.SqlDialect<SqlDialect.MySql>();
persistence.ConnectionBuilder(
connectionBuilder: () =>
{
return new MySqlConnection(connection);
});
var subscriptions = persistence.SubscriptionSettings();
subscriptions.CacheFor(TimeSpan.FromMinutes(1));
#endregion
endpointConfiguration.UseTransport<LearningTransport>();
endpointConfiguration.EnableInstallers();
var endpointInstance = await Endpoint.Start(endpointConfiguration)
.ConfigureAwait(false);
Console.WriteLine("Press any key to exit");
Console.ReadKey();
await endpointInstance.Stop()
.ConfigureAwait(false);
}
}
how to solve mscorlib.dll Could not extract 'MySqlPassword' from Environment variables..? Please help me..