[英]Copying the projectname.dll file from my visual studio project to my IIS bin folder is this correct
[英]Visual Studio 2015 does not find external .dll even after copying in bin folder, but only after copying to c:\Windows\
我尝试在Visual Studio 2015中构建一个Web项目,该项目引用ac#.dll项目“ dotnetWrapper”,这是c ++项目“ managedDllWrapper”的ac#包装器,其中包括一些第三方的64位本机c ++ .dll。
引用的项目和Web项目在.Net Framework 4.6.1和x64上运行。 VS2015使用iis Express 64位。
一切都编译良好。
当我在VS2015中启动本地Web服务器时(单击绿色的“开始”按钮),我收到一条错误消息,即找不到“ managedDllWrapper.dll”或其依赖项之一:
“ /”应用程序中的服务器错误。
无法加载文件或程序集“ managedDllWrapper.DLL”或其依赖项之一。 指定的模块无法找到。
说明:执行当前Web请求期间发生未处理的异常。 请查看堆栈跟踪,以获取有关错误及其在代码中起源的更多信息。
异常详细信息:System.IO.FileNotFoundException:无法加载文件或程序集“ managedDllWrapper.DLL”或其依赖项之一。 指定的模块无法找到。
源错误:
当前Web请求的执行期间生成了未处理的异常。 可以使用下面的异常堆栈跟踪来标识有关异常的来源和位置的信息。
堆栈跟踪:
[FileNotFoundException:无法加载文件或程序集'managedDllWrapper.DLL'或其依赖项之一。 找不到指定的模块。] System.Reflection.RuntimeAssembly._nLoad(AssemblyName文件名,字符串codeBase,证据AssemblySecurity,RuntimeAssembly locationHint,StackCrawlMark&stackMark,IntPtr pPrivHostBinder,布尔型throwOnFileNotFound,布尔值用于Introspection,布尔值hibitSecurityChecks)
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef,证据AssemblySecurity,RuntimeAssembly reqAssembly,StackCrawlMark&stackMark,IntPtr pPrivHostBinder,布尔型throwOnFileNotFound,布尔型用于自省,布尔型抑制安全检查)+234
System.Reflection.RuntimeAssembly.InternalLoad(字符串assemblyString,证据AssemblySecurity,StackCrawlMark&stackMark,IntPtr pPrivHostBinder,用于自省的布尔值)+108
System.Reflection.RuntimeAssembly.InternalLoad(字符串assemblyString,证据assemblySecurity,StackCrawlMark&stackMark,用于自省的布尔值)+25
System.Reflection.Assembly.Load(字符串assemblyString)+34 System.Web.Configuration.CompilationSection.LoadAssemblyHelper(字符串assemblyName,布尔starDirective)+49
[ConfigurationErrorsException:无法加载文件或程序集'managedDllWrapper.DLL'或其依赖项之一。 指定的模块无法找到。]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(字符串assemblyName,布尔型starDirective)+772
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory()+259
System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai)+163
System.Web.Compilation。<> 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(IEnumerable程序集,字符串typeName,布尔值ignoreCase)+217
System.Web.Compilation.BuildManager.GetType(字符串类型名称,布尔throwOnError,布尔ignoreCase)+266
System.Web.Configuration.HandlerFactoryCache.GetTypeWithAssert(字符串类型)+48
System.Web.Configuration.HandlerFactoryCache.GetHandlerType(字符串类型)+17
System.Web.Configuration.HandlerFactoryCache..ctor(字符串类型)+25
System.Web.HttpApplication.GetFactory(字符串类型)+104
System.Web.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()+262
System.Web.HttpApplication.ExecuteStep(IExecutionStep步骤,布尔值和已完成同步)+137
版本信息:Microsoft .NET Framework版本:4.0.30319; ASP.NET版本:4.6.1055.0
请注意,本机dll(依赖项)位于Web项目的bin文件夹(手动复制)中。
当我将本机dll复制到我的C:\\ Windows \\文件夹中时,Web应用程序可以正常运行。 以某种方式,Web应用程序的dll搜索路径仅指向C:\\ Windows \\文件夹,但是它也应该查看webapp执行(bin)文件夹,对吗?
当我不使用Web应用程序,而是使用C#控制台测试应用程序(该程序还包括所有dll的包装程序)时,将dll复制到test-app bin文件夹中就可以正常工作,并且该应用程序可以运行。 仅Web应用程序有此问题,不接受其bin文件夹中的dll。
另外,当我将dll复制到C:\\ Windows \\目录中,并运行Web应用程序,然后尝试再次删除dll时,它说无法删除它们,因为
因为该文件是在IIS Express工作进程中打开的。
因此,也许这是IIS的问题,而不是VS2015的问题,但是我无法配置IIS(或者我不知道如何)。 我使用Visual Studio 2015随附的IIS Express。
我在Google和stackoverflow上所做的所有研究均得出:
“无法添加[..]。dll。请确保该文件可访问,并且它是有效的程序集或COM组件。”
如果我的Web项目可以在不同于C:\\ Windows \\的文件夹中找到.dll,我会很高兴,因为我怀疑是否可以将17 .dll添加到MS azurewebsites的C:\\ Windows \\文件夹中当我想发布该网站时。 然后,路径应以某种方式位于应用程序文件夹中。
我没有一对一地解决问题,但是我成功地绕过了这个问题:
通过用显式的dllimport重写c#/ c ++包装器,我直接用路径处理了dll文件。 然后,从属dll只需与引用的dll位于同一文件夹中。 这在Web应用程序中也适用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.