2

编辑:我解决了我的问题。

我似乎和这个和这个有同样问题。除了我可以使用 XNA3.0 或 3.1,但它们都没有 Microsoft.Xna.Framework.Xact.dll 而是有 Microsoft.Xna.Framework 和 Microsoft.Xna.Framework.Game 。

我正在 Microsoft 表面表上编程,我从使用 XNA 2.0 的示例中复制了代码。我可以很好地运行示例代码,但我找不到它正在使用的参考。

我对 Microsoft.Xna.Framework 和 Microsoft.Xna.Framework.Game 都有引用,并且在我拥有的代码中

using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework;

我的代码在尝试创建新的 AudioEngine 时中断:(因为如果我将其注释掉,程序就会运行)

string filename = System.Windows.Forms.Application.ExecutablePath;
string path = System.IO.Path.GetDirectoryName(filename) + "\\Audio\\";

try
{
audioEngine = new AudioEngine(path + "PianoSounds.xgs");
waveBank = new WaveBank(audioEngine, path + "PianoSounds.xwb");
soundBank = new SoundBank(audioEngine, path + "PianoSounds.xsb");
}

我得到的错误不是很有帮助:

Cannot create instance of 'SurfaceWindow1' defined in assembly 'CoffeeTable1, Version=1.0.4652.32991, Culture=neutral, PublicKeyToken=null'. Exception has been thrown by the target of an invocation.  Error in markup file 'CoffeeTable1;component/SurfaceWindow1.xaml' Line 1 Position 18.

这是尝试初始化的 xaml 文件 SurfaceWindow1.xaml:

<s:SurfaceWindow x:Class="CoffeeTable1.SurfaceWindow1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:s="http://schemas.microsoft.com/surface/2008"
    Title="CoffeeTable1"
    >
  <s:SurfaceWindow.Resources>
    <ImageBrush x:Key="WindowBackground" Stretch="None" Opacity="0.6" ImageSource="pack://application:,,,/Resources/WindowBackground.jpg"/>
  </s:SurfaceWindow.Resources>

  <Grid Background="{StaticResource WindowBackground}" >
        <s:SurfaceButton Content="A" ContactEnter="StartSound" Margin="50,50,0,0" Height="100" Width="100" HorizontalAlignment="Left" VerticalAlignment="Top" Name="A6" ClickMode="Hover" />
    </Grid>
</s:SurfaceWindow>
4

0 回答 0