Download Attachment: [url="http://www.vbgamer.com/msgboard/uploaded/cbx/20041228194939_WindowsApplication1.zip"][img]icon_paperclip.gif[/img]WindowsApplication1.zip[/url]<br>57.98KB">
Need help: InvalidCallException in D3D9 Managed!
cbxOK something strange going on here, and was wondering if anyone else was having the same issues. I am using vb.net and DX9 Managed. I was playing around with ways to simplify directx down to an aboslute minimum. What I did was create a class library. And added a bunch of modules and in those modules I added some publicly availible methods such as InitGraphics, ShutdownGraphics, EnableLighting etc etc. Now all of the varibles like the D3D Device, and present parameters etc are module level varibles that are not visible to outside apps. They are declared friend so only the Class library can see them. Although I do provide methods for accessing those varibles indirectly through some methods, GetD3DDevice for example is one of those methods. But it seems when I create an application that references this class library and calls the initgraphics method but then tries to get the value of a render state on that device like so ... [code] InitGraphics(Me, True) ' True means windoed mode msgbox(GetD3DDevice.RenderState.Lighting) ' get the Lighting renderstate property and show it [/code] I keep getting a InvalidCallException being thrown when I try to retrieve the Lighting render state!?! I get this exception when I try to access any of the render state properties. I don't get this error when I call the EnableLighting method but I do get a InvalidCallException being thrown when I try to retrieve the value of one of the render state properties on this device! Now here is the thing. i have also tried converting the modules in the class library into classes so that my application has to create an object in order to work with the methods. but I still get the same exception being thrown! What's up with that? You wanna know what the really odd thing is. I have never ever had an InvalidCallException thrown before until of cource I installed the new DirectX sdk Devember 2004 a few days ago! This is what I suspect is causing me my problems. Any thoughts on this? VB.NET 2002 Test code Download Attachment: [url="http://www.vbgamer.com/msgboard/uploaded/cbx/2004122819501_dx9mtester.zip"][img]icon_paperclip.gif[/img]dx9mtester.zip[/url]<br>38.07KB VB.NET 2005 aka VBExpress 2005 beta 1 test code Download Attachment: [url="http://www.vbgamer.com/msgboard/uploaded/cbx/20041228194939_WindowsApplication1.zip"][img]icon_paperclip.gif[/img]WindowsApplication1.zip[/url]<br>57.98KB
cbxBTW I have also tested the fallowing code and it works just fine and as you would expect it to. [code]Public Class Form1 Dim GFX As Direct3D.Device Private Sub Form1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Click MsgBox(GFX.RenderState.Lighting) End Sub Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed GFX.Dispose() GFX = Nothing End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.Show() Dim PP As New Direct3D.PresentParameters PP.SwapEffect = Direct3D.SwapEffect.Discard PP.AutoDepthStencilFormat = Direct3D.DepthFormat.D16 PP.EnableAutoDepthStencil = True PP.Windowed = True GFX = New Direct3D.Device(0, Direct3D.DeviceType.Hardware, Me, Direct3D.CreateFlags.SoftwareVertexProcessing, pp) End Sub Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint GFX.Clear(Direct3D.ClearFlags.Target Or Direct3D.ClearFlags.ZBuffer, Color.Black, 1, 0) GFX.BeginScene() ' draw scene here GFX.EndScene() GFX.Present() End Sub End Class[/code]
Lachlan87One thing you should know. . . the .NET way of doing msgbox is: [code]MessageBox.Show(Blah,blah,blah)[/code] My next thought would be to ask if your passing the renderstate byVal, or byRef. Maybe I'll think of something else later, too. Lachlan
Lachlan87Here's what you didn't want to be told. . . I downloaded your code and it works fine on my computer. I guess you know what that means. (I only have the summer update)
Eric ColemanThis is unrelated to your problem, but when I start VS 2002 I have the green X in the splash page to show that I have the directX sdk installed. However, I can't load your project file. It says I'm missing Managed.DirectX.dll. However, I have 3 of them, or at least 3 directories under Microsoft.Net/Managed DirectX/. 9.00.0900, 9.00.1126, and 9.02.3900. I have the October 2004 Update installed. However, I can't create any type of directx project. Even the VS directx wizard fails by saying that I'm missing that dll.
Lachlan87Yeah, it's a common problem with 2002. Add the references yourself---to both of the projects in the solution. If your like me though, VB 2002 won't like the version of the DX dll's he uses though. It'll tell you something about it not liking the version of .NET runtimes the DX dll's use. I had to open his solution with VB.NET 2003 to get it to work. VB.NET 2002 has problems, that's for sure.
Eric ColemanOk, I got the program to compile when using the files in the 9.02.3900 folder. The test program works as well (except when I resize it too large I get an out of video memory error, LOL)
cbx
quote:
Originally posted by Lachlan87 <br>Here's what you didn't want to be told. . . I downloaded your code and it works fine on my computer. I guess you know what that means. (I only have the summer update)
As I suspected. [:(!] Has anyone else got it working who does not have December 2004 installed? As for eric not being able to reference the DirectX dll's you can find the files under the C:\WINDOWS\Microsoft.NET\Managed DirectX\v9.02.3900 folder. The problem with vs.net is that it will only list asselblies that are the same version it uses or lower. For example in VS.net 2003 when you add a reference it will only populate the availible references list with assemblies compiled for .NET framework 1.0 and 1.1 But vs.net 2002 will only populate the availible references list with assemblies compiled only for .NET framework 1.0. With VBExpress 2005 beta 1 all 1.0, 1.1, and 2.0 assemblies can are visible in the list. Unfortunatly it appears if the December 2004 dx release is causing my problems I will have to wait until the next dx release in Feburary to see if that update will fix my problem.
Eric Coleman
quote:
Originally posted by cbx
As I suspected. [:(!] Has anyone else got it working who does not have December 2004 installed?
Read my previous post [:D] I got the program to compile and run with the Oct 2004 release. I'll download the December 2004 update to see if that causes any problems for me.
cbxAlrighty then, Just finished doing some testing and sure enough I'm convinced that it was the December 2004 instalation of directx that is causing me problems. I changed the references for the vb.net 2002 and vb.net 2005 projects to use the dx assemblies in the v1.0.900.0 folder and presto it wored fine. So then I removed those dx references and added references to the dx files under the v9.03.91 folder IE the December 2004 release and crash boom bam a InvalidCallException exception is thrown! Using the v9.02.3900 assemblies also causes InvalidCallException to be thrown. Heck i have even tried switching between retail and debug version of the managed assemblies but still keep getting the same InvalidCallException exception. So how many stike outs is that now? 3, 4 maybe. The first release of managed directx that was made availible had unfinished documentation. The next release had that byref byval DrawText bug. Not to mention it did not install any previous versions of managed directx assemblies. And now it seems the December 2004 release goes a step further by throwing InvalidCallException exceptions all over the place! Ladies and gentlemen if the upcomming feburary release does not go smoothly... Tom Miller is gonna get some serious spam flooding from me demanding what the hell is going on over there in redmond.