我正在将 Asp.net Webapi 项目从 .net 4.6.2 框架升级到 .net 4.7.2,并将现有项目格式更改为 MsBuild 15 格式。
在本地开发机器上,它可以正常工作,没有任何问题。
我的应用程序部署在 Azure webapp 上。尝试访问我的 webapi 时出现错误。
无法使用命令行“dotnet .\WebApplication6.dll”启动进程,ErrorCode = '0x80004005'。
我在现有项目中使用 elmah。我还看到问题 ConfigurationErrorsException。
Could not load file or assembly 'Elmah' or one of its dependencies. The system cannot find the file specified. at System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, XmlNode node, Boolean checkAptcaBit, Boolean ignoreCase) at System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, Boolean checkAptcaBit) at System.Web.Configuration.Common.ModulesEntry.SecureGetType(String typeName, String propertyName, ConfigurationElement configElement) at System.Web.Configuration.Common.ModulesEntry..ctor(String name, String typeName, String propertyName, ConfigurationElement configElement) at System.Web.HttpApplication.BuildIntegratedModuleCollection(List`1 moduleList) at System.Web.HttpApplication.GetModuleCollection(IntPtr appContext) at System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) at System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) at System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) at System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) Could not load file or assembly 'Elmah' or one of its dependencies. The system cannot find the file specified. at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type) at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName) at System.Type.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) at System.Web.Compilation.BuildManager.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) at System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, XmlNode node, Boolean checkAptcaBit, Boolean ignoreCase)
我没有找到任何有用的资源来转换为 .net 4.7.2 和 ms build 15 项目格式。
物业集团
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<ProjectId>test</ProjectId>
<version>1.0.0</version>
<TargetFrameworks>net472</TargetFrameworks>
<TargetFramework>net472</TargetFramework>
<PlatformTarget>x64</PlatformTarget>
<OutputType>Library</OutputType>
<OutputPath>bin\</OutputPath>
<RunCommand>$(MSBuildExtensionsPath64)\..\IIS Express\iisexpress</RunCommand>
<RunArguments>/path:"$(MSBuildProjectDirectory)" /port:52451</RunArguments>
</PropertyGroup>
</Project>
网页配置
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
<aspNetCore processPath="dotnet.exe" arguments=".\WebApplication6.dll" stdoutLogEnabled="false" stdoutLogFile="\\?\%home%\LogFiles\stdout" />
全球.asax
public class WebApiApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
GlobalConfiguration.Configure(WebApiConfig.Register);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
}
我试图了解我的方法是否正确。我可以将项目转换为 Ms Build 15 格式并使用 .net 框架 4.7.2 而不使用 asp.net 核心并部署到 Azure Web 应用程序吗?
一旦我发布到 azure webapp 上面的 web.config 行,默认情况下会添加。除非我引用.net核心,否则不确定为什么要添加这些行。