转载的,就不翻译了…微软把精力放到xna去了。所以推荐大家用XNA,如果非要用托管的DirectX也可以,只不过版本一直是2006年的了。

具体方法:

安装SDK之后

他默认的位置在
C:\WINDOWS\Microsoft.NET\Managed DirectX
把里面相应版本的Microsoft.DirectX.Direct3DX.Dll都复制到
C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0

在项目里面就可以添加引用了。

With the DirectX SDK (June 2010) release and the addition of support for Visual Studio 2010, I’ve been seeing a lot of questions of the form:

How do I create a DirectX .NET application in Visual Studio 2010? I can’t find Microsoft.DirectX to add to my project but I have the DirectX SDK (June 2010) release installed.

As with many seemingly simple questions on a technical topic, this one is actually quite complex.

Back in the days of DirectX 7 and DirectX 8, there was support included for using DirectX from Visual Basic. While most developers used DirectX APIs via C and C++, there was intense interest in the hobbyist community to access this technology. Thus the focus on enabling Visual Basic developers. When working on DirectX 9, Visual Basic had become unified with the .NET family of languages and thus Managed DirectX 1.1 was created (with a great deal of individual passion and effort from Tom Miller and others on the DirectX team at the time). It was designed for the .NET 1.1 Runtime, and include managed wrappers for the whole family of DirectX technology: Direct3D 9, D3DX9, DXDIAG, DirectDraw, DirectInput, DirectPlay, DirectSound, and a simple wrapper for DirectShow. The focus shifted from the Visual Basic language to C#, although VB .NET could still be used.

Note: The DirectX 7 and 8 Visual Basic 6.0 support I mention here is no longer available as of Windows Vista. It was part of DirectX 9.0c and was included with Windows XP Service Pack 2&3, Windows Server 2003 Service Pack 1 & 2, and Windows XP Professional x64 Edition.

With the release of .NET 2.0, there was an effort to update Managed DirectX to use the new constructs and in 2005 there was a Managed DirectX 2.0 Beta included as part of the DirectX SDK. As this effort was underway, a major reorganization at Microsoft took place and when the dust settled, the relatively small team that had been working on this technology suddenly found themselves as the seed of an entirely new effort around .NET gaming development: XNA Game Studio. The Managed DirectX 2.0 project was shelved, and all the effort focused on this new more comprehensive end-to-end solution for the indie game developers targeting Windows, Xbox 360, Zune, and eventually Windows Phone 7.

Managed DirectX 1.1 as it stands today is deprecated. It was last updated in April 2006 to match that version of D3DX9, while the Managed DirectX 1.1 documentation was last updated in August 2005. The last DirectX SDK to include the samples and documentation for Managed DirectX 1.1 was August 2006. Since that time, we’ve continued to include the Managed DirectX 1.1 assemblies in the DirectX SDK Developer Runtime, the DirectSetup REDIST folder, the DirectX End-User Runtime package, and the DirectX End-User Runtime Web Installer to simplify legacy deployment and support existing applications that relied on it. This last support for Managed DirectX 1.1 deployment is likely to be removed in a future DirectX SDK update.

At this point, Managed DirectX 1.1 is really beginning to show it's age.

  • Since the last version of D3DX9 supported by Managed DirectX 1.1 is April 2006, it makes use of a very outdated version of the HLSL compiler.
  • The Managed DirectX 1.1 assemblies are 32-bit only, so you cannot use them from an x64 native .NET application (/platform:anycpu on a Windows x64 system). You must build with /platform:x86 and stay within the limits of the 2 GB memory space of 32-bit applications.
  • The assemblies only support the legacy DirectX API set, with no support for Direct3D9Ex, Direct3D 10.x, Direct3D 11, Direct2D, DirectWrite, DXGI, D3DX10, D3DX11, XAUDIO2, XACT, XINPUT, etc.
  • Since Managed DirectX 2.0 was never released in production form, the Managed DirectX 1.1 assemblies still reflect .NET 1.1 design principles and does not support or make use of .NET 2.0 constructs.
  • Managed DirectX 1.1 while compatible with .NET 2.0 (and the .NET 3.0 and .NET 3.5 extensions of the 2.0 runtime), is not compatible with .NET 4.0

The last bullet here is the heart of the issue I started out with in this post. The Visual Studio 2010 toolset only supports developing .NET 4.0 applications, and therefore Managed DirectX 1.1 as a .NET 1.1 technology is not supported by Visual Studio 2010. BTW, it is possible to use the Visual Studio 2010 IDE to build .NET 2.0 applications using older toolsets through multi-targeting, but this is really using legacy tools which do work with .NET 1.1 era assemblies.

The modern version of the DirectX SDK is designed for C/C++ native developers. If you are looking for .NET solutions for using DirectX technology, there are many options available although the choice of solution depends on your specific needs:

  • XNA Game Studio is the solution aimed directly at indie game developers looking to create Direct3D games on Windows, Xbox 360, Zune, and Windows Phone 7. It currently has some limitations (requires /platform:x86, no support for DirectX 10.x or DirectX 11, more focused DirectX API support), but includes numerous tools and a vibrant developer community. Those original hobbyist developers Tom Miller wanted to help are very well served by this product, as is the professional and indie game developer looking for a complete solution for writing .NET games.
  • For a developer using the Windows Presentation Foundation but wants to use the new DirectX 11 APIs, the Windows API Code Pack provides managed assemblies for Direct3D 10.1, Direct3D 11, Direct2D, DirectWrite, DXGI, and the Windows Imaging Library  (WIC) along with many other Windows 7 features. The latest version supports .NET 4.0, and x64 native “anycpu” applications. Note you still need to install the DirectX SDK to get the HLSL compiler (FXC.EXE) tool.
  • For developers who are invested in Managed DirectX 1.1 but are looking for updates to address the limitations I note above, the open sourceSlimDX library is designed to mimic Managed DirectX 1.1 for just this purpose. It includes support for x64 native “anycpu” applications, includes modern DirectX support, and is compatible with the .NET 4.0 runtime.
  • If you are a media developer using DirectShow and want a more complete solution than the simple Managed DirectX 1.1 wrapper, the open source directshow.netlibrary may be useful to you, although it doesn’t yet appear to have been updated to be .NET 4.0 compatible.

If these solutions don’t work for you, you can always write your own managed wrapper using standard native interop constructs or use Managed C++/CLI to write the DirectX portion of your application in C/C++ using the DirectX SDK. The Windows Presentation Foundation D3DImageclass can be a useful way to do this interop, although the use of Direct3D9Ex on Windows Vista and Windows 7 can cause some problems with components like D3DX9 which you should watch out for.

关于VS2010 C#使用DirectX的问题[英]的更多相关文章

  1. [转]DirectX and .NET[英]

    With the DirectX SDK (June 2010) release and the addition of support for Visual Studio 2010, I’ve be ...

  2. 搭把手教美工妹妹如何通过升级SSD提升电脑性能

    -----by LinHan 不单单适用于妹子,我这名的意思的妹子也能看懂. 以下教程依据实践和部分互联网资料总结得出,向博客园, CSDN的前辈们致谢:同时,如有说的不正确或有不到位的地方,麻烦指出 ...

  3. C# WPF 显示图片和视频显示 EmuguCv、AForge.Net测试

    WPF 没有用到 PictureBox, 而是用Image代替. 下面我试着加载显示一个图片 . XAML <Image x:Name="srcImg"Width=" ...

  4. 新机上岗 Core i7-4790 @ 3.60GHz 四核 / 16 GB ( 金士顿 DDR3 1866MHz ) / GeForce GTX 970 ( 4 GB / 七彩虹 )

    新机上岗 ==============================电脑型号 华硕 All Series 台式电脑操作系统 Windows 7 旗舰版 64位 SP1 ( DirectX 11 )  ...

  5. Win系统下制作U盘CLOVER引导+安装原版Mavericks10.9

    啃苹果有一段时间了,之前一直用白苹果,但是白苹果配置有所限制,对于我搞音频的人来讲,显得有点拖沓.所以研究了将近2年的黑苹果,最近心血来潮给大家一个比较傻瓜式的教程,首先强调一点,黑苹果是需要折腾的, ...

  6. B450配置

    电脑型号 联想 B450 笔记本电脑  (扫描时间:2015?5?7?操作系统 Windows 7 旗舰版 32位 SP1 ( DirectX 11 ) 处理器 英特尔 酷睿2 双核 T9800 @ ...

  7. 固态硬盘Ghost安装Windows 10无法引导的问题

    机器配置如下: 电脑型号 技嘉 B360M POWER 台式电脑 操作系统 Windows 10 64位 ( DirectX 12 ) 处理器 英特尔 Core i7-8700 @ 3.20GHz 六 ...

  8. 第一篇:CUDA 6.0 安装及配置( WIN7 64位 / 英伟达G卡 / VS2010 )

    前言 本文讲解如何在VS 2010开发平台中搭建CUDA开发环境. 当前配置: 系统:WIN7 64位 开发平台:VS 2010 显卡:英伟达G卡 CUDA版本:6.0 若配置不同,请谨慎参考本文. ...

  9. DirectX 9 SDK安装后在vs2010里编译BaseClasses出错问题解决方法

    打开你的dx的sdk安装目录,例如: D:/DX90SDK/Samples/C++/DirectShow/ 这里就有一个叫baseclasses的工程,为安全起见,请先备份此工程. 1,双击basec ...

随机推荐

  1. MVC 导出Execl 的总结几种方式 (三)

    第三种方式呢,就是借用第三方插件 NPOI 来实现Execl 导出 第一步:在NuGut包中下载NPOI 组件 第二步:编辑控制器代码 public FileResult ExcelNewKeyPro ...

  2. python 字符串居中

    下面的代码可以让字符串居中,左对齐和右对齐,字符串长度设置为50,居中后左右补充空格,右对齐会在左侧补充空格 string1 = "Now I am here." print( s ...

  3. Javascript全选,反选,全不选的实现代码

    使用js实现全选.反选.全不选. 代码如下: <html> <head> <script type="text/javascript"> fun ...

  4. css中单位em和rem的区别

    在css中单位长度用的最多的是px.em.rem,这三个的区别是: px是固定的像素,一旦设置了就无法因为适应页面大小而改变. em和rem相对于px更具有灵活性,他们是相对长度单位,意思是长度不是定 ...

  5. php写入文件fwrite() 函数用法

    在php中,php fwrite() 函数是用于写入文件(可安全用于二进制文件).说的简单点,就是在一个文件中,添加新的内容,本篇文章收集总结了几篇关于php写入文件fwrite() 函数用法的总结, ...

  6. 浏览器根对象document之方法概述

    1.1 节点 筛选 getRootNode返回上下文的根节点. querySelector返回文档中匹配指定 CSS 选择器的第一个元素. querySelectorAll返回文档中匹配指定 CSS ...

  7. flutter开发中常用的dart插件

    flutter插件官网地址:https://pub.dartlang.org/packages/ 1. image_picker 一个可以从图库选择图片,并可以用相机拍摄新照片的flutter插件 2 ...

  8. mysql 存储引擎 配置文件my.ini 的配置方式

    如果想使修改后的参数生效,须重新启动MySQL服务器. #存储引擎设置 default-storage-engine = INNODB

  9. python 基础-----数字,字符串,if while 循环 数据类型的转换简单介绍

    一.第一个python小程序 首先我们要知道python创立的初衷是:Python崇尚优美.清晰.简单. 所以python比起其他的语言需要的工作量少了一半都不止,比如和现在一直霸占语言排行榜  榜首 ...

  10. [翻译] OCMaskedTextField

    OCMaskedTextField https://github.com/OmerCora/OCMaskedTextField Simple class to display dynamically ...