Jua*_*rdo 3 c# entity-framework-core asp.net-core-mvc asp.net-core-identity razor-pages
我试过添加
<PackageReference Include="Microsoft.AspNetCore.Razor.Runtime" Version="2.2.0" />
Run Code Online (Sandbox Code Playgroud)
但是 2.2.0 是目前可用的最新版本,与错误不符。重建应用程序后错误仍然相同。
项目.csproj:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="3.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.0" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="3.1.0" />
</ItemGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)
完整错误:
未处理的异常。System.IO.FileNotFoundException:无法加载文件或程序集“Microsoft.AspNetCore.Razor.Runtime,版本=3.1.1.0,Culture=neutral,PublicKeyToken=adb9793829ddae60”。该系统找不到指定的文件。
文件名:'Microsoft.AspNetCore.Razor.Runtime,版本=3.1.1.0,Culture=neutral,PublicKeyToken=adb9793829ddae60' at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule 模块,Int32 typeToken,RuntimeTypeHandle[] typeInstantiationContext),方法IntimeContext[] System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) 在 System.Reflection.CustomAttribute.FilterCustomAttributeRecord(MetadataToken caCtorToken, MetadataImport& scope, RuntimeModule modifiedModule, MetadataToken modifiedToken, RuntimeType, Boolean attributeBeFilterInheritType
1& derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg) at System.Reflection.CustomAttribute.AddCustomAttributes(ListBuilder1& 属性、RuntimeModule 装饰模块、Int32 装饰元数据令牌、RuntimeType 属性过滤器类型、布尔型 mustBeInheritable、ListBuilder1 derivedAttributes) at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType) at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType) at System.Reflection.RuntimeAssembly.GetCustomAttributes(Type attributeType, Boolean inherit) at System.Attribute.GetCustomAttributes(Assembly element, Type attributeType, Boolean inherit) at System.Attribute.GetCustomAttribute(Assembly element, Type attributeType, Boolean inherit) at System.Reflection.CustomAttributeExtensions.GetCustomAttribute[T](Assembly element) at Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartFactory.GetApplicationPartFactory(Assembly assembly) 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.AddControllersCore(IServiceCollection services) at Microsoft.Extensions.DependencyInjection.MvcServiceCollectionExtensions.AddControllersWithViewsCore(IServiceCollection services) at Microsoft.Extensions.DependencyInjection.MvcServiceCollectionExtensions.AddControllersWithViews(IServiceCollection services) at Microsoft.Extensions.DependencyInjection.MvcServiceCollectionExtensions.AddMvc(IServiceCollection services) at Microsoft.AspNetCore.Identity.IdentityBuilderUIExtensions.AddRelatedParts(IdentityBuilder builder) at Microsoft.AspNetCore.Identity.IdentityBuilderUIExtensions.AddDefaultUI(IdentityBuilder builder) at Microsoft.Extensions.DependencyInjection.IdentityServiceCollectionUIExtensions.AddDefaultIdentity[TUser](IServiceCollection services, Action1 configureOptions) 在 Microsoft.Extensions.DependencyInjection.IdentityServiceCollectionUIExtensions.AddDefaultIdentity[TUser](IServiceCollection services) 在 pieshop/ServicesStartup(IServiceCollection services)。 juan/code/web-projects/piesshop/src/Startup.cs:line 36 at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions) at System.Reflection.RuntimeMethodInfo.Invoke (对象 obj、BindingFlags invokeAttr、Binder 绑定器、Object[] 参数、CultureInfo 文化)
在 Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.InvokeCore(Object instance, IServiceCollection services) 在 Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass9_0.g__Startup|0(IServiceCollection serviceCollection) 在 Microsoft.AspNetCore.Hosting.ConfigureServicesObjectBuilder instance.Invoke( , IServiceCollection 服务) 在 Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass8_0.b__0(IServiceCollection services) 在 Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.UseStartup(Type startupType, HostBuilderContext context, IServiceCollection services) 在 Microsoft.AspNetCore.Hosting.GenericWeb .<>c__DisplayClass12_0.b__0(HostBuilderContext 上下文,IServiceCollection 服务)在 Microsoft.Extensions.Hosting.HostBuilder。CreateServiceProvider() at Microsoft.Extensions.Hosting.HostBuilder.Build() at pieshop.Program.Main(String[] args) in /home/juan/code/web-projects/piesshop/src/Program.cs:line 10
Startup.cs 的第 36 行:
services.AddDefaultIdentity<IdentityUser>()
.AddEntityFrameworkStores<AppDbContext>();
Run Code Online (Sandbox Code Playgroud)
解决了!我按照以下顺序分别卸载了 dotnet 包:dotnet-sdk-bin (AUR) dotnet-runtime-bin (AUR) dotnet-host-bin (AUR)
然后我以相反的顺序构建了这些相同的包。现在它们都在 3.1.1.sdk101-2 到今天,我的项目再次运行。
我注意到了同样的事情,请查看框架的 ms 更新,几天前有一个更新,预计已安装较新的 nuget 软件包。
您遇到的问题是 nuget 软件包与您的 SDk 不匹配,至少我是这样。在进行 Windows 更新并安装新的 Core Runtime 后,Version=3.1.1.0 一切正常
小智 5
我通过重新安装解决了这个问题:.Net Core SDK 3.1.101 和 ASP.NET Core Runtime 3.1.1
https://dotnet.microsoft.com/download/dotnet-core/3.1
| 归档时间: |
|
| 查看次数: |
2408 次 |
| 最近记录: |