gpt4 book ai didi

c# - 发布 .NET Web 应用程序时出现 "Index was outside the bounds of the array"错误

转载 作者:行者123 更新时间:2023-12-03 20:50:22 25 4
gpt4 key购买 nike

我有一个简单的 .NET Web 应用程序,当我在本地机器上运行它时它运行良好。但是,当我尝试将应用程序发布到本地文件夹时,我看到了“索引超出数组范围”的错误消息。恐怕这个错误非常模糊,我无法弄清楚问题是什么。

我正在 Visual Studio 社区 2019 上创建这个项目。
有人可以帮我弄清楚问题是什么:)

最佳答案

我不知道这个问题或解决方案,但这是我使用的解决方法。
本质上,您需要手动创建发布文件夹和文件配置文件。
我为 .NET Core 3.1 Blazor 项目做了这个
第 1 步 - 在您的项目中,转到 Properties 文件夹,您可以在其中找到 launchSettings.json
第 2 步 - 在里面,创建一个文件夹并将其命名为“PublishProfiles”
第 3 步 - 在 PublishProfiles 文件夹内,创建一个文件并将其命名为“FolderProfile.pubxml”
第 4 步 - 在此文件中,粘贴此代码并将位置路径添加到您要发布的文件夹中:

<?xml version="1.0" encoding="utf-8"?>
<!-- https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<DeleteExistingFiles>True</DeleteExistingFiles>
<ExcludeApp_Data>False</ExcludeApp_Data>
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<PublishProvider>FileSystem</PublishProvider>
<PublishUrl>Your location path where you want to publish your application</PublishUrl>
<WebPublishMethod>FileSystem</WebPublishMethod>
<SiteUrlToLaunchAfterPublish />
<TargetFramework>netcoreapp3.1</TargetFramework>
<ProjectGuid>08d93ba4-c83c-47e9-a83e-73f12d97626a</ProjectGuid>
<SelfContained>false</SelfContained>
</PropertyGroup>
</Project>
第 5 步 - 创建另一个文件并将其命名为“FolderProfile.pubxml.user”并将此代码粘贴到其中。再次插入所需文件夹的路径:
<?xml version="1.0" encoding="utf-8"?>
<!-- https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<_PublishTargetUrl>Your location path where you want to publish your application</_PublishTargetUrl>
<History>True|2021-07-02T16:47:41.7255934Z;True|2021-07-02T12:44:24.1064885-04:00;True|2021-05-21T09:22:02.2383330-04:00;True|2021-05-20T17:42:40.0758569-04:00;True|2021-05-20T09:45:45.4390896-04:00;True|2021-05-20T09:02:32.8340404-04:00;</History>
</PropertyGroup>
</Project>
第 6 步 - 之后,您应该能够在 Visual Studio 中右键单击您的项目,单击选项发布...,带有发布按钮的屏幕应该可见。

关于c# - 发布 .NET Web 应用程序时出现 "Index was outside the bounds of the array"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63182078/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com