blodbath's picture

Access violation creating GameWindow

So I got a nice OpenTK project going, terrain with shadowing and reflections and soforth and it worked great. However I upgraded my graphics card drivers and now it appears that it doesn't work any more. Here's my relevant code (note that I don't even get past calling the base constructor):

 
 public static void Main(string[] args) {
            DisplayResolution resolution =
                DisplayDevice.Default.AvailableResolutions[120];
 
 
            using (AppWindow window = new AppWindow(resolution, false)) {
                window.Run(30.0);
            }
 }
 
 public class AppWindow : GameWindow {
        public bool FullScreen { get; private set; }
 
        private GLRenderer renderer = null;
        private Geometry geo = null;
 
        public AppWindow(DisplayResolution resolution, bool fullScreen) 
            : base(
            resolution.Width, 
            resolution.Height, 
            new GraphicsMode(), 
            "SBC", 
            (fullScreen ? GameWindowFlags.Fullscreen : GameWindowFlags.Default), 
            DisplayDevice.Default, 
            3, 0, 
            GraphicsContextFlags.Debug) // fails right here
 {

The constructor for the GameWindow is throwing an access violation down in ChoosePixelFormat called from line 128 of WinGraphicsMode.cs:

int pixel = Functions.ChoosePixelFormat(deviceContext, ref pixelFormat);

deviceContext = 0xffffffffbf0106e2 System.IntPtr

pixelFormat {OpenTK.Platform.Windows.PixelFormatDescriptor} OpenTK.Platform.Windows.PixelFormatDescriptor
AccumAlphaBits 0x00 byte
AccumBits 0x00 byte
AccumBlueBits 0x00 byte
AccumGreenBits 0x00 byte
AccumRedBits 0x00 byte
AlphaBits 0x00 byte
AlphaShift 0x00 byte
AuxBuffers 0x00 byte
BlueBits 0x00 byte
BlueShift 0x00 byte
ColorBits 0x00 byte
DamageMask 0x00000000 int
DepthBits 0x00 byte
Flags DOUBLEBUFFER | DRAW_TO_WINDOW | SUPPORT_OPENGL | DEPTH_DONTCARE OpenTK.Platform.Windows.PixelFormatDescriptorFlags
GreenBits 0x00 byte
GreenShift 0x00 byte
LayerMask 0x00000000 int
LayerType 0x00 byte
PixelType RGBA OpenTK.Platform.Windows.PixelType
RedBits 0x00 byte
RedShift 0x00 byte
Reserved 0x00 byte
Size 0x0028 short
StencilBits 0x00 byte
Version 0x0001 short
VisibleMask 0x00000000 int

Call stack:

> OpenTK.dll!OpenTK.Platform.Windows.WinGraphicsMode.SelectGraphicsModePFD(OpenTK.Graphics.ColorFormat color = {0 (0000)}, int depth = 0x00000000, int stencil = 0x00000000, int samples = 0x00000000, OpenTK.Graphics.ColorFormat accum = {0 (0000)}, int buffers = 0x00000002, bool stereo = false) Line 128 C#

OpenTK.dll!OpenTK.Platform.Windows.WinGraphicsMode.SelectGraphicsMode(OpenTK.Graphics.ColorFormat color = {0 (0000)}, int depth = 0x00000000, int stencil = 0x00000000, int samples = 0x00000000, OpenTK.Graphics.ColorFormat accum = {0 (0000)}, int buffers = 0x00000002, bool stereo = false) Line 78 + 0x6e bytes C#

OpenTK.dll!OpenTK.Graphics.GraphicsMode.Index.get() Line 186 + 0x162 bytes C#

OpenTK.dll!OpenTK.Graphics.GraphicsMode.ToString() Line 329 + 0x4a bytes C#

[External Code]
OpenTK.dll!OpenTK.Graphics.GraphicsContext.GraphicsContext(OpenTK.Graphics.GraphicsMode mode = {OpenTK.Graphics.GraphicsMode}, OpenTK.Platform.IWindowInfo window = {Windows.WindowInfo: Handle 1378484, Parent (Windows.WindowInfo: Handle 524978, Parent (null))}, int major = 0x00000001, int minor = 0x00000000, OpenTK.Graphics.GraphicsContextFlags flags = Default) Line 94 + 0x48 bytes C#

OpenTK.dll!OpenTK.Platform.Windows.WinGraphicsMode.SelectGraphicsModeARB(OpenTK.Graphics.ColorFormat color = {32 (8888)}, int depth = 0x00000010, int stencil = 0x00000000, int samples = 0x00000000, OpenTK.Graphics.ColorFormat accum = {0 (0000)}, int buffers = 0x00000002, bool stereo = false) Line 158 + 0x13a bytes C#

OpenTK.dll!OpenTK.Platform.Windows.WinGraphicsMode.SelectGraphicsMode(OpenTK.Graphics.ColorFormat color = {32 (8888)}, int depth = 0x00000010, int stencil = 0x00000000, int samples = 0x00000000, OpenTK.Graphics.ColorFormat accum = {0 (0000)}, int buffers = 0x00000002, bool stereo = false) Line 70 + 0x6e bytes C#

OpenTK.dll!OpenTK.Graphics.GraphicsMode.Index.get() Line 186 + 0x162 bytes C#

OpenTK.dll!OpenTK.Graphics.GraphicsMode.ToString() Line 329 + 0x4a bytes C#

[External Code]
OpenTK.dll!OpenTK.Graphics.GraphicsContext.GraphicsContext(OpenTK.Graphics.GraphicsMode mode = {OpenTK.Graphics.GraphicsMode}, OpenTK.Platform.IWindowInfo window = {Windows.WindowInfo: Handle 2820158, Parent (Windows.WindowInfo: Handle 3801558, Parent (null))}, int major = 0x00000003, int minor = 0x00000000, OpenTK.Graphics.GraphicsContextFlags flags = Debug) Line 94 + 0x48 bytes C#

OpenTK.dll!OpenTK.GameWindow.GameWindow(int width = 0x000005a0, int height = 0x00000384, OpenTK.Graphics.GraphicsMode mode = {OpenTK.Graphics.GraphicsMode}, string title = "SBC", OpenTK.GameWindowFlags options = Default, OpenTK.DisplayDevice device = {Primary: {X=0,Y=0,Width=1920,Height=1200} (147 modes available)}, int major = 0x00000003, int minor = 0x00000000, OpenTK.Graphics.GraphicsContextFlags flags = Debug, OpenTK.Graphics.IGraphicsContext sharedContext = null) Line 206 + 0xa0 bytes C#

OpenTK.dll!OpenTK.GameWindow.GameWindow(int width = 0x000005a0, int height = 0x00000384, OpenTK.Graphics.GraphicsMode mode = {OpenTK.Graphics.GraphicsMode}, string title = "SBC", OpenTK.GameWindowFlags options = Default, OpenTK.DisplayDevice device = {Primary: {X=0,Y=0,Width=1920,Height=1200} (147 modes available)}, int major = 0x00000003, int minor = 0x00000000, OpenTK.Graphics.GraphicsContextFlags flags = Debug) Line 178 + 0x6d bytes C#

SBC.exe!SBC.AppWindow.AppWindow(OpenTK.DisplayResolution resolution = {{X=0,Y=0,Width=1440,Height=900}x32@60Hz}, bool fullScreen = false) Line 16 + 0xea bytes C#

SBC.exe!SBC.Program.Main(string[] args = {string[0x00000000]}) Line 14 + 0x23 bytes C#

For reference I'm running Windows 7 x64 with an ATI 5770 with the newest (10.3) drivers installed. Oddly enough the example binaries still run just fine so I'm not sure whats going on with it. Mindfully this code was running just fine before I updated my drivers so it may have something to do with that...


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
blodbath's picture

Oh, also I'm using the latest version of OpenTK, 1.0 RC1.

nythrix's picture

I also hit this issue from time to time. The difference being that in my case it is quite random and 9 runs out of 10 are successful. I'm not sure that this is drivers related because I'm running nVidia.

gameWindow = new GameWindow(
    640, 480,
    GraphicsMode.Default,
    "Tests",
    GameWindowFlags.Default,
    DisplayDevice.Default,
    2, 1,
    GraphicsContextFlags.Debug );

Win7 64bit, 196.21, OpenTK 1.0 RC1.

blodbath's picture

Some more information, still haven't solved it (although I haven't had much time to check into things). The debug output log is highly suspect--I can't seem to even step into the calls that generate all this creating/destroying spam. I'm wondering if there's some event logic going on I'm not seeing (I'm not creating multiple threads and VS only shows the main thread).

DisplayDevice 1 (primary) supports 147 resolutions.
Creating default GraphicsMode (32, 16, 0, 0, 0, 2, False).
Creating default GraphicsMode (32, 16, 0, 0, 0, 2, False).
'GLTerrain.exe' (Managed): Loaded 'C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Creating GraphicsContext.
    Device context: -1929310682
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 460790, Parent (null)
Creating GraphicsContext.
    Device context: -1056895444
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 526326, Parent (null)
'GLTerrain.exe' (Managed): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.Debugger.Runtime\9.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Debugger.Runtime.dll'
Creating GraphicsContext.
    Device context: -1107227101
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 591862, Parent (null)
Creating GraphicsContext.
    Device context: -620687852
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 657398, Parent (null)
Creating GraphicsContext.
    Device context: -1929310682
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 722934, Parent (null)
Creating GraphicsContext.
    Device context: -822014462
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 788470, Parent (null)
Creating GraphicsContext.
    Device context: -822014462
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 854006, Parent (null)
Creating GraphicsContext.
    Device context: -620687852
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 919542, Parent (null)
Creating GraphicsContext.
    Device context: -620687852
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 985078, Parent (null)
Creating GraphicsContext.
    Device context: -1107227101
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 1050614, Parent (null)
Creating GraphicsContext.
    Device context: -1929310682
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 1116150, Parent (null)
Creating GraphicsContext.
    Device context: -620687852
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 1181686, Parent (null)
Creating GraphicsContext.
    Device context: -1056895444
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 1247222, Parent (null)
Creating GraphicsContext.
    Device context: -1056895444
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 1312758, Parent (null)
Creating GraphicsContext.
    Device context: -1929310682
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 1378294, Parent (null)
Creating GraphicsContext.
    Device context: 738266625
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 1837046, Parent (null)
Creating GraphicsContext.
    Device context: -822014462
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 1902582, Parent (null)
Creating GraphicsContext.
    Device context: 738266625
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 1968118, Parent (null)
Creating GraphicsContext.
    Device context: -1056895444
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 2033654, Parent (null)
Creating GraphicsContext.
    Device context: -1929310682
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 2099190, Parent (null)
Creating GraphicsContext.
    Device context: -1929310682
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 2164726, Parent (null)
Creating GraphicsContext.
    Device context: 1661011461
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 2230262, Parent (null)
Creating GraphicsContext.
    Device context: -1929310682
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 2295798, Parent (null)
Creating GraphicsContext.
    Device context: -620687852
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 2361334, Parent (null)
Creating GraphicsContext.
    Device context: -822014462
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 2557942, Parent (null)
Creating GraphicsContext.
    Device context: -620687852
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 2623478, Parent (null)
Creating GraphicsContext.
    Device context: -1107227101
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 2689014, Parent (null)
Creating GraphicsContext.
    Device context: 738266625
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 2754550, Parent (null)
Creating GraphicsContext.
    Device context: -1107227101
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 2820086, Parent (null)
Creating GraphicsContext.
    Device context: -1929310682
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 2885622, Parent (null)
Creating GraphicsContext.
    Device context: -1056895444
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 2951158, Parent (null)
Creating GraphicsContext.
    Device context: -822014462
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 3016694, Parent (null)
Creating GraphicsContext.
    Device context: -1056895444
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 3082230, Parent (null)
Creating GraphicsContext.
    Device context: -1929310682
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 3147766, Parent (null)
Creating GraphicsContext.
    Device context: 1661011461
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 3213302, Parent (null)
Creating GraphicsContext.
    Device context: -1929310682
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 3278838, Parent (null)
Creating GraphicsContext.
    Device context: -1056895444
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 3344374, Parent (null)
Creating GraphicsContext.
    Device context: -1107227101
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 3409910, Parent (null)
Creating GraphicsContext.
    Device context: -620687852
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 3475446, Parent (null)
Creating GraphicsContext.
    Device context: -822014462
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 3540982, Parent (null)
Creating GraphicsContext.
    Device context: -1056895444
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 3606518, Parent (null)
Creating GraphicsContext.
    Device context: -1107227101
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 3672054, Parent (null)
Creating GraphicsContext.
    Device context: 1661011461
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 3737590, Parent (null)
Creating GraphicsContext.
    Device context: -1107227101
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 3803126, Parent (null)
Creating GraphicsContext.
    Device context: 738266625
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 3868662, Parent (null)
Creating GraphicsContext.
    Device context: -822014462
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 3934198, Parent (null)
Creating GraphicsContext.
    Device context: 738266625
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 3999734, Parent (null)
Creating GraphicsContext.
    Device context: -1929310682
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 4065270, Parent (null)
Creating GraphicsContext.
    Device context: -1056895444
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 4130806, Parent (null)
Creating GraphicsContext.
    Device context: 738266625
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 4196342, Parent (null)
Creating GraphicsContext.
    Device context: -1107227101
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 4261878, Parent (null)
Creating GraphicsContext.
    Device context: -1929310682
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 4327414, Parent (null)
Creating GraphicsContext.
    Device context: -1929310682
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 4392950, Parent (null)
Creating GraphicsContext.
    Device context: -1056895444
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 4458486, Parent (null)
Creating GraphicsContext.
    Device context: -1929310682
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 4524022, Parent (null)
Creating GraphicsContext.
    Device context: 1661011461
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 4589558, Parent (null)
Creating GraphicsContext.
    Device context: -620687852
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 4655094, Parent (null)
Creating GraphicsContext.
    Device context: 1661011461
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 4720630, Parent (null)
Creating GraphicsContext.
    Device context: -620687852
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 4786166, Parent (null)
Creating GraphicsContext.
    Device context: -822014462
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 4851702, Parent (null)
Creating GraphicsContext.
    Device context: -620687852
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 4917238, Parent (null)
Creating GraphicsContext.
    Device context: -822014462
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 4982774, Parent (null)
Creating GraphicsContext.
    Device context: 1661011461
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 5048310, Parent (null)
Creating GraphicsContext.
    Device context: -1929310682
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 5113846, Parent (null)
Creating GraphicsContext.
    Device context: 738266625
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 5179382, Parent (null)
Creating GraphicsContext.
    Device context: 1661011461
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 5244918, Parent (null)
Creating GraphicsContext.
    Device context: -620687852
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 5310454, Parent (null)
Creating GraphicsContext.
    Device context: 1661011461
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 5375990, Parent (null)
Creating GraphicsContext.
    Device context: -1929310682
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 5441526, Parent (null)
Creating GraphicsContext.
    Device context: -620687852
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 5507062, Parent (null)
Creating GraphicsContext.
    Device context: -1056895444
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 5572598, Parent (null)
Creating GraphicsContext.
    Device context: -1929310682
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 5638134, Parent (null)
Creating GraphicsContext.
    Device context: -620687852
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 5703670, Parent (null)
Creating GraphicsContext.
    Device context: -822014462
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 5769206, Parent (null)
Creating GraphicsContext.
    Device context: 738266625
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 5834742, Parent (null)
Creating GraphicsContext.
    Device context: 738266625
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 5900278, Parent (null)
Creating GraphicsContext.
    Device context: -1056895444
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 5965814, Parent (null)
Creating GraphicsContext.
    Device context: 1661011461
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 6031350, Parent (null)
Creating GraphicsContext.
    Device context: -1107227101
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 6096886, Parent (null)
Creating GraphicsContext.
    Device context: -1929310682
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 6162422, Parent (null)
Creating GraphicsContext.
    Device context: 738266625
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 6227958, Parent (null)
Creating GraphicsContext.
    Device context: -1056895444
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 6293494, Parent (null)
Creating GraphicsContext.
    Device context: -620687852
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 6359030, Parent (null)
Creating GraphicsContext.
    Device context: -620687852
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 7276548, Parent (null)
Creating GraphicsContext.
    Creating GraphicsContext.
        Device context: -1929310682
        Selecting pixel format... A first chance exception of type 'System.AccessViolationException' occurred in OpenTK.dll
Destroying window: Windows.WindowInfo: Handle 330024, Parent (null)
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at OpenTK.Platform.Windows.Functions.ChoosePixelFormat(IntPtr dc, PixelFormatDescriptor& pfd)
   at OpenTK.Platform.Windows.WinGraphicsMode.SelectGraphicsModePFD(ColorFormat color, Int32 depth, Int32 stencil, Int32 samples, ColorFormat accum, Int32 buffers, Boolean stereo) in D:\projects\OpenTK\Source\OpenTK\Platform\Windows\WinGraphicsMode.cs:line 128
   at OpenTK.Platform.Windows.WinGraphicsMode.SelectGraphicsMode(ColorFormat color, Int32 depth, Int32 stencil, Int32 samples, ColorFormat accum, Int32 buffers, Boolean stereo) in D:\projects\OpenTK\Source\OpenTK\Platform\Windows\WinGraphicsMode.cs:line 78
   at OpenTK.Graphics.GraphicsMode.get_Index() in D:\projects\OpenTK\Source\OpenTK\Graphics\GraphicsMode.cs:line 186
   at OpenTK.Graphics.GraphicsMode.ToString() in D:\projects\OpenTK\Source\OpenTK\Graphics\GraphicsMode.cs:line 329
   at System.Text.StringBuilder.AppendFormat(IFormatProvider provider, String format, Object[] args)
   at System.String.Format(IFormatProvider provider, String format, Object[] args)
   at System.Diagnostics.Debug.Print(String format, Object[] args)
   at OpenTK.Graphics.GraphicsContext..ctor(GraphicsMode mode, IWindowInfo window, Int32 major, Int32 minor, GraphicsContextFlags flags) in D:\projects\OpenTK\Source\OpenTK\Graphics\GraphicsContext.cs:line 94
   at OpenTK.Platform.Windows.WinGraphicsMode.SelectGraphicsModeARB(ColorFormat color, Int32 depth, Int32 stencil, Int32 samples, ColorFormat accum, Int32 buffers, Boolean stereo) in D:\projects\OpenTK\Source\OpenTK\Platform\Windows\WinGraphicsMode.cs:line 158
   at OpenTK.Platform.Windows.WinGraphicsMode.SelectGraphicsMode(ColorFormat color, Int32 depth, Int32 stencil, Int32 samples, ColorFormat accum, Int32 buffers, Boolean stereo) in D:\projects\OpenTK\Source\OpenTK\Platform\Windows\WinGraphicsMode.cs:line 70
   at OpenTK.Graphics.GraphicsMode.get_Index() in D:\projects\OpenTK\Source\OpenTK\Graphics\GraphicsMode.cs:line 186
   at OpenTK.Graphics.GraphicsMode.ToString() in D:\projects\OpenTK\Source\OpenTK\Graphics\GraphicsMode.cs:line 329
   at System.Text.StringBuilder.AppendFormat(IFormatProvider provider, String format, Object[] args)
   at System.String.Format(IFormatProvider provider, String format, Object[] args)
   at System.Diagnostics.Debug.Print(String format, Object[] args)
   at OpenTK.Graphics.GraphicsContext..ctor(GraphicsMode mode, IWindowInfo window, Int32 major, Int32 minor, GraphicsContextFlags flags) in D:\projects\OpenTK\Source\OpenTK\Graphics\GraphicsContext.cs:line 94
   at OpenTK.GameWindow..ctor(Int32 width, Int32 height, GraphicsMode mode, String title, GameWindowFlags options, DisplayDevice device, Int32 major, Int32 minor, GraphicsContextFlags flags, IGraphicsContext sharedContext) in D:\projects\OpenTK\Source\OpenTK\GameWindow.cs:line 206
Destroying window: Windows.WindowInfo: Handle 591912, Parent (null)
A first chance exception of type 'System.AccessViolationException' occurred in OpenTK.dll
Creating GraphicsContext.
    Device context: -620687852
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 657448, Parent (null)
Creating GraphicsContext.
    Device context: -620687852
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 722984, Parent (null)
Creating GraphicsContext.
    Device context: 738266625
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 788520, Parent (null)
Creating GraphicsContext.
    Device context: -620687852
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 854056, Parent (null)
Creating GraphicsContext.
    Device context: 738266625
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 919592, Parent (null)
Creating GraphicsContext.
    Device context: -822014462
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 984174, Parent (null)
Creating GraphicsContext.
    Device context: -822014462
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 1049710, Parent (null)
Creating GraphicsContext.
    Device context: -1107227101
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 1115246, Parent (null)
Creating GraphicsContext.
    Device context: -822014462
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 1180782, Parent (null)
Creating GraphicsContext.
    Device context: -1107227101
    Selecting pixel format... Destroying window: Windows.WindowInfo: Handle 1246318, Parent (null)
hack2root's picture

for ATI drivers, install

ATI Open Stream SDK for support of OpenCL due that it is no more shipped with new drivers, as written here and here

There are reference to NVIDIA software as well.

Opfer's picture

I've got the same issue. It goes away when changing the platform in Visual Studio from "Any CPU" to "x86". Installing the ATI Open Stream SDK did not help.

Windows 7 Professional (x64)
ATI Radeon HD 5870 (Catalyst 10.3)
OpenTK 1.0 RC1

the Fiddler's picture

I'm looking into this.

hack2root's picture

Oh, I see. I forgot that I was a Windows hacker ;) Yeah, now i understand, what's wrong,

While loading JIT compiler (this is unavoidable by design of .NET framework untill assembly image is not linked as native x64\x86 image), it compiles assemby on the fly as x64 images on 64bit system (Windows7) and tries to load x86 process context into x64 process context which leads to memory corruptions because 64 bit pointers are twice as big as 32 bit pointers, so some memory adressing exceptions occurs on a calee becuse of 64 bit caller's pointers.

Steps to complie QuickStart.sln (Windows7, Visual Studio)

1. Remove links in project to OpenTK.dll, using Solution Explorer for the project itself and project's Project References
2 .Add OpenTK project to solution. Add references to that project in any project you will use.
3. Add x86 solution configuration.

Using Confiiguration Manager, add new soultion configuration (x86) from existing configuration (AnyCPU).
Rebuild soultion and everything will be done automatically, you will able to debug your projects.

Cheers!

hack2root's picture

Speakin about error in the topic, I discovered that nothing is wrong with OpenTK.Platform.Windows.Functions.ChoosePixelFormat(IntPtr dc, PixelFormatDescriptor& pfd)
function.

It is the first call of externally mapped dll function, so i expected managed AccessViolationException, and i got it well.

The reason i metioned previosly is that x64 versions on native dll's for system /dll's and OpenAL/GL/CL dll's are still missing by the assembly you are running, you need to rebuild them as well first for you hardware and software configuration.

the Fiddler's picture

OpenTK is x64-aware, which it is (or should be) safe to run as AnyCPU. System dlls (like opengl32.dll, gdi32.dll etc) come in both x86 and x64 flavors and the correct one is resolved by the OS.

I'm trying to reproduce the issue in order to understand what is going wrong. So far everything seems to be running fine on both my Nvidia and Ati systems.

blodbath's picture

I have no issues with my Nvidia system here at work, it runs like a charm. When I brought the project home it worked great for a couple days. I upgraded my drivers and it started doing this. I should have more time tonight to dive into this and see if I can get any more information out of it.