保存xml文件时出现clr错误 [英] clr error in saving xml file

查看:95
本文介绍了保存xml文件时出现clr错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

declare @result varchar(max)
set @result=(SELECT * FROM tbroomtype FOR XML
raw('Room_info'), root('Roomtypes'))
print @result
 exec [dbo].[xp_SaveXML] @result,'c:\temp\myxml.xml'





您好,我使用clr将xml内容保存到指定的文件中. ..
当我运行上面的查询时,它给了我以下错误:

写入文件``类型为System.Security.Permissions.FileIOPermission,mscorlib,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089''的权限的请求时出错.

我正在使用.net 2008和mssql 2008

有什么可以帮助我的吗?
感谢





hi i m using clr to save the xml content into the specified file . ..
when i m running this above query it is giving me following error :

Error writing to file Request for the permission of type ''System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'' failed.

i m using .net 2008 and mssql 2008

can any help me???
thanks

推荐答案

什么是xp_SaveXML?

尽管您很难看到代码,但是很难确定.

运行您的代码的用户是否有权在c:\ Temp中创建文件?
What is xp_SaveXML?

There is a chance that your problem is there, although without seeing the code it is difficult to be sure.

Does the user running your code have permissions to create a file in c:\Temp?


我首先将对目录的读写权限添加到目录中
..
xp_saveXml是我的clr存储过程

i jst add the read write permission to the directory
..
and xp_saveXml is my clr stored procedure

[Microsoft.SqlServer.Server.SqlProcedure]
   public static void xp_SaveXML(string  XmlData, String Filename)
   {
       try
       {
           FileIOPermission(FileIOPermissionAccess.AllAccess, Filename);
           PermissionSet(PermissionState.Unrestricted);
           ps.AddPermission(fp);
           File.WriteAllText(Filename, XmlData);
           XmlDocument xmlDoc = new XmlDocument();
           SqlPipe output = SqlContext.Pipe;
           xmlDoc.LoadXml(XmlData);
           xmlDoc.Save(Filename);
       }
       catch (Exception ex)
       {
           SqlContext.Pipe.Send("Error writing to file " + ex.Message);
       }
   }


....
it i think related to mu assebly strong name problem .. . as my assembly created from clr stored procedure is not assigned a strong name ....uh i m jst thinking of that all i m not sure about all this
....

can u plz go through this..?


thanks for reply


嘿,我得到了我的回答....
http://blog.strictly-software.com/2009/09/database-owner-sid-recorded-in-master.html [
hey guys i got my answer ....
http://blog.strictly-software.com/2009/09/database-owner-sid-recorded-in-master.html[^]


这篇关于保存xml文件时出现clr错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆