Memory Mapped File and Win Service - Cannot find File Created By Server

为君一笑 提交于 2019-12-06 15:12:09

问题


I am trying to create a memory mapped file with a windows service so it can hold a lot of static data that other windows applications can use.

My issue is that when I start the service - the service can read and write the memory mapped file easily. However, the windows apps cannot. They get a file not found error.

Using the same class to read and write the memory mapped file, in two windows applications I have no issues. So, I am under the belief that the use of the memory mapped files is correct but there is something else - probably in the realm of windows services that I am missing.

I have tried to add an access control but that does not help. Still, file not found.

Admittedly, I am not very experienced with windows services. I have tried to create simple files to write my exceptions into but they are not being created from the service either. As for the account, I am using my own windows account (I have limited, local admin privs).

I am not using the Network Services account because I need to access a database with credentials embedded in my user account.

Any ideas would be awesome because I have started to spin my wheels at this point.


回答1:


You might need to prepend the MMF name with @"Global\". I believe the newer versions of Windows runs services under a different session than other apps.

I saw references to the following article: Impact of Session 0 Isolation on Services and Drivers in Windows

You might also need to modify the Local Security Policy "Create global objects", depending on what user account you are running your windows app from.



来源:https://stackoverflow.com/questions/11301978/memory-mapped-file-and-win-service-cannot-find-file-created-by-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!