在wpf中使用DirectX组件的问题 [英] Problem in using DirectX components in wpf

查看:304
本文介绍了在wpf中使用DirectX组件的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用wpf应用程序中的directX组件时遇到问题。如果我不使用任何DirectX组件,那么没有问题,窗口将被加载。如果我包含DirectX组件并创建一个对象,则窗口不会加载并给出异常:

{混合模式程序集是针对运行时的版本'v1.1.4322'构建的并且无法在没有其他配置信息的情况下加载到4.0运行时。:null}



无论我使用哪种DirectX组件,我都遇到同样的问题。这是我的代码:

I have a problem in using the directX components in wpf application. If I don't use any DirectX components then there's no problem and the window will be loaded. If I include the DirectX component and create an object, then the window is not loading and giving an exception:
{"Mixed mode assembly is built against version 'v1.1.4322' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.":null}

Whichever DirectX component I use I have the same problem. Here is my code:

private void Window_Loaded(object sender, RoutedEventArgs e)
{
     Microsoft.DirectX.DirectSound.Device dev = new Microsoft.DirectX.DirectSound.Device();
     MessageBox.Show("HI");
}

推荐答案

如果您还没有app.config文件,请将其添加到项目中。在此文件中,您需要添加:
Add an app.config file to your project if you don't have one already in place. In this file, you need to add:
<configuration>
  <startup useLegacyV2RuntimeActivationPolicy="true" />
</configuration>

这告诉.NET 4允许混合模式 [< a href =http://msdn.microsoft.com/en-us/library/x0w2664k.aspxtarget =_ blanktitle =New Window> ^ ] CLR 2程序集。

This tells .NET 4 to allow Mixed Mode[^] CLR 2 assemblies.


这篇关于在wpf中使用DirectX组件的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆