【问题标题】:Program crashes when using Managed DirectX with .Net Framework 4.0将托管 DirectX 与 .Net Framework 4.0 一起使用时程序崩溃
【发布时间】:2012-06-22 18:46:14
【问题描述】:

我们在将 DirectSound 与托管 DirectX dll 和 .Net Framework 4.0 一起使用时遇到问题

该程序在 .Net Framework 2.0 上运行良好 - 但我们需要升级到 4.0 才能使用其他一些组件。

当程序调用 Sound 模块时,它会崩溃并出现以下异常。

有人看过这个并知道如何修复它吗?

==============================================
System.IO.FileNotFoundException was unhandled
Message=Could not load file or assembly 'Microsoft.DirectX, Version=2.0.0.0, Culture=neutral,    PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
Source=Microsoft.DirectX.DirectSound
FileName=Microsoft.DirectX, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
FusionLog=""
[stack dump snipped]
InnerException: System.IO.FileNotFoundException
Message=Could not load file or assembly 'Microsoft.DirectX, Version=1.0.2902.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
FileName=Microsoft.DirectX, Version=1.0.2902.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35

FusionLog==== Pre-bind state information ===
LOG: User = *****************
LOG: DisplayName = Microsoft.DirectX, Version=1.0.2902.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file:///C:/Users/*********/Documents/Visual Studio 2010/Projects/************/bin/x86/Debug/
LOG: Initial PrivatePath = NULL

Calling assembly : Microsoft.DirectX.DirectSound, Version=1.0.2902.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\***********\Documents\Visual Studio 2010\Projects\****************\bin\x86\Debug\***************.exe.config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Redirect found in application configuration file: 1.0.2902.0 redirected to 2.0.0.0.
LOG: Post-policy reference: Microsoft.DirectX, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: The same bind was seen before, and was failed with hr = 0x80070002.
InnerException: 

【问题讨论】:

    标签: directx directsound managed-directx


    【解决方案1】:

    我知道这是一个迟到的回复,但为了让我能够正常工作,我必须找到两个 DirectX DLL Microsoft.DirectXMicrosoft.DirectX.DirectInput,然后将其添加为项目的引用。

    然后只需使用 DirectX 命名空间来调用方法。

    【讨论】:

    • 这个问题最终得到了 DirectX 团队的一名 Microsoft 员工的回答。答案是:
    【解决方案2】:
     <!--  Uncomment this section when switching from Net2.0 to Net 4.0 
      It is intended to fix problems loading DirectX dlls  - per Microsoft-->
    
     <!-- 
    
      <startup useLegacyV2RuntimeActivationPolicy="true">
      <supportedRuntime version="v4.0"/>
    
       </startup>
     -->
    

    【讨论】:

    • 请提供指向 Microsoft 推荐的链接。
    【解决方案3】:

    传统的 DirectX Managed 1.1 程序集正式不支持 .NET 4.0。有关详细信息,请参阅此 blog 帖子。

    您可以考虑使用SlimDX 或其他替代方法...

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-12-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多