相关疑难解决方法(0)

如何获取代码所在的程序集路径?

有没有办法获取当前代码所在的程序集的路径?我不想要调用程序集的路径,只需要包含代码的路径.

基本上我的单元测试需要读取一些相对于dll的xml测试文件.无论测试dll是从TestDriven.NET,MbUnit GUI还是其他东西运行,我都希望路径始终正确解析.

编辑:人们似乎误解了我的要求.

我的测试库位于说

C:\项目\ MyApplication的\ daotests\BIN \调试\ daotests.dll

我想得到这条道路:

C:\项目\ MyApplication的\ daotests\BIN \调试\

当我从MbUnit Gui运行时,到目前为止这三个建议都让我失望:

  • Environment.CurrentDirectory 给出c:\ Program Files\MbUnit

  • System.Reflection.Assembly.GetAssembly(typeof(DaoTests)).Location 给出C:\ Documents and Settings\george\Local Settings\Temp\....\DaoTests.dll

  • System.Reflection.Assembly.GetExecutingAssembly().Location 与前一个相同.

.net c# reflection

746
推荐指数
20
解决办法
58万
查看次数

ASP.NET拒绝访问临时目录

我今天在许多不同的服务器上遇到这个问题.

System.UnauthorizedAccessException:拒绝访问临时目录.

最近没有触及服务器.我脑子里唯一想到的是Windows更新破坏了什么......有什么想法吗?

尝试从asp.net页面访问Web服务时会发生这种情况

System.UnauthorizedAccessException: Access to the temp directory is denied.  Identity 'NT AUTHORITY\NETWORK SERVICE' under which XmlSerializer is running does not have sufficient permission to access the temp directory.  CodeDom will use the user account the process is using to do the compilation, so if the user doesnt have access to system temp directory, you will not be able to compile.  Use Path.GetTempPath() API to find out the temp directory location.
       at System.Xml.Serialization.Compiler.Compile(Assembly parent, String ns, XmlSerializerCompilerParameters xmlParameters, …
Run Code Online (Sandbox Code Playgroud)

c# asp.net exception

13
推荐指数
2
解决办法
5万
查看次数

标签 统计

c# ×2

.net ×1

asp.net ×1

exception ×1

reflection ×1