它在我的本地系统上运行得很好。但不是在现场。我使用此代码块通过ckeditor上传图像。我给托管提供商打了电话。我必须写这些代码与信任级别中或高。托管公司不支持完全信任级别。如果我可以用web.config更改完全信任级别,它就会工作得很好。如何编写或更改支持高或中信任级别的代码。
错误:安全异常
描述:应用程序试图执行安全策略不允许的操作。若要授予此应用程序所需的权限,请与系统管理员联系或在配置文件中更改应用程序的信任级别。
异常详细信息: System.Security.SecurityException:请求'System.Security.Permissions.MediaPermission,WindowsBase,Version=3.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35‘类型的权限失败。
public static ImageMedia Create(byte[] data)
{
ImageMedia result = new ImageMedia();
result._source = BitmapDecoder.Create(new MemoryStream(data), BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.None).Frames[0];
result._data = data;
try { result._copyright = ((BitmapMetadata)result._source.Metadata).Copyright; }
catch (Exception) { }
return result;
}发布于 2013-06-24 01:35:36
3.0方式需要完全信任。您可以尝试从较低级别的位图中获取信息
Bitmap MyPhoto =
new Bitmap(@"myphoto.JPG");
PropertyItem[] props =
MyPhoto.PropertyItems;
foreach (PropertyItem prop in props)
{
MessageBox.Show(
prop.Id.ToString());
}有关更多详细信息,请阅读本文:http://www.developerfusion.com/article/84474/reading-writing-and-photo-metadata/
https://stackoverflow.com/questions/17261940
复制相似问题