本人是新手,在执行程序时出现"“Tao.PerformanceTimer”的类型初始值设定项引发异常"的异常情况,该异常的详细情况如下:
System.TypeInitializationException: “Tao.PerformanceTimer”的类型初始值设定项引发异常。 ---> System.EntryPointNotFoundException: 无法在 DLL“kernel32”中找到名为“QueryPerformenceFrequency”的入口点。
在 Tao.PerformanceTimer.QueryPerformenceFrequency(Int64& PerformanceFrenquency)
在 Tao.PerformanceTimer..cctor() 位置 d:\Visual Studio 2005\Projects\复件 Tao\Tao\PerformanceTimer.cs:行号 19
--- End of inner exception stack trace ---
在 Tao.PerformanceTimer.QueryPerformanceCounter(Int64& PerformanceCount)
在 Tao.GLWindow.Render() 位置 d:\Visual Studio 2005\Projects\复件 Tao\Tao\GLWindow.cs:行号 101
在 Tao.MainForm..ctor() 位置 d:\Visual Studio 2005\Projects\复件 Tao\Tao\MainForm.cs:行号 28
在 Tao.Program.Main() 位置 d:\Visual Studio 2005\Projects\复件 Tao\Tao_test081112\Program.cs:行号 17下面是部分相关程序源码:当执行Render()函数的语句“PerformanceTimer.QueryPerformanceCounter(ref startTicks);”是就出现如前所述异常。
请各位高手指教!!!using System;
using System.Collections;//.Generic;
using System.Text;
using System.Runtime.InteropServices;namespace Tao
{
public sealed class PerformanceTimer
{
public static long TicksPerSecond; static PerformanceTimer()
{
long tickFrequency=0;
if(!QueryPerformenceFrequency(ref tickFrequency))
throw new NotSupportedException("The machine doesn't appear to support high resolution timer.") ;
TicksPerSecond=tickFrequency;
System.Diagnostics.Debug.WriteLine("tickFrenquency="+tickFrequency);
} #region High Resolution Timer functions
[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport("kernel32")]
private static extern bool QueryPerformenceFrequency(ref long PerformanceFrenquency); [System.Security.SuppressUnmanagedCodeSecurity]
[DllImport("kernel32")]
public static extern bool QueryPerformanceCounter(ref long PerformanceCount);
#endregion
}
public void Render()
{
long startTicks = 0;
PerformanceTimer.QueryPerformanceCounter(ref startTicks);
try
{ }
catch()
{}
...........
}
}
System.TypeInitializationException: “Tao.PerformanceTimer”的类型初始值设定项引发异常。 ---> System.EntryPointNotFoundException: 无法在 DLL“kernel32”中找到名为“QueryPerformenceFrequency”的入口点。
在 Tao.PerformanceTimer.QueryPerformenceFrequency(Int64& PerformanceFrenquency)
在 Tao.PerformanceTimer..cctor() 位置 d:\Visual Studio 2005\Projects\复件 Tao\Tao\PerformanceTimer.cs:行号 19
--- End of inner exception stack trace ---
在 Tao.PerformanceTimer.QueryPerformanceCounter(Int64& PerformanceCount)
在 Tao.GLWindow.Render() 位置 d:\Visual Studio 2005\Projects\复件 Tao\Tao\GLWindow.cs:行号 101
在 Tao.MainForm..ctor() 位置 d:\Visual Studio 2005\Projects\复件 Tao\Tao\MainForm.cs:行号 28
在 Tao.Program.Main() 位置 d:\Visual Studio 2005\Projects\复件 Tao\Tao_test081112\Program.cs:行号 17下面是部分相关程序源码:当执行Render()函数的语句“PerformanceTimer.QueryPerformanceCounter(ref startTicks);”是就出现如前所述异常。
请各位高手指教!!!using System;
using System.Collections;//.Generic;
using System.Text;
using System.Runtime.InteropServices;namespace Tao
{
public sealed class PerformanceTimer
{
public static long TicksPerSecond; static PerformanceTimer()
{
long tickFrequency=0;
if(!QueryPerformenceFrequency(ref tickFrequency))
throw new NotSupportedException("The machine doesn't appear to support high resolution timer.") ;
TicksPerSecond=tickFrequency;
System.Diagnostics.Debug.WriteLine("tickFrenquency="+tickFrequency);
} #region High Resolution Timer functions
[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport("kernel32")]
private static extern bool QueryPerformenceFrequency(ref long PerformanceFrenquency); [System.Security.SuppressUnmanagedCodeSecurity]
[DllImport("kernel32")]
public static extern bool QueryPerformanceCounter(ref long PerformanceCount);
#endregion
}
public void Render()
{
long startTicks = 0;
PerformanceTimer.QueryPerformanceCounter(ref startTicks);
try
{ }
catch()
{}
...........
}
}
[DllImport("kernel32")]
private static extern bool QueryPerformenceFrequency(ref long PerformanceFrenquency); Kernel32没有这个API:QueryPerformenceFrequency
楼主是不是搞错了?
同样谢谢楼上!
不是
QueryPerformenceFrequency();
如果没有分号,生成时系统提示让添加分号。
是"a"不是"e"我有点汗的,!-__-