开发者

ASP.NET web application project: how to copy a referenced DLL's dependencies to the 'Temporary ASP.NET Files' folder?

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

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.

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'.

From what I've read, ASP.NET will c开发者_开发百科ompile 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.

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.

Thanks!


Try adding the XML file as an embeded resouce, if you got properties on the XML file within visual studio, there will be an option to change it.

Regards

Iain


Not 100% sure on this, but if you go to the properties window of the xml file that's in your solution, you should be able to set the Copy to Output Directory = Copy Always or Copy if Newer. This should instruct it to copy it to where it's needed.


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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜