我需要将之前版本为16.1的特定库切换到15.0版。我这样做是通过删除更高版本并通过nuget安装更低版本。
构建时,会在bin目录中创建正确的dll(15.0)。但是在启动(web)应用程序时收到以下错误:
[FileLoadException: Could not load file or assembly 'Microsoft.SharePoint.Client.Runtime, Version=16.1.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type) +0
System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) +145
System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) +158
System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg) +91
System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent) +438
System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType) +103
System.Reflection.RuntimeAssembly.GetCustomAttributes(Boolean inherit) +37
Owin.Loader.DefaultLoader.SearchForStartupAttribute(String friendlyName, IList`1 errors, Boolean& conflict) +106
Owin.Loader.DefaultLoader.GetDefaultConfiguration(String friendlyName, IList`1 errors) +46
Owin.Loader.DefaultLoader.LoadImplementation(String startupName, IList`1 errorDetails) +75
Owin.Loader.DefaultLoader.Load(String startupName, IList`1 errorDetails) +21
Microsoft.Owin.Host.SystemWeb.OwinBuilder.GetAppStartup() +115
Microsoft.Owin.Host.SystemWeb.OwinHttpModule.InitializeBlueprint() +28
System.Threading.LazyInitializer.EnsureInitializedCore(T& target, Boolean& initialized, Object& syncLock, Func`1 valueFactory) +115
Microsoft.Owin.Host.SystemWeb.OwinHttpModule.Init(HttpApplication context) +106
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +534
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +352
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296
对此错误最令人恼火的是,Owin-package似乎会导致此错误。但根据NuGet文档,Owin根本不应该引用Microsoft.SharePoint.Client。
或者这整条线索是否具有误导性,Owin不必对这个问题做任何事情?
答案 0 :(得分:0)
我遇到了同样的问题。
对我来说,通过从bin目录中删除导致错误的.dll来解决问题。 (在我的情况下,它是 Microsoft.Online.Sharepoint.Tentant.dll )
答案 1 :(得分:0)
我也遇到了这个问题。可以通过在web.config中指定启动类来避免这种情况,以使Owin不会尝试搜索正确的启动类。
appSetting
元素将覆盖OwinStartup
属性,并且 命名约定。您可以有多个启动类(每个使用OwinStartup
属性)并配置将要使用的启动类 使用类似于以下内容的标记将其加载到配置文件中:<appSettings> <add key="owin:appStartup" value="StartupDemo.ProductionStartup" /> </appSettings>
以下键,用于明确指定启动类和 汇编也可以使用:
<add key="owin:appStartup" value="StartupDemo.ProductionStartup, StartupDemo" />
更多详细信息,请参见in the documentation。