web service asmx under IIS and shared memory

懵懂的女人 提交于 2020-01-15 13:37:27

问题


I have a windows console application that use shared memory for communicate with other process, I need to share data with this process from a web service hosted on same machine.

When I use visual studio development server all works fine, but I have FILE NOT FOUND ERROR (code 2 ) when I try to open a memory-mapped file from web service application under IIS 6.1.

These are functions for create and open memory-mapped file, I think that IIS use a different memory space, is possible ?

[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
    static extern IntPtr CreateFileMapping(IntPtr hFile, IntPtr lpFileMappingAttributes, FileMapProtection flProtect, uint dwMaximumSizeHigh, uint dwMaximumSizeLow, [MarshalAs(UnmanagedType.LPTStr)] string lpName);
    [DllImport("kernel32.dll", SetLastError = true)]
    static extern IntPtr OpenFileMapping(uint dwDesiredAccess, bool bInheritHandle, string lpName);

Using Process Explorer I can see that console application create correctly a memory-mapped file, under :

\Sessions\1\BaseNamedObjects\filemapname

same path I have when web service run in visual studio development server, but when run under IIS can't see any path. If I run "GETLASTERROR" function after "OpenFileMapping" I have error code 2, that mean File not found.

Edit :

Reading about some similar issue I try to rename memory-mapping file to "Global\filemapname" in console application, and now Web Service under IIS can read this file but now I have ERROR_ACCESS_DENIED, so I think that IIS process need more privileges.

I try to modify some IIS option, and I win when change identity of DefaultAppPool(default is ApplicationPoolIdentity) to administrator user of machine .

Using this setting application works fine under IIS, but maybe this is not better and clean solution. Any suggest ?

来源:https://stackoverflow.com/questions/25722243/web-service-asmx-under-iis-and-shared-memory

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