Closed YellowFlashLeo closed 3 years ago
Hi @YellowFlashLeo ,
First of all thanks for using the tool and taking time to report the issue.
Could you please provide the code for the ConnectionStrings class?
Thanks
public class ConnectionStrings { public string DatabaseConnection { get; set; } public string StudioConnection { get; set; } }
And in appconfig I have { "ConnectionStrings": { "DatabaseConnection": "dsdsds", "StudioConnection": "dsdsdsds" },
The reason I dont want my appconfig to have "AppSettings": { "ConnectionStrings": {, is because after encryption. I cant get connectionString value in my middleware, dbContextOptions.UseSqlServer(Configuration.GetConnectionString("DatabaseConnection"), b => b.MigrationsAssembly("WebDataExtract"))); this returns null. I also tried bContextOptions.UseSqlServer(Configuration.GetSection("AppSettings:ConnectionStrings:DatabaseConnection").Value, also returns null
Hi again, the usage of this class it's perfectly understandable, ans it's ok, thanks for sharing, it was my first option.
It is a .Net Core > 3.0 application?
If it is true, seems that it's using IWebHost marked as obsolete from .Net Core 3.0 and above, so the dependency it's no longer required in SecureConfig in projets using this framework version.
You can check the documentation regarding the migration from .Net Core 2.2 to 3.0 here
SecureConfig is using only IHost from .Net Core 3.1 and above versions.
Let me know if this information helps in your current context.
Thanks
It is in .Net Core 3.1
So, in that case, having a look in the link provided above, it is recommend to move to IHost instead of keeping IWebHost.
Once migrated, this should help.
From your documentation: By default, the tool is looking for a section called "AppSettings" in the appSettings files, from version 1.2.2 if a custom section name wants to be specified, it is mandatory to do it at EncryptSettings (Program, Main) and SetUpSecureConfig (ConfigureServices), in example:
.EncryptSettings<[TSettings]>(true, "AppSettingsCustomName")
services.SetUpSecureConfig<[TSettings]>(Configuration, testApikey, "AppSettingsCustomName");
What I get CreateWebHostBuilder(args) .Build() .EncryptSettings(true,"ConnectionStrings")
.RunAsService();
IWebHost does not contain a definition for "EncryptSettings" and the best extension method overload 'WebHostExtensions.EncryptSettings(IHost,bool,string) required a receiver of type IHost.
I used 1.2.2 and all above version of nuget, still same issue