简体   繁体   English

为什么.NET 4.0程序在安装了.NET 4.5的Windows Server 2012计算机上会产生system.unauthorizedAccess错误?

[英]Why does a .NET 4.0 program produce a system.unauthorizedAccess error on a Windows Server 2012 machine with .NET 4.5 installed?

I'm getting an error that seems to only occur on machines running Windows Server 2012 . 我收到的错误似乎只在运行Windows Server 2012的计算机上发生。 My application was written for a .NET 4.0 environment. 我的应用程序是为.NET 4.0环境编写的。 My hypothesis is something in the .NET 4.5 isn't playing nicely with my application. 我的假设是.NET 4.5中的某些内容无法与我的应用程序很好地配合。 I have no other ideas. 我没有其他想法。

The application is designed to create PDF files. 该应用程序旨在创建PDF文件。 It will do this by calling multiple instances of itself. 它将通过调用自身的多个实例来实现此目的。 The main application will call another EXE file with a set of parameters that indicate which PDF files to create. 主应用程序将调用另一个带有一组参数的EXE文件,这些参数指示要创建的PDF文件。

In this way we can call multiple EXE files, speeding up the process. 这样,我们可以调用多个EXE文件,从而加快了处理速度。 For testing purposes, I can disable the calls to outside programs by changing a setting this will create all the PDF files with the same program, just more slowly. 出于测试目的,我可以通过更改设置来禁用对外部程序的调用,此设置将以相同的程序创建所有PDF文件,但速度会更慢。

The PDF files will be saved onto a local hard drive. PDF文件将保存到本地硬盘驱动器上。 The user should have access to all local drives and all administrator privileges. 用户应该有权访问所有本地驱动器和所有管理员特权。 There are no hidden folders. 没有隐藏的文件夹。

As soon as the main application goes to call a new instance of itself, it will crash. 一旦主应用程序调用其自身的新实例,它将崩溃。 See the picture below. 参见下图。 Either it can't use the EXE file, or it can't write to the local drive. 它要么不能使用EXE文件,要么不能写入本地驱动器。 I'm not sure which; 我不确定哪个 if I need to create a log I will, thus I can determine if the application can't call the EXE file or if the application can't write to the local drive. 如果需要创建日志,则可以确定应用程序是否无法调用EXE文件,或者应用程序是否无法写入本地驱动器。

However, if I run the same application as administrator it runs correctly. 但是,如果我运行与管理员相同的应用程序,它将正确运行。 Running as administrator isn't a viable solution for the long term. 从长远来看,以管理员身份运行不是可行的解决方案。 This makes me think it's not really a .NET issue. 这使我认为这实际上不是.NET问题。

Another thing, if I change the setting to create all the PDF files internally it will run correctly. 另一件事,如果我更改设置以在内部创建所有PDF文件,它将可以正确运行。 This doesn't require the elevated privileges. 这不需要提升的特权。 This proves that the user should have access to the drive. 这证明用户应该有权访问驱动器。

The application that has run stably(ish) for months off an older system Windows Server 2003 with .NET 4.0 installed. 在安装了.NET 4.0的旧系统Windows Server 2003上 ,可以稳定运行几个月的应用程序。

I'm attempting to move the application to a new server, Windows Server 2012, by default .NET 4.5 or above is installed. 我尝试将应用程序移动到新服务器Windows Server 2012,默认情况下安装了.NET 4.5或更高版本。

I have no debugger on the target system. 我在目标系统上没有调试器。 Everything runs fine on my development environment and from the old production environment. 在我的开发环境和旧的生产环境中,一切都运行良好。

错误消息框的图片

The problem ended up being I was referencing a shared local drive. 问题最终导致我引用共享本地驱动器。 For some reason I did not have permission on the share drive to write anything. 由于某种原因,我没有共享驱动器上的写入权限。 I changed the output path from \\\\"c-drive\\ to c:\\... . That fixed the problem. 我将输出路径从\\\\“ c-drive \\更改为c:\\ ...。这解决了问题。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM