关于VS2010 C#使用DirectX的问题[英]

转载的,就不翻译了…微软把精力放到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.net library 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 D3DImage class 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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
DirectX修复工具(DirectX Repair)是一款系统级工具软件,简便易用。本程序为绿色版,无需安装,可直接运行。 本程序的主要功能是检测当前系统的DirectX状态,如果发现异常则进行修复。程序主要针对0xc000007b问题设计,可以完美修复该问题。本程序中包含了最新版的DirectX redist(Jun2010),并且全部DX文件都有Microsoft的数字签名,安全放心。 本程序为了应对一般电脑用户的使用,采用了傻瓜式一键设计,只要点击主界面上的“检测并修复”按钮,程序就会自动完成校验、检测、下载、修复以及注册的全部功能,无需用户的介入,大大降低了使用难度。 本程序适用于多个操作系统,如Windows XP(需先安装.NET 2.0,详情请参阅“致Windows XP用户.txt”文件)、Windows Vista、Windows 7、Windows 8、Windows 8.1、Windows 8.1 Update、Windows 10,同时兼容32位操作系统和64位操作系统。本程序会根据系统的不同,自动调整任务模式,无需用户进行设置。 本程序的V3.5版分为标准版、增强版以及在线修复版。标准 版支持修复DirectX的功能,而增强版则支持同时修复DirectXc++的功能。在线修复版与标准版相同,默认只支持修复DirectX,但其所需的数据包需要在修复时自动下载。各个版本之间,主程序完全相同,只是其配套使用的数据包不同。因此,标准版和在线修复版可以通过补全扩展包的形式成为增强版。本程序自V3.5版起,自带扩展功能。只要在主界面的“工具”菜单下打开“选项”对话框,找到“扩展”标签,点击其中的“开始扩展”按钮即可。扩展过程需要Internet连接,扩展成功后重新运行程序即可使新的数据包生效。扩展用时根据网络速度不同而不同,最快仅需数秒,最慢需要数分钟,烦请耐心等待。 本程序自V2.0版起采用全新的底层程序架构,使用了异步多线程编程技术,使得检测、下载、修复单独进行,互不干扰,快速如飞。新程序更改了自我校验方式,因此使用新版本的程序时不会再出现自我校验失败的错误;但并非取消自我校验,因此程序安全性与之前版本相同,并未降低。 程序有自动更新c++功能。由于绝大多数软件运行时需要c++的支持,并且c++的异常也会导致0xc000007b错误,因此程序在检测修复的同时,也会根据需要更新系统中的c++组件。自V3.2版本开始使用了全新的c++扩展包,可以大幅提高工业软件修复成功的概率。修复c++的功能仅限于增强版,标准版及在线修复版在系统c++异常时(非丢失时)会提示用户使用增强版进行修复。 程序有两种窗口样式。正常模式即默认样式,适合绝大多数用户使用。另有一种简约模式,此时窗口将只显示最基本的内容,修复会自动进行,修复完成10秒钟后会自动退出。该窗口样式可以使修复工作变得更加简单快速,同时方便其他软件、游戏将本程序内嵌,即可进行无需人工参与的快速修复。开启简约模式的方法是:打开程序所在目录下的“Settings.ini”文件(如果没有可以自己创建),将其中的“FormStyle”一项的值改为“Simple”并保存即可。 程序有高级筛选功能,开启该功能后用户可以自主选择要修复的文件,避免了其他不必要的修复工作。同时,也支持通过文件进行辅助筛选,只要在程序目录下建立“Filter.dat”文件,其中的每一行写一个需要修复文件的序号即可。该功能仅针对高级用户使用,并且必须在正常窗口模式下才有效(简约模式时无效)。 本程序有自动记录日志功能,可以记录每一次检测修复结果,方便在出现问题时,及时分析和查找原因,以便找到解决办法。 程序的“选项”对话框中包含了5项高级功能。点击其中的“注册系统文件夹中所有dll文件”按钮可以自动注册系统文件夹下的所有dll文件。该项功能不仅能修复DirectX问题,还可以修复系统中很多其他由于dll未注册而产生的问题,颇为实用。点击该按钮旁边的小箭头,还可以注册任意指定文件夹下的dll文件,方便用户对绿色版、硬盘版的程序组件进行注册。点击第二个按钮可以为dll文件的右键菜单添加“注册”和“卸载”项,方便对单独的dll文件进行注册。请注意,并不是所有的dll文件都可以通过这种方式注册。点击“扩展”选项卡可以将任意版本的程序扩展成增强版。点击“DirectX版本”选项卡,可以自行修改系统中DirectX的版本信息。点击“DirectX加速”选项卡可以控制系统中DirectX加速的开启与关闭。 新版程序集成了用户反馈程序,可以在用户允许的前提下发送检测修复结果。用户也可以在出现问题时通过反馈程序和软件作者进行交流,共同查找问题。反馈是完全自愿和匿名(如果不填写E-mail地址)的。 本程序的通用版基于Microsoft .NET Framework 2.0开发,对于Windows 2000、Windows XP、Windows 2003的用户需要首先安装.NET Framework 2.0或更高版本方可运行本程序。有关下载和安装的详细信息请参阅“致Windows XP用户.txt”文件。对于Windows Vista、Windows 7及后续用户,可以直接运行本程序。 同时鉴于Windows 8(Windows 8.1、Windows 8.1 Update)、Windows 10系统中默认未包含.NET Framework 2.0,因此新版的程序文件夹内将包含一个DirectX_Repair_win8_win10的特别版程序,该程序功能与通用版相同,基于.NET Framework 4.0开发,可以在Windows8(Windows 8.1、Windows 8.1 Update)、Windows 10系统中直接运行(其他系统如果安装了.NET Framework 4.0也可以运行这个特别版的程序)。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值