【问题标题】:Where do i find System.Windows.Media ? The Media is not exist我在哪里可以找到 System.Windows.Media ?媒体不存在
【发布时间】:2014-11-23 11:44:06
【问题描述】:

我试过了:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using AviFile;
using ScreenShotDemo;
using System.Threading;
using System.Windows.

在我的新课程中,但在底部的 system.Windows 中。 没有媒体

我正在使用 Visual c# pro 2012 和 .net 4.5 尝试将其添加为参考,在 .net 和 COM 中查找它,但它不存在。

我需要它的原因是在我的代码中我有 PixelFormat 但它不存在:

Bitmap bmpScreenShot = new Bitmap(currentScreen.Bounds.Width,
currentScreen.Bounds.Height,
PixelFormat.Format32bppArgb);

PixelFormat 不存在。

【问题讨论】:

  • 看起来你实际上并没有使用来自 System.Windows.Media 的任何东西。
  • 您似乎想要混合使用 WPF (System.Windows.Media) 和 WinForms (System.Drawing) API。你确定要这样做吗?你的其余代码让我怀疑你根本不想使用System.Windows.Media

标签: c#


【解决方案1】:

您需要将 System.Drawing.Imaging 添加到您的 using 语句中。

您通常可以通过右键单击相关项目并选择“解决”轻松找到需要包含的内容

【讨论】:

  • Thankyouuuuu,使用 vs 3 年,从不知道为提示解析命名空间 +1 这么容易
【解决方案2】:

我正在写这个答案,就像我一样,花了几个小时试图找到using System.Windows.Media,但无法获得 BitmapImage。只需使用using Windows.UI.Xaml.Media.Imaging。它工作得很好。

【讨论】:

    【解决方案3】:

    System.Windows.Media 需要引用 PresentationCore.dll 和

    Pixelformat 需要引用 System.Drawing.dll。

    参见参考here

    【讨论】:

    • 奇怪......但是,添加对“PresentationCore.dll”的引用为我解决了这个问题。谢谢你的政变。
    猜你喜欢
    • 2013-05-21
    • 2015-02-14
    • 2014-07-16
    • 2012-05-30
    • 2013-07-13
    • 2012-06-05
    • 2011-04-24
    • 2021-02-02
    • 2016-07-02
    相关资源
    最近更新 更多