smremde Posted October 10, 2003 Posted October 10, 2003 i have this classImports System.Runtime.InteropServices Public Class Timer Private m_Frequency As Long Private m_Count As Long Public Sub New() QueryPerformanceFrequency(m_Frequency) End Sub Public ReadOnly Property FTime() As Double Get QueryPerformanceCounter(m_Count) Return m_Count / m_Frequency End Get End Property <DllImport("Kernel32.dll")> Private Function QueryPerformanceCounter(ByRef lpPerformanceCount As Long) As Boolean End Function <DllImport("Kernel32.dll")> Private Function QueryPerformanceFrequency(ByRef lpFrequency As Long) As Boolean End Function End Class and i get exceptions here QueryPerformanceFrequency(m_Frequency) and here QueryPerformanceCounter(m_Count): An unhandled exception of type 'System.InvalidProgramException' occurred in xfengine.dll Additional information: Error: PInvoke item (field,method) must be Static. The program '[1588] XF2.exe' has exited with code 0 (0x0). xfengine.dll is my class library containing the high resolution timer and XF2.exe is the console app using xfengine.dll any help much appreciated Stephen Quote
*Experts* Nerseus Posted October 11, 2003 *Experts* Posted October 11, 2003 All external Dll references must be static. In C# the keyword is static, I'm not sure if it's the same in VB.NET (I think it might be Shared?). Also, I don't think the params should be ByRef for those functions. And I think it should return an Int32, not Boolean (though Bool *might* work, I wouldn't count on it). -Nerseus Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Recommended Posts