ASP.NET Web应用程序项目:如何将引用的DLL的依赖项复制到"ASP.NET临时文件"文件夹中? [英] ASP.NET web application project: how to copy a referenced DLL's dependencies to the 'Temporary ASP.NET Files' folder?

查看:63
本文介绍了ASP.NET Web应用程序项目:如何将引用的DLL的依赖项复制到"ASP.NET临时文件"文件夹中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个引用类库CL的Web应用程序项目WAP.CL需要一些xml配置文件才能正常工作.

I have a web application project WAP that references class library CL. CL needs some xml configuration files in order to work properly.

在WAP的csproj中,我添加了一个PostBuildEvent以将必要的XML文件复制到TargetDir.构建时,文件夹结构良好;bin文件夹包含CL和xml文件.

In WAP's csproj, I add a PostBuildEvent to copy the necessary XML files to the TargetDir. When I build, the folder structure is good; the bin folder contains CL and the xml files.

当我运行Web服务时,CL抛出错误,因为它找不到xml文件:

When I run the webservice, CL throws an error because it can't find the xml files:

System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\accountreplication\284ca636\19f84c15\assembly\dl3\bf68503c\34888845_bd69cb01\XmlTemplates\Clusters.xml'.

从我所读的内容中,ASP.NET会即时编译我的文件,并将它们放在"Temporary ASP.NET"文件夹中.因此,看来我的问题是/bin/文件夹中的xml文件没有复制到该临时文件夹中.

From what I've read, ASP.NET will compile on the fly my files and put them in that 'Temporary ASP.NET' folder. So it seems like my problem is that the xml files from the /bin/ folder are not copied in that temp folder.

关于如何解决此问题的任何想法?复制temp文件夹中的xml文件,或者直接从/bin/目录实际提供文件(不确定是否可以这样做).理想情况下,我不想在/bin/目录中添加环境变量.

Any idea on what I should do to get around this? Either to copy the xml files in the temp folder, or to actually serve the files from the /bin/ directory directly (not sure if this is possible). Ideally, I don't want to add an environment variable to the /bin/ directory.

谢谢!

推荐答案

我们遇到了类似的问题,最终在 web.config 中添加了 appSettings 键/值.我们的DLL用于查找所需的文件.文件是手动复制到那里的.

We had a similar problem and ended up adding an appSettings key/value to web.config that our DLL use to find the required files. Files were copied there manually.

<configuration>
  ...
  <appSettings>
    <add key="sExeFolder" value="C:\Project\Support_Files"/>
  </appSettings>
  ...
</configuration>

这篇关于ASP.NET Web应用程序项目:如何将引用的DLL的依赖项复制到"ASP.NET临时文件"文件夹中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆