在写一个CRL存储过程时,里面调用了IO读文件:
StreamReader sr = File.OpenText(strFileName);
可是调试跟踪到这里就断掉,异常信息为:
System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.查了相关资料后,在代码里加了2句:
FileIOPermission perm = new FileIOPermission(FileIOPermissionAccess.AllAccess, strFileName);
perm.Demand(); StreamReader sr = File.OpenText(strFileName);
可是好象没有作用……
请各位大大帮帮忙解决下!如何在CRL存储过程中进行文件操作呢?
StreamReader sr = File.OpenText(strFileName);
可是调试跟踪到这里就断掉,异常信息为:
System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.查了相关资料后,在代码里加了2句:
FileIOPermission perm = new FileIOPermission(FileIOPermissionAccess.AllAccess, strFileName);
perm.Demand(); StreamReader sr = File.OpenText(strFileName);
可是好象没有作用……
请各位大大帮帮忙解决下!如何在CRL存储过程中进行文件操作呢?
解决方案 »
- 调用动态库图片处理
- 急:C# ToolBar 控件怎么修改背景图片
- 用C#如何从excel中读取一列数据,然后存储到txt中
- ToolStrip 中怎么没有时间控间dateTimePicker
- matlab c# 混合编程问题
- 关于“皮肤技术”的问题,高手请指教,谢谢
- 散分,源码下载:在DataGridColumnStyle的单元格中使用DateTimePicker、ComboBox、NumericUpDown等控件
- 请教高手!如何在DATAGRID表格重绘图片!狂谢!分不够再加!
- 小妹记录来请教,技术哥哥们,请教来了。SQL问题
- win2000是否真的支持unicode?
- 请教下各位大哥,用C#+SQL Server写Winform邮件系统?谢谢!
- 对话框 帮帮忙看下
是CLR……
只是一个CLR存储过程!
编译后和普通的存储过程一样!
VS2005里的SQL项目!
消息 6522,级别 16,状态 1,过程 WebCount,第 0 行
在执行用户定义例程或聚合 'WebCount' 期间出现 .NET Framework 错误:
System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
System.Security.SecurityException:
at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)
at System.Security.CodeAccessPermission.Demand()
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize)
at System.IO.StreamReader..ctor(String path)
at System.IO.File.OpenText(String path)
at StoredProcedures.WebCount(String strLogFilePath)
。
FROM 'D:\IISWebRoot\SQLCLR\MyDbApp\MyDbApp\bin\Release\MyDbApp.dll'
WITH PERMISSION_SET = UNSAFE
GO
FROM 'F:\MyExe\WebCountSql\bin\Debug\WebCountSql.dll'
WITH PERMISSION_SET = UNSAFE
GO
消息 10327,级别 14,状态 1,第 1 行
针对程序集 'WebCountSql' 的 CREATE ASSEMBLY 失败,因为程序集 'WebCountSql' 未获授权(PERMISSION_SET = UNSAFE)。 当符合以下两个条件之一时,将对程序集授权: 数据库所有者(DBO)具有 UNSAFE ASSEMBLY 权限,而且数据库的 TRUSTWORTHY 属性处于打开状态;或者,程序集签名时所使用的证书或非对称密钥所对应的登录名具有 UNSAFE ASSEMBLY 权限我是用的WINDOWS身份登录的SQL!
还是不明白怎么授权啊?