【发布时间】:2019-01-06 11:41:48
【问题描述】:
我通过 FTP 从 Visual Studio 上传了我的 asp.net 应用程序,部署后它抛出运行时(解析错误)。
我看过几个帖子并尝试了很多替代方法,但没有一个有效:
上传后报错:
Server Error in '/' Application.
Parser Error
Description: An error occurred during the parsing of a resource required to
service this request. Please review the following specific parse error
details
and modify your source file appropriately.
Parser Error Message: Could not load type 'SimpleEchoBot.WebApiApplication'.
Source Error:
Line 1: <%@ Application CodeBehind="Global.asax.cs"
Inherits="SimpleEchoBot.WebApiApplication" Language="C#" %>
Source File: /global.asax Line: 1
正如这篇文章中提到的:Parser Error Message: Could not load type 'webmarketing',我将 CodeBehind 更改为 CodeFile,但出现了一个新错误,指出 asax.cs 不存在!
Server Error in '/' Application.
Parser Error
Description: An error occurred during the parsing of a resource required to
service this request. Please review the following specific parse error
details and modify your source file appropriately.
Parser Error Message: The file '/Global.asax.cs' does not exist.
Source Error:
Line 1: <%@ Application CodeFile="Global.asax.cs"
Inherits="SimpleEchoBot.WebApiApplication" Language="C#" %>
Source File: /global.asax Line: 1
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET
Version:4.7.3282.0
当时我的 plesk 文件管理器是这样的:
然后我上传了 Global.asax.cs 文件,然后出现了这个错误:
如本文所示:Parser Error: Server Error in '/' Application 我更改了 Global.asax.cs 命名空间,使其与 asax 中的继承路径相同!
修改 asax.cs 中的命名空间代码:
asax 中的代码:
<%@ Application CodeBehind="Global.asax.cs" Inherits="SimpleEchoBot.WebApiApplication" Language="C#" %>
但是,上面的“此程序被组策略阻止”错误仍然出现!
我将相同的应用程序部署到 Azure,同样的解析错误,顶部提到的出现了!
“/”应用程序中的服务器错误。 解析器错误 说明:解析服务此请求所需的资源时出错。请查看以下特定的解析错误详细信息并适当地修改您的源文件。
Parser Error Message: Could not load type 'SimpleEchoBot.WebApiApplication'.来源错误:
第 1 行: Inherits="SimpleEchoBot.WebApiApplication" Language="C#" %>
源文件:/global.asax 行:1
版本信息:Microsoft .NET Framework 版本:4.0.30319; ASP.NET 版本:4.7.3163.0
编辑:根据 jessehouwing 的要求,这里是 Bin 文件夹截图:
正如@jeesehouwing 评论所述,我尝试预编译网站并上传,但在预编译时收到一些错误:
System.AggregateException: One or more errors occurred. --->
System.Exception: Publish failed due to build errors. Check the error list
for more details.
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean
includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout,
CancellationToken cancellationToken)
at Microsoft.VisualStudio.Web.Publish.PublishService.VsWebProjectPublish.
<>c__DisplayClass40_0.<PublishAsync>b__2()
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) atSystem.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)atMicrosoft.VisualStudio.ApplicationCapabilities.Publish.ViewModel.ProfileSelectorViewModel.<RunPublishTaskAsync>d__88.MoveNext()
---> (Inner Exception #0) System.Exception: Publish failed due to build errors.
Check the error list for more details.<---
【问题讨论】:
-
错误和代码都是文字,不需要截图。
-
“所以我不得不使用链接” - 不正确。您已选择使用图片链接。那个选择是不正确的。请在问题中包含相关信息。文本信息应作为文本包含在内。
-
很抱歉给您带来不便!需要的图像用代码更新
-
可以分享一下bin文件夹内容的截图吗?您的应用程序似乎缺少关键依赖项。
-
@jessehouwing 截图更新!
标签: c# asp.net visual-studio plesk