我将我的VS社区版更新到15.8.1,之后当我尝试在强类型数据集中编辑我的sql时出现此错误.
Run Code Online (Sandbox Code Playgroud)Configure TableAdapter failed Unable to find connection 'my_connection' for object 'Web.config'. The connection string could not be found in application settings, or the data provider associated with the connection string could not be loaded."
我了解如何在 2d 点中使用 delaunay 三角剖分?
但是如何在 3d 点中使用 delaunay 三角剖分呢?
我的意思是我想生成表面三角形网格而不是四面体网格,那么如何使用 delaunay 三角剖分来生成 3d 表面网格?
请给我一些提示。
我正在构建一个应用程序,自动备份数据的功能设置如下:
android:allowBackup="true"
Run Code Online (Sandbox Code Playgroud)
我需要删除这些数据。我无法要求应用程序的用户删除备份本身或禁用数据同步。
有没有办法以编程方式请求?
谢谢
我正在尝试使用SmtpClient.SendMailAsync方法发送大量电子邮件。这是我从简单控制台应用程序调用的测试方法。
static void Main(string[] args)
{
SendMailsOnebyOneAsync().GetAwaiter().GetResult();
}
public static async Task SendMailsOnebyOneAsync()
{
for (int i = 0; i < 1000; i++)
{
try
{
using (SmtpClient sMail = new SmtpClient("XXX"))
{
sMail.DeliveryMethod = SmtpDeliveryMethod.Network;
sMail.UseDefaultCredentials = false;
sMail.Credentials = null;
var fromMailAddress = new MailAddress("XXX");
var toMailAddress = new MailAddress("XXX");
MailMessage message = new MailMessage(fromMailAddress, toMailAddress)
{
Subject = "test"
};
await sMail.SendMailAsync(message);
Console.WriteLine("Sent {0}", i);
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
} …Run Code Online (Sandbox Code Playgroud) 我想为WPF窗口设置动画。它设置为内容的大小,因此当内容更改时,窗口也会更改大小。但是我不希望它捕捉到新的大小,当它确定需要新的大小时,我希望它可以通过动画在新旧值之间徘徊。
我该如何设置?
编辑:我正在使用SizeToContent = WidthAndHeight“作为我的窗口的参数,并希望在它自动调整大小以显示不同内容时进行动画处理。
阅读这篇关于 EF Core 中 SQL 注入预防的有趣文章,我发现现在插值字符串可能会生成FormattableString.
在 .NET Core 2.2 中运行此测试代码:
public static void Main()
{
var filter = "Mark'; DROP TABLE tbl; --";
Console.WriteLine(FromSql("SELECT * FROM tbl WHERE fld = '" + filter + "'"));
Console.WriteLine(FromSql($"SELECT * FROM tbl WHERE fld = {filter}"));
Console.WriteLine(FromSql(FormattableStringFactory.Create(
"SELECT * FROM tbl WHERE fld = {0}", filter)));
}
private static string FromSql(string sql) => sql;
private static string FromSql(FormattableString sql)
{
var formatArgs = sql.GetArguments();
for (var paramIndex = …Run Code Online (Sandbox Code Playgroud) 我按照这个文档Logging in .NET Core and ASP.NET Core,尝试将日志写入 Windows EventLog。
首先,我在 Windows 事件日志中创建源和日志:
if (!EventLog.SourceExists("MyTestSource"))
{
EventLog.CreateEventSource("MyTestSource", "MyTestLog");
return;
}
Run Code Online (Sandbox Code Playgroud)
它被创建了。
然后,我从我的 ASP.NET Core 应用程序(核心 3.0)的 Program.cs 配置了登录 CreateHostBuilder:
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureLogging(logging =>
{
logging.ClearProviders();
logging.AddEventLog(new EventLogSettings
{
SourceName = "MyTestSource",
LogName = "MyTestLog"
});
})
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
Run Code Online (Sandbox Code Playgroud)
我认为仅此而已。然后我在我的控制器中使用记录器:
[Route("[controller]")]
[ApiController]
public class ServerController : ControllerBase
{
ILogger<ServerController> _logger = null;
public ServerController(ILogger<ServerController> logger)
{
_logger = logger;
}
[HttpGet("GetServerInfo")]
public …Run Code Online (Sandbox Code Playgroud) 如何将自定义属性值绑定到路由?
我想要的是:
[ApiController]
[CustomAttribute("value")]
[Route("{customAttributeValue}/[controller")]
public class ExampleController : Controller
{
//...
}
Run Code Online (Sandbox Code Playgroud)
我第一次看到这一点是在对 api 进行版本控制时
[ApiController]
[ApiVersion("2")]
[Route("v{version:apiVersion}/[controller]")]
public class ExampleController : Controller
{
//...
}
Run Code Online (Sandbox Code Playgroud)
在我的项目中,我有以下文件:
appsettings.json和appsettings.Development.json
所以我们的想法是在开发环境中加载文件appsettings.Development.json ,在生产环境中加载appsettings.json。
在launchSettings.json中,我将ASPNETCORE_ENVIRONMENT更改为 Development:
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
Run Code Online (Sandbox Code Playgroud)
这按预期工作:
env.IsDevelopment() is true
Run Code Online (Sandbox Code Playgroud)
appsettings 的加载方式如下:
var config = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", true, true)
.Build();
Run Code Online (Sandbox Code Playgroud)
但所有值仍然是从 appsettings.json 而不是 appsettings.Development.json 加载的。
我也尝试过:
var config = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", true, true)
.AddJsonFile("appsettings.Development.json", true, true)
.Build();
Run Code Online (Sandbox Code Playgroud)
但在本例中,值始终从最后一个文件加载 appsettings.Development.json,即使:
env.IsDevelopment() is false
Run Code Online (Sandbox Code Playgroud) 我目前正在研究Azure 服务总线,但我不明白队列与具有单个订阅的主题相比的真正好处。我发现在这两种情况下都可以创建不同的应用程序来侦听单个队列(或订阅)以更快地处理消息。
那么,如果使用主题可以以同样的方式工作,那么使用天蓝色服务总线队列的真正便利是什么?更好的性能?这个更便宜?
azureservicebus azure-servicebus-queues azure-servicebus-topics
c# ×7
.net-core ×3
asp.net-core ×3
.net-6.0 ×1
android ×1
animation ×1
appsettings ×1
async-await ×1
dataset ×1
delaunay ×1
ilogger ×1
mesh ×1
polygon ×1
resize ×1
smtpclient ×1
wpf ×1
xsd ×1