MemoryMappedFile.CreateOrOpen抛出UnauthorizedAccessException(拒绝访问路径) [英] MemoryMappedFile.CreateOrOpen throws UnauthorizedAccessException (Access to the path is denied)

查看:227
本文介绍了MemoryMappedFile.CreateOrOpen抛出UnauthorizedAccessException(拒绝访问路径)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Windows 7机器。

I am using Windows 7 machine.

我有2个进程。一个(Process1)在本地系统帐户的上下文中作为Windows服务运行。其他一个(Process2)作为常规Windows应用程序运行。

I have 2 processes. One (Process1) is run as a Windows service under the context of local system account. Other one (Process2) is run as regular Windows application.

我正在尝试使用MemoryMappedFile.CreateOrOpen函数创建或打开一个内存管理文件("Global \\ MyMMF"" ,这两个过程都是如此。

I am trying to create or open a Memory Managed File using the function MemoryMappedFile.CreateOrOpen("Global\\MyMMF",iSize) in both these processes.

如果我先运行Process2,然后运行Process1,那么MemoryMappedFile.CreateOrOpen函数在两个进程中都能正常工作。

If I first run Process2 followed by Process1, then MemoryMappedFile.CreateOrOpen function works fine in both processes.

但是,如果我首先运行Process1,然后运行Process2,则Process2中的MemoryMappedFile.CreateOrOpen函数将失败并显示错误UnauthorizedAccessException并显示异常消息 - "对路径的访问被拒绝"

But If I first run Process1 followed by Process2, MemoryMappedFile.CreateOrOpen function in Process2 fails with error UnauthorizedAccessException with exception message - "Access to the path is denied"

我尝试使用"使用"调用Process2 ;以管理员身份运行,但没有用。

I tried invoking Process2 using "Run as Admin", but no use.

-Shakir

推荐答案

我有完全相同的问题。

有一个称为'的'doucment'会话0隔离对Web上的服务和驱动程序的影响,并解释共享对象应该是pr使用\Global进行电子修复,你已经完成了这项工作。我已经尝试在本地安全策略中更改Create
Global Object项的权限。

There is a doucment called 'Impact of Session 0 Isolation on Services and Drivers in Windows Vista' on the web and explains that shared objects should be pre-fixed with \Global you have done this as have I. I have tried changing permissions on the Create Global Object item in the local security policy.

我的代码有效在XP SP3上没有问题,但在2008 Server或Windows 7上没有问题,与你发现的问题完全相同。

My code works fine on XP SP3 but not on 2008 Server or Windows 7, with exactly the same issue as you have found.

在我的情况下,服务将始终在任何用户程序之前自动启动。

In my case the services will always start automatically well before any user program.

有一个设置MemoryMappedFileSecurity可以传递给CreateOrOpen,我想知道如果使用正确的设置它将起作用。基本上我想要破坏共享内存对象的所有安全性。

There is a setting MemoryMappedFileSecurity that can be passed to CreateOrOpen and am wondering if with the right settings it will work. Basically I want to disble all security for the shared memory object.

MS的任何人都在看这个?

Anyone in MS looking at this?

-Andy

 

 

 


这篇关于MemoryMappedFile.CreateOrOpen抛出UnauthorizedAccessException(拒绝访问路径)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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