MemoryStream fs = new MemoryStream();
byte[] tmp = null;
// 序列化
BinaryFormatter formatter = new BinaryFormatter();
formatter.Serialize(fs, obj);
tmp = fs.ToArray();这段代码,在本地运行正常,上传到虚拟主机上出现权限错误,信息如下:Security Exception
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file. Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.请高手指点,谢谢
byte[] tmp = null;
// 序列化
BinaryFormatter formatter = new BinaryFormatter();
formatter.Serialize(fs, obj);
tmp = fs.ToArray();这段代码,在本地运行正常,上传到虚拟主机上出现权限错误,信息如下:Security Exception
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file. Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.请高手指点,谢谢
解决方案 »
- fckeditor中插入图片,如何设置自动给图片加上链接~
- 求助 ADO.NET entity framework 数据表添加数据的问题
- 有用oracle和asp.net配合的吗 我想问下捕获异常的问题
- sql查询的问题
- NET.AfritXia.RssFoundation,RSS 聚合创建框架
- asp.net中treeview的刷新问题,新手.最好给VB.net代码.代码看附件
- 收藏的asp.net经典技术文章
- 一个高分的刷新问题。。。。。。
- 谁能将这条语句写成c#?
- 怎么编写代码可以使网页上面的某一控件在托动网页滚动条的时候保持不动?
- 花生壳问题?
- 我实在是有点想不明白啊。ASPNET有前途吗??
up
{
using (FileStream fs = new FileStream(path, fileMode))
{
BinaryFormatter formatter = new BinaryFormatter();
formatter.Serialize(fs, obj);
}
}public static string SerializeToXml(object obj)
{
string xml = "";
using (MemoryStream memoryStream = new MemoryStream())
{
XmlSerializer serializer = new XmlSerializer(obj.GetType());
serializer.Serialize(memoryStream, obj);
memoryStream.Seek(0, 0);
xml = Encoding.ASCII.GetString(memoryStream.ToArray());
} return xml;
}
string base64 = "";
byte[] aryByte = Convert.FromBase64String(base64);
BinaryFormatter formatter = new BinaryFormatter();
MemoryStream memoryStream = new MemoryStream(aryByte,0,aryByte.Length);
myobject = (MySerialObject)formatter.Deserialize(memoryStream);
memoryStream.Close();