【问题标题】:Could not load file or assembly 'AxInterop.WMPLib' or one of its dependencies. The parameter is incorrect.无法加载文件或程序集“AxInterop.WMPLib”或其依赖项之一。参数不正确。
【发布时间】:2012-12-05 10:13:35
【问题描述】:

我有一个库 AXInterop.WMPLib,它让我发疯。这是我收到的错误。我没有使用任何其他依赖项。

堆栈跟踪:

[FileLoadException: 无法加载文件或程序集“AxInterop.WMPLib” 或其依赖项之一。参数不正确。 (例外 从 HRESULT: 0x80070057 (E_INVALIDARG))]

[FileLoadException: 无法加载文件或程序集 'AxInterop.WMPLib, Version=1.0.0.0,Culture=neutral,PublicKeyToken=null' 或其之一 依赖关系。参数不正确。 (HRESULT 的例外情况: 0x80070057 (E_INVALIDARG))]
System.Reflection.RuntimeAssembly._nLoad(AssemblyName 文件名,字符串 codeBase,证据 assemblySecurity,RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean for Introspection, Boolean 抑制安全检查)+0
System.Reflection.RuntimeAssembly.nLoad(AssemblyName 文件名,字符串 codeBase,证据 assemblySecurity,RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean for Introspection, Boolean 抑制安全检查)+34
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef,证据 assemblySecurity,RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean for Introspection, Boolean 抑制安全检查)+152
System.Reflection.RuntimeAssembly.InternalLoad(字符串组装字符串, 证据组装Security、StackCrawlMark& stackMark、IntPtr pPrivHostBinder,布尔用于自省)+77
System.Reflection.RuntimeAssembly.InternalLoad(字符串组装字符串, 证据组装Security, StackCrawlMark& stackMark, Boolean forIntrospection) +16 System.Reflection.Assembly.Load(String 组装字符串)+28
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(字符串 assemblyName, Boolean starDirective) +38

[ConfigurationErrorsException: 无法加载文件或程序集 'AxInterop.WMPLib,版本=1.0.0.0,文化=中性, PublicKeyToken=null' 或其依赖项之一。参数是 不正确。 (来自 HRESULT 的异常:0x80070057 (E_INVALIDARG))]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(字符串 程序集名称,布尔型 starDirective) +752
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +218 System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +130
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +170
System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +91 System.Web.Compilation.BuildManager.CallPreStartInitMethods(字符串 preStartInitListPath) +258
System.Web.Compilation.BuildManager.ExecutePreAppStart() +135
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, 异常 appDomainCreationException) +516

[HttpException (0x80004005): 无法加载文件或程序集 'AxInterop.WMPLib,版本=1.0.0.0,文化=中性, PublicKeyToken=null' 或其依赖项之一。参数是 不正确。 (来自 HRESULT 的异常:0x80070057 (E_INVALIDARG))]
System.Web.HttpRuntime.FirstRequestInit(HttpContext 上下文) +9850940 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext 上下文) +101 System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest WR) +456

【问题讨论】:

  • 你如何包含这个?它是一种什么样的参考?您是否确定您有任何其他程序集,您正在使用的程序集需要这些程序集?另外,您能否包括发生此错误的代码?

标签: c# asp.net


【解决方案1】:

我假设您在 Windows 客户端(XP、Vista 或 7)上开发此应用程序,然后将其部署到 Windows Server(2008、2008 R2 等)

Windows Media Player 是 Windows Server 上的一个可选组件(与 Windows 7 等 Windows 客户端不同),因此您必须启用它(作为桌面体验角色服务的一部分),

http://technet.microsoft.com/en-us/library/cc772567.aspx

之后,AxInterop.WMPLib 应该能够找到它的依赖项(Windows Media Player 中的本地库)。

【讨论】:

    【解决方案2】:

    我在 Windows 10 Pro 中遇到了同样的错误。问题是我使用自定义构建事件在另一个路径中编译,而我没有将库添加到项目编译文件夹中。

    所以,请务必将 AxInterop.WMPLib.dllInterop.WMPLib.dll 添加到项目文件夹中。

    【讨论】:

      猜你喜欢
      • 2017-08-12
      • 1970-01-01
      • 1970-01-01
      • 2021-12-12
      • 2012-01-14
      • 1970-01-01
      相关资源
      最近更新 更多