经过测试验证,是文件夹目录中包含#的原因。项目从2.0升级2.1,2.0时文件目录和发布目录包含#没问题,升级2.1就不行,感谢!!!
项目是怎么运行的?
直接F5运行,我换了个磁盘创建可以,但发布后部署在iis又出现这个问题
这是发布之后的错误提示
Application startup exception: System.ArgumentNullException: Value cannot be null.
Parameter name: path1
at System.IO.Path.Combine(String path1, String path2)
at Microsoft.AspNetCore.Mvc.ApplicationParts.RelatedAssemblyAttribute.GetRelatedAssemblies(Assembly assembly, Boolean throwOnError, Func2 fileExists, Func
2 loadFile)
at Microsoft.AspNetCore.Mvc.ApplicationParts.RelatedAssemblyAttribute.GetRelatedAssemblies(Assembly assembly, Boolean throwOnError)
at Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationAssembliesProvider.GetRelatedAssemblies(Assembly assembly)
at Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationAssembliesProvider.GetAssemblyItem(Assembly assembly)
at Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationAssembliesProvider.ResolveFromDependencyContext(DependencyContext dependencyContext)
at Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationAssembliesProvider.ResolveAssemblies(Assembly entryAssembly)+MoveNext()
at Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartManager.PopulateDefaultParts(String entryAssemblyName)
at Microsoft.Extensions.DependencyInjection.MvcCoreServiceCollectionExtensions.GetApplicationPartManager(IServiceCollection services)
at Microsoft.Extensions.DependencyInjection.MvcCoreServiceCollectionExtensions.AddMvcCore(IServiceCollection services)
at Microsoft.Extensions.DependencyInjection.MvcServiceCollectionExtensions.AddMvc(IServiceCollection services)
at Tencent.Web.Startup.ConfigureServices(IServiceCollection services) in D:\Demo\Tencent.Web\Startup.cs:line 38
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureApplicationServices()
at Microsoft.AspNetCore.Hosting.Internal.WebHost.Initialize()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
crit: Microsoft.AspNetCore.Hosting.Internal.WebHost[6]
Application startup exception
System.ArgumentNullException: Value cannot be null.
Parameter name: path1
at System.IO.Path.Combine(String path1, String path2)
at Microsoft.AspNetCore.Mvc.ApplicationParts.RelatedAssemblyAttribute.GetRelatedAssemblies(Assembly assembly, Boolean throwOnError, Func2 fileExists, Func
2 loadFile)
at Microsoft.AspNetCore.Mvc.ApplicationParts.RelatedAssemblyAttribute.GetRelatedAssemblies(Assembly assembly, Boolean throwOnError)
at Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationAssembliesProvider.GetRelatedAssemblies(Assembly assembly)
at Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationAssembliesProvider.GetAssemblyItem(Assembly assembly)
at Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationAssembliesProvider.ResolveFromDependencyContext(DependencyContext dependencyContext)
at Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationAssembliesProvider.ResolveAssemblies(Assembly entryAssembly)+MoveNext()
at Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartManager.PopulateDefaultParts(String entryAssemblyName)
at Microsoft.Extensions.DependencyInjection.MvcCoreServiceCollectionExtensions.GetApplicationPartManager(IServiceCollection services)
at Microsoft.Extensions.DependencyInjection.MvcCoreServiceCollectionExtensions.AddMvcCore(IServiceCollection services)
at Microsoft.Extensions.DependencyInjection.MvcServiceCollectionExtensions.AddMvc(IServiceCollection services)
at Tencent.Web.Startup.ConfigureServices(IServiceCollection services) in D:\Demo\Tencent.Web\Startup.cs:line 38
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureApplicationServices()
at Microsoft.AspNetCore.Hosting.Internal.WebHost.Initialize()
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
Hosting environment: Production
Content root path: D:#Publish\Demo
Now listening on: http://127.0.0.1:2668
Application started. Press Ctrl+C to shut down.
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET http://localhost/
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 13.1851ms 500 text/html; charset=utf-8
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 GET http://localhost/favicon.ico
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 0.3941ms 500 text/html; charset=utf-8
新建项目是不可能有这样的问题的。首先回答@dudu的问题是怎样运行的?
参数path1是什么
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
官方就是这样写,这个里面没有传递参数的地方