编辑:我解决了我的问题。
我似乎遇到与this one和this one相同的问题。除了我可以使用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>