IIS7 访问MemoryMappedFile, Unable to find the specified file.

C云 2013-07-11 01:42:26
我在本地跑了一个Console程序, 并用MemoryMappedFile在内存里写了一个“HelloHere"的值。

const MemoryMappedFileRights allRequiredRights = (MemoryMappedFileRights)((int)MemoryMappedFileRights.FullControl | 16);

var security = new MemoryMappedFileSecurity();

security.AddAccessRule(new AccessRule<MemoryMappedFileRights>(new SecurityIdentifier(WellKnownSidType.WorldSid, null), allRequiredRights, AccessControlType.Allow));

MemoryMappedFile.CreateNew("HelloHere", 1000, MemoryMappedFileAccess.ReadWriteExecute, MemoryMappedFileOptions.None, security, HandleInheritability.Inheritable);


然后我建了另外一个MVC工程

public ActionResult Index()
{
try
{
var a = MemoryMappedFile.OpenExisting("HelloLoren");
}
catch (Exception ex)
{
}
}


我直接运行这个MVC程序,a = MemoryMappedFile.OpenExisting("HelloHere"); 这句代码是能得到值的。但我把MVC程序发布到IIS,然后通过IIS去访问网站,这句代码就报异常了,说是Unable to find the specified file.
我的IIS版本是7.5,操作系统为win7。

我把同样的代码拿到xp上去运行,IIS版本为5, 却能正常运行。
有人知道是为什么吗? IIS7.5没有权限还是其他缘故。 多谢各位。
...全文
301 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
maxwellno1 2015-06-24
  • 打赏
  • 举报
回复
在mapName前面加上Global即可。即将"HelloHere"改为“Global\\HelloHere”
C云 2013-07-11
  • 打赏
  • 举报
回复
引用 1 楼 Return_false 的回复:
var a = MemoryMappedFile.OpenExisting("HelloHere"); 测试 7.5下并无异常
你用的是.net framework的哪个版本? 我的是.net framework 4.5. 对了,那个代码有点错误, 应该把 HelloLoren 改成HelloHere
  • 打赏
  • 举报
回复
var a = MemoryMappedFile.OpenExisting("HelloHere"); 测试 7.5下并无异常

110,529

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧