高分求教vs2010调用DirectX

北京2008 2012-05-09 02:11:15
Microsoft.DirectX.DirectSound.SecondaryBuffer snd = null;
Microsoft.DirectX.DirectSound.Device dev = null;
Microsoft.DirectX.DirectSound.BufferDescription buffDes = null;
在vs2008中编译没问题,在运行的时候会出现“C:\WINDOWS\assembly\GAC\Microsoft.DirectX.DirectSound\1.0.2902.0__31bf3856ad364e35\Microsoft.DirectX.DirectSound.dll”正试图在 OS 加载程序锁内执行托管代码。不要尝试在 DllMain 或映像初始化函数内运行托管代码,这样做会导致应用程序挂起的异常,但是继续运行是没问题的,后来进过设置vs2008,这个异常也不报了。
可我现在vs2010中这么用的时候这个异常它不报了,直接出现假死或者软件直接关闭的问题,请高手指点下,谢谢
...全文
142 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
mizuho_2006 2012-05-09
  • 打赏
  • 举报
回复
加一段代码到program.cs,如果程序出现直接关闭,会记录错误日志到文件。查看日志找到出错行看看错误在哪里。

话说40分也太少了。


static Program()
{
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
}

static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
string strException = string.Format("{0}发生系统异常。\r\n{1}\r\n\r\n\r\n", DateTime.Now, e.ExceptionObject.ToString());
File.AppendAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SystemException.log"), strException);
}

110,571

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧