本文介绍了保存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
推荐答案
[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
这篇关于保存xml文件时出现clr错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!