我遇到了一个奇怪的问题。我正在使用适用于 Windows Phone 8 的 Visual Studio 2012 Express,并且想要引用 System.Drawing.dll。我右键单击项目中的“引用”,然后单击“添加引用...”,但是,我在.NET选项卡下找不到System.Drawing.dll。有什么想法吗?
实际上我想将我的图像转换为 base64
。我有一种方法,该方法包含 Sysytem.drawing
成像.dll。
public string imagetobase64(image image,
system.drawing.imaging.imageformat format)
{
using (memorystream ms = new memorystream())
{
// convert image to byte[]
image.save(ms, format);
byte[] imagebytes = ms.toarray();
// convert byte[] to base64 string
string base64string = convert.tobase64string(imagebytes);
return base64string;
}
}
Convert image to base64 string 。我该如何解决这个问题?
最佳答案
(在问题改为实际问两个问题之前回答...)
Any ideas why?
是的 - 您根本无法在 Windows Phone 8 中使用 System.Drawing.dll
。
看看list of supported .NET namespaces in Windows Phone 8 - System.Drawing
不存在,并且 System.Drawing.dll
中的所有公共(public)类型都在 System.Drawing
命名空间中(或者无论如何,以 System.Drawing
开头)。
您还没有说出您实际上想要实现的目标,但您只需要找到其他方法即可实现。
关于c# - 引用中的 wp8 :Cannot find System. Drawing.dll,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16272229/