System.ComponentModel.Win32Exception:访问被拒绝.....错误 [英] System.ComponentModel.Win32Exception: Access is denied..... Error

查看:99
本文介绍了System.ComponentModel.Win32Exception:访问被拒绝.....错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我们的网站上打开一个文档文件.为此,我编写了以下代码.

I want to open one document file on our website. For that I write following code.

try
{
      Process proc = new Process();
      proc.StartInfo = new ProcessStartInfo(Server.MapPath("~/Quatation/PREMIUMQUOTATION1.doc"));
      proc.Start();
}
catch (WebException we)
{

}

它在本地运行非常好,但是在Web服务器上运行Web却给我类似

It runs locally very fine but web on web server it gives me an error like

System.ComponentModel.Win32Exception:访问被拒绝?

System.ComponentModel.Win32Exception: Access is denied?

请提出建议,我该怎么办?

Please suggest, what should I do?

推荐答案

.NET Target Framework设置为4.5.2时,出现了此问题.我通过将目标框架版本更改为4.5来修复它.若要使用Visual Studio 2015进行此操作,请打开解决方案资源管理器,右键单击您的解决方案,然后单击属性".目标框架"应设置为".NET Framework 4.5".此外,如果以前使用4.5以外的目标框架进行构建,则web.config中可能会有< compiler> 部分,并且在构建时可能会引发错误.只需删除此部分即可解决此问题.删除它不会造成任何问题.

I had this problem when my .NET Target Framework was set to 4.5.2. I fixed it by changing the target framework version to 4.5. To do this using Visual Studio 2015, open Solution Explorer, right click on your solution and click Properties. The "Target Framework" should be set to ".NET Framework 4.5". Additionally, if you previously built with a target framework other than 4.5, you may have a <compiler> section in your web.config, and this may throw an error when you build. Just remove this section to fix the issue. Removing it should not cause any problems.

我写了一篇有关此处的简短文章尝试对我不起作用,但可能对您有用.

I wrote a short article about this here that has a couple other things to try that didn't work for me but might work for you.

还要查看

Also check out This Stack Overflow answer which also helped numerous people with this error!

这篇关于System.ComponentModel.Win32Exception:访问被拒绝.....错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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