简体   繁体   English

System.ComponentModel.Win32Exception:访问被拒绝...错误

[英]System.ComponentModel.Win32Exception: Access is denied… Error

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)
{

}

It runs locally very fine but web on web server it gives me an error like它在本地运行得非常好,但是 Web 服务器上的 Web 它给了我一个错误,例如

System.ComponentModel.Win32Exception: Access is denied? System.ComponentModel.Win32Exception:访问被拒绝?

Please suggest, what should I do?请建议,我该怎么办?

I had this problem when my .NET Target Framework was set to 4.5.2.当我的 .NET Target Framework 设置为 4.5.2 时,我遇到了这个问题。 I fixed it by changing the target framework version to 4.5.我通过将目标框架版本更改为 4.5 来修复它。 To do this using Visual Studio 2015, open Solution Explorer, right click on your solution and click Properties.要使用 Visual Studio 2015 执行此操作,请打开解决方案资源管理器,右键单击您的解决方案并单击属性。 The "Target Framework" should be set to ".NET Framework 4.5". “目标框架”应设置为“.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.此外,如果您之前使用 4.5 以外的目标框架构建,则您的 web.config 中可能有一个<compiler>部分,这可能会在您构建时引发错误。 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!还可以查看This Stack Overflow 的答案,它也帮助了很多人解决了这个错误!

可能是您的 SQL 服务器已关闭,请在服务中检查它并启动它

It sounds like you haven't changed the service logon user.听起来您还没有更改服务登录用户。 You can do it from service control manager by right clicking the service and go to the Logon tab.您可以通过右键单击服务并转到登录选项卡从服务控制管理器执行此操作。 Then add user as Service Logon User然后将用户添加为服务登录用户

Or you can do it from the command line:或者您可以从命令行执行此操作:

sc config ServiceName obj= Domain\user password= pass

Note the space between obj= and Domain\\user\u003c/code> it is not a typo.请注意obj=Domain\\user\u003c/code>之间的空格,这不是拼写错误。 It is required.它是必需的。 The same for password= . password=

Goto windows explorer and right click on the folder "~/Quatation/".转到 Windows 资源管理器并右键单击文件夹“~/Quation/”。 Select properties and pick the Security tab to give permissions.选择属性并选择安全选项卡以授予权限。 In the case where your application pool under which the web application runs is using a domain account, you will need to give that specific domain account permission.如果运行 Web 应用程序的应用程序池使用域帐户,则需要授予该特定域帐户权限。

I faced the same issue while running my website from local IIS, after spending some time reading the project properties, found that, certain changes to the project properties were not saved...我在从本地 IIS 运行我的网站时遇到了同样的问题,在花了一些时间阅读项目属性后,发现对项目属性的某些更改没有保存...

Once it was saved, the error went away...保存后,错误消失了......

I got this error while I was working in visual studio 2017, using dotNet framework 4.5, in MVC project...我在 Visual Studio 2017 中使用 dotNet 框架 4.5,在 MVC 项目中工作时遇到此错误...

My problem solve with this我的问题解决了这个

In IIS Manage->Pool Application->Advance Setting->Identity change to Custom Account and set Administrator User在IIS管理->池应用程序->高级设置->身份更改为自定义帐户并设置管理员用户

If you are getting this exception maybe you don't have the administration rights to your system so check with your admin and ask for the rights.如果您收到此异常,可能您没有系统的管理权限,因此请与您的管理员联系并请求权限。 If you do have administrator rights please open your IDE(eg Visual Studio as an Administrator).You might also get this exception if you are trying to access the processes of 32 bit configuration system but your system has 64 bit configuration.如果您确实有管理员权限,请打开您的 IDE(例如 Visual Studio 以管理员身份)。如果您尝试访问 32 位配置系统的进程,但您的系统具有 64 位配置,您也可能会收到此异常。

I am using .Net 4.5.2 and IIS 8.5.9我正在使用 .Net 4.5.2 和 IIS 8.5.9

In IIS Manage->Pool Application->Advance Setting->Identity change ApplicationPoolIdentity to Custom Account and set Administrator User在 IIS Manage->Pool Application->Advance Setting->Identity 中将 ApplicationPoolIdentity 更改为 Custom Account 并设置 Administrator User

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 System.ComponentModel.Win32Exception:访问被拒绝错误 - System.ComponentModel.Win32Exception: Access is denied Error System.ComponentModel.Win32Exception:访问被拒绝 - System.ComponentModel.Win32Exception : Access is denied System.ComponentModel.Win32Exception:访问被拒绝 - System.ComponentModel.Win32Exception: Access is denied System.ComponentModel.Win32Exception:“拒绝访问” - System.ComponentModel.Win32Exception: „Acces is denied” System.ComponentModel.Win32Exception: 使用 FlaUI+SpecFlow 自动化 WPF 应用程序时出现“拒绝访问”错误 - System.ComponentModel.Win32Exception: 'Access is denied' error while Automating a WPF app using FlaUI+SpecFlow 具有管理员访问权限,但抛出 System.ComponentModel.Win32Exception:“访问被拒绝。” - has admin access but throws System.ComponentModel.Win32Exception: 'Access is denied.' System.ComponentModel.Win32Exception(0x80004005):访问被拒绝 - System.ComponentModel.Win32Exception (0x80004005): Access is denied System.ComponentModel.Win32Exception:尝试从 ebay 获取令牌时拒绝访问 - System.ComponentModel.Win32Exception: Access is denied while trying to get token from ebay 为什么hasExited抛出&#39;System.ComponentModel.Win32Exception&#39;? - Why did hasExited throw 'System.ComponentModel.Win32Exception'? System.ComponentModel.Win32Exception:找不到路径 - System.ComponentModel.Win32Exception: Path not found
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM