小编bmu*_*l30的帖子

无法绑定到 LocalHost(无效异常)错误 Visual Studio 2022

我正在构建一个全新的 ASP.Net Core MVC 项目。当我尝试在调试器中运行它时,出现以下错误:

System.IO.IOException
  HResult=0x80131620
  Message=Failed to bind to address https://localhost:5001.
  Source=Microsoft.AspNetCore.Server.Kestrel.Core
  StackTrace:
   at Microsoft.AspNetCore.Server.Kestrel.Core.LocalhostListenOptions.<BindAsync>d__2.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()

  This exception was originally thrown at this call stack:
    [External Code]

Inner Exception 1:
AggregateException: One or more errors occurred. (An invalid argument was supplied.) (An invalid argument was supplied.)

Inner Exception 2:
SocketException: An invalid argument was supplied.
Run Code Online (Sandbox Code Playgroud)

错误发生在我的 Program.cs 类中:

public class Program
{
    public static void Main(string[] args)
    {
        CreateHostBuilder(args).Build().Run(); …
Run Code Online (Sandbox Code Playgroud)

c# localhost asp.net-core-mvc

6
推荐指数
2
解决办法
7197
查看次数

如何在我的Visual Studio 2012项目中引用XML文件作为项目代码中的数据源?

我的项目包括一个组合框,其中包含供用户选择的数据库列表.选择确定稍后将联系哪个数据库.

由于数据库具有奇数名称,因此我想给每个数据库提供一个可理解的名称,以便在组合框的显示值中显示,实际数据库名称隐藏在Value Member属性中(即"XYZprojDB123"的"数据库1").因此,我将具有显示值/值成员对的XML文件放在一起,并将其添加到我在Visual Studio中的项目中,但现在我无法在我的代码中链接到它.只是写作

XDocument dbList = XDocument.Load("Databases.xml");
Run Code Online (Sandbox Code Playgroud)

不起作用.

这是一个Windows应用程序,因此我希望在发布时包含此XML文件以进行分发.有谁知道如何使这项工作?

c# xml visual-studio-2012

1
推荐指数
1
解决办法
3233
查看次数