Opening a Memory Mapped File causes FileNotFoundException when deployed in IIS

后端 未结 3 1873
隐瞒了意图╮
隐瞒了意图╮ 2021-01-18 06:21

Following the code example from this website, I created a windows console application that creates a mapped memory file:

        using (var file = MemoryMapp         


        
3条回答
  •  醉酒成梦
    2021-01-18 06:55

    For non physical file, there are two cases,

    1. File is deleted after your process exits.
    2. IIS does not run in same user as your console process, IIS runs in little restricted mode, so unless you create File with added security to allow process to access your service.

    You will have to use http://msdn.microsoft.com/en-us/library/dd267529(v=vs.110).aspx this constructor with following security.

            MemoryMappedFileSecurity mSec = new MemoryMappedFileSecurity ();
            mSec.AddAccessRule(new AccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null),
                MemoryMappedFileRights .FullControl, AccessControlType.Allow));
    

    And then try to access it from IIS with same security.

提交回复
热议问题