rakkarage's picture

build.exe and vs2010 and exception

in beta2 vs2010... when i use build.exe to generate project files... if i choose vs then convert the project builds... if i choose vs9 then convert i get two errors

Error 44 Could not load referenced assembly "D:\projects\OpenTK\Binaries\OpenTK\Debug\OpenTK.dll". Caught a BadImageFormatException saying "Could not load file or assembly 'D:\projects\OpenTK\Binaries\OpenTK\Debug\OpenTK.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.". D:\projects\OpenTK\Source\Compatibility\ResGen OpenTK.Compatibility

Error 45 Could not load referenced assembly "D:\projects\OpenTK\Binaries\OpenTK\Debug\OpenTK.dll". Caught a BadImageFormatException saying "Could not load file or assembly 'D:\projects\OpenTK\Binaries\OpenTK\Debug\OpenTK.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.". D:\projects\OpenTK\Source\Examples\ResGen OpenTK.Examples

also even when i use vs now i get an exception when running QuickStart in GameWindow constructor... GraphicsContext.available_contexts.Values is empty? is that normal? it passes a null shareContext into CreateGLContext?

thanks


Comments

Comment viewing options

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

VS2010 beta 1 used to work correctly. I don't have beta 2 installed, so I can't test myself - are you building OpenTK for .Net 2.0 or 4.0? (It should work in both cases, but it's been only tested on .Net 2.0).

A null shareContext is normal if you are only creating a single GraphicsContext (this is the most common case). Can you please post the exact error message and stacktrace for the exception?

rakkarage's picture

System.AccessViolationException was unhandled
Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Source=OpenTK
StackTrace:
at OpenTK.Platform.Windows.Wgl.Arb.CreateContextAttribs(IntPtr hDC, IntPtr hShareContext, Int32[] attribList) in D:\projects\OpenTK\Source\OpenTK\Platform\Windows\Bindings\Wgl.cs:line 551
at OpenTK.Platform.Windows.WinGLContext..ctor(GraphicsMode format, WinWindowInfo window, IGraphicsContext sharedContext, Int32 major, Int32 minor, GraphicsContextFlags flags) in D:\projects\OpenTK\Source\OpenTK\Platform\Windows\WinGLContext.cs:line 96
at OpenTK.Platform.Windows.WinFactory.CreateGLContext(GraphicsMode mode, IWindowInfo window, IGraphicsContext shareContext, Boolean directRendering, Int32 major, Int32 minor, GraphicsContextFlags flags) in D:\projects\OpenTK\Source\OpenTK\Platform\Windows\WinFactory.cs:line 53
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 122
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 185
at OpenTK.Graphics.GraphicsMode.ToString() in D:\projects\OpenTK\Source\OpenTK\Graphics\GraphicsMode.cs:line 326
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 97
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 218
at OpenTK.GameWindow..ctor(Int32 width, Int32 height, GraphicsMode mode, String title, GameWindowFlags options, DisplayDevice device, Int32 major, Int32 minor, GraphicsContextFlags flags) in D:\projects\OpenTK\Source\OpenTK\GameWindow.cs:line 178
at OpenTK.GameWindow..ctor(Int32 width, Int32 height, GraphicsMode mode, String title, GameWindowFlags options, DisplayDevice device) in D:\projects\OpenTK\Source\OpenTK\GameWindow.cs:line 160
at OpenTK.GameWindow..ctor(Int32 width, Int32 height, GraphicsMode mode, String title) in D:\projects\OpenTK\Source\OpenTK\GameWindow.cs:line 133
at RageWorld.Game..ctor() in D:\projects\RageWorld\Game.cs:line 22
at RageWorld.Game.Main() in D:\projects\RageWorld\Game.cs:line 108
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:

but only happens sometimes? idk

the Fiddler's picture

Are you using a nvidia graphics card? There used to be an AccessViolationException issue that only appeared on nvidia cards (never seen it on Ati/Intel/Mesa), for which I never found the cause. The issue more or less disappeared a few months ago - but it seems to have resurfaced now.

It's quite strange: everything seems to be working correctly, no detectable errors then suddenly it crashes. This usually happens during mode selection or context construction - but only on nvidia cards. Stack corruption? Maybe, but I've triple-checked the WGL/GDI bindings and they look correct.

Is this x86 or amd64? Vista, I guess?

rakkarage's picture

ya nvidia x86 win7 (another beta?)... i just assumed it was vs2010 beta

aberghage's picture

I can confirm the BadImageFormatException error building the compatibility and examples projects in VS2010 Beta 2 (WinXP SP3 x86).

Also, on a (maybe) related note, I can't edit project properties for anything in OpenTK, or build OpenTK.GLControl or OpenTK.Build. Visual Studio complains about not being able to find the .NET 2.0 SDK. This is an interesting error, since I have the 3.5 SDK (which correctly prevents the 2.0 SDK from installing), the Win7 SDK, and the .NET 4 SDK (thanks to vs2010) installed. I'll poke in to this some more as time allows (VS2008 on the other machine still works fine, and I'm not one to pitch a fit when I've still got a working solution :-P).

the Fiddler's picture

For some strange reason, Microsoft decided to change the default build targets in VS2010 from AnyCPU to x86. Double check that all projects are using the same CPU target (OpenTK is AnyCPU by default), otherwise you'll get BadImageFormatExceptions.

Since VS2010 beta 1 could build OpenTK just fine, I am going to write off the other issue as a beta 2 bug. Let's wait until VS2010 hits RC status and see how it works then.

aberghage's picture

Confirmed, fixing the build targets solved the BadImageFormatExceptions. With that fixed, beta 2 is building everything just fine for me.

As an aside, I did track down at least part of the SDK path issue I ran in to: Manually setting the registry key HKLM/SOFTWARE/Microsoft/.NET Framework/SDKInstallRootv2.0 to the path to your framework (or in my case windows) SDK seems to solve it. For whatever reason the VS2010 beta and the windows SDK installer don't set this value (or didn't in my case, googling seems to suggest the SDK installer sets it if you install visual studio before the SDK-- I have no idea which I did first, it was a little while ago).