iis Visual Studio 2015即使在bin文件夹中复制后也找不到外部.dll,但仅在复制到c:\Windows\

n6lpvg4x  于 8个月前  发布在  Windows
关注(0)|答案(1)|浏览(51)

我尝试在Visual Studio 2015中构建一个Web项目,它引用了一个c# . dll项目“dotnetWrapper”,这是一个c项目“managedDllWrapper”的c# Package 器,其中包括一些第三方64位原生c. dll。
参考项目和Web项目在.Net Framework 4.6.1和x64上运行。VS2015使用iis express 64位。
一切正常。
当我在VS 2015中启动本地Web服务器时(点击绿色启动按钮),我得到错误消息,“managedDllWrapper.dll”或其依赖项之一无法找到:
“/”应用程序中的服务器错误。
未能加载文件或程序集“website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website
产品描述:执行当前Web请求期间发生未处理的异常。请查看堆栈跟踪以了解有关错误及其在代码中起源的详细信息。
例外详细信息:System.IO.FileNotFoundException:未能加载文件或程序集“website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website. website
错误代码:
在执行当前Web请求期间生成了未处理的异常。有关异常的来源和位置的信息可以使用下面的异常堆栈跟踪来标识。
堆栈跟踪:
[FileNotFoundException:无法加载文件或程序集“managedDllWrapper.DLL”或它的某一个依赖项。找不到指定的模块。] System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName,String codeBase,Evidence assemblySecurity,RuntimeAssemblylocationHint,StackCrawlMark& stackMark,IntPtr pPrivHostBinder,Boolean throwOnFileNotFound,Boolean forIntrospection,Boolean suppressSecurityChecks)+0
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef,Evidence assemblySecurity,RuntimeAssembly reqAssembly,StackCrawlMark& stackMark,IntPtr pPrivHostBinder,Boolean throwOnFileNotFound,Boolean forIntrospection,Boolean suppressSecurityChecks)+234
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString,Evidence assemblySecurity,StackCrawlMark& stackMark,IntPtr pPrivHostBinder,Boolean forIntrospection)+108
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString,Evidence assemblySecurity,StackCrawlMark& stackMark,Boolean forIntrospection)+25
System.Reflection.Assembly.Load(String assemblyString)+34 System.Web.Configuration. AppendicationSection.LoadAssemblyHelper(String assemblyName,Boolean starDirective)+49
[错误提示]未能加载文件或程序集“websites”或它的某一个依赖项。找不到指定的模块。
System.Web.Configuration. DisparationSection.LoadAssemblyHelper(String assemblyName,Boolean starDirective)+772
系统.Web.配置.配置节.LoadAllAssembliesFromAppDomainBinDirectory()+259
系统.Web.配置.配置节.LoadAssembly(AssemblyInfo ai)+163
System. Web. Exclusion.<>c.b__143_0(AssemblyInfo ai)+29
System.Linq.d__16'2.MoveNext()+293
System.Linq.d__66'1.MoveNext()+100
System.Linq.d__63'1.MoveNext()+73
System.Web.UI.Util.GetTypeFromAssemblies(IEEEAssemblies,String typeName,Boolean TypeCase)+217
System.Web.Compilation.BuildManager.GetType(String typeName,Boolean throwOnError,Boolean throwreCase)+266
System.Web.Configuration.HandlerFactoryCache.GetTypeWithAssert(String type)+48
System.Web.Configuration.HandlerFactoryCache.GetHandlerType(String type)+17
System.Web.Excelation.HandlerFactoryCache.. ctor(String type)+25
System.Web.HttpApplication.GetFactory(String type)+104
System.Web.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()+262
System.Web. Http Application.ExecuteStep(IExecutionStep步骤,布尔值和同步完成)+137
版本信息:Microsoft .NET Framework版本:4.0.30319; ASP.NET版本:4.6.1039.0
请注意,本机dll(依赖项)位于web-project bin文件夹中(手动复制)。
当我将本地dll复制到C:\Windows\文件夹时,Web应用程序运行得很顺利。不知何故,Web应用程序的dll搜索路径只指向C:\Windows\文件夹,但它也应该查看webapp execution(bin)文件夹,对吗?
当我不做一个web应用程序,而是一个C#控制台测试应用程序时,它也包括所有dll的 Package 器,将dll复制到测试应用程序的bin文件夹中工作正常,应用程序运行。只有web应用程序有这个问题,不接受bin文件夹中的dll。
此外,当我将dll复制到C:\Windows\目录,并运行Web应用程序,然后再次尝试删除dll时,它说它们无法删除,因为
因为该文件已在IIS Express工作进程中打开。
所以,也许这是IIS的问题,而不是VS2015的问题,但我无法配置我的IIS(或者我不知道如何配置)。我使用Visual Studio 2015附带的IIS express。
我在Google和StackOverflow上的所有研究结果是:

  • 复制dll到bin文件夹(尝试过,但如上所述不起作用,仅适用于C#控制台应用程序,但不适用于Web应用程序)。
  • 直接在项目中引用dll(不可能:)

无法添加[..].dll。请确保该文件可访问,并且是有效的程序集或COM组件。

  • 检查是否所有内容都是64位,以及相同的.Net版本(检查,64位,.Net 4.6.1。此外:它适用于控制台应用程序,但不是Web应用程序)。
  • 更改web.config以添加更多的.dll文件夹。但这也没有帮助。

我会很高兴,如果.dll可以通过我的Web项目在一个不同的文件夹中找到C:\Windows\,因为我怀疑我将被允许添加17 .dll到MS azurewebsites上的C:\Windows\文件夹,当我想发布网站.然后,路径应该在应用程序文件夹内的某种方式.

ryoqjall

ryoqjall1#

我没有一对一地解决问题,但我成功地规避了问题:
通过重写c#/c++ wrapper的dllimport,我直接用path来寻址dll文件,这样依赖的dll就和被引用的dll在同一个文件夹中了,这在web应用中也是有效的。

相关问题