无法加载文件或程序集“AxInterop.WMPLib”或其依赖项之一。参数不正确。

时间:2012-12-18 08:29:43

标签: c# asp.net

我有一个库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 fileName,String   codeBase,Evidence assemblySecurity,RuntimeAssembly locationHint,   StackCrawlMark&安培; stackMark,IntPtr pPrivHostBinder,Boolean   throwOnFileNotFound,Boolean forIntrospection,Boolean   suppressSecurityChecks)+0
  System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName,String   codeBase,Evidence assemblySecurity,RuntimeAssembly locationHint,   StackCrawlMark&安培; stackMark,IntPtr pPrivHostBinder,Boolean   throwOnFileNotFound,Boolean forIntrospection,Boolean   suppressSecurityChecks)+34
  System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(的AssemblyName   assemblyRef,Evidence assemblySecurity,RuntimeAssembly reqAssembly,   StackCrawlMark&安培; stackMark,IntPtr pPrivHostBinder,Boolean   throwOnFileNotFound,Boolean forIntrospection,Boolean   suppressSecurityChecks)+152
  System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString,   证据集合安全,StackCrawlMark& stackMark,IntPtr   pPrivHostBinder,Boolean forIntrospection)+77
  System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString,   证据集合安全,StackCrawlMark& stackMark,布尔   forIntrospection)+16 System.Reflection.Assembly.Load(String   assemblyString)+28
  System.Web.Configuration.CompilationSection.LoadAssemblyHelper(字符串   assemblyName,布尔starDirective)+38

     

[ConfigurationErrorsException:无法加载文件或程序集   'AxInterop.WMPLib,版本= 1.0.0.0,文化=中立,   PublicKeyToken = null'或其依赖项之一。参数是   不正确。 (HRESULT异常:0x80070057(E_INVALIDARG))]
  System.Web.Configuration.CompilationSection.LoadAssemblyHelper(字符串   assemblyName,布尔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(String   preStartInitListPath)+258
  System.Web.Compilation.BuildManager.ExecutePreAppStart()+135
  System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager   appManager,IApplicationHost appHost,IConfigMapPathFactory   configMapPathFactory,HostingEnvironmentParameters hostingParameters,   PolicyLevel policyLevel,Exception appDomainCreationException)+516

     

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

2 个答案:

答案 0 :(得分:3)

我假设您在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中的本机库)。

答案 1 :(得分:0)

我在Windows 10 Pro中有相同的错误。问题是我正在使用自定义生成事件在另一个路径中进行编译,而我却缺少将库添加到项目编译文件夹中的功能。

因此,请确保将 AxInterop.WMPLib.dll Interop.WMPLib.dll 添加到项目文件夹中。