Sign in to follow this  
Override

[MDX] Effect.FromFile problem

Recommended Posts

I seem to have a strange problem with the following code:
 Effect effect;

        public MeshMaterial(Device device, string filename)
        {
            try
            {
                effect = Effect.FromFile(device, filename, null, null, ShaderFlags.None, null);
            }
            catch (Exception)
            {
                System.Windows.Forms.MessageBox.Show("caught exception");
            }
        }

If I use the correct device and the correct filename, the function works and the program exits with no memory leaks. If I use the correct device but an incorrect filename, I get the exception and when I exit the program there is a memory leak. If I use a null device and incorrect filename I get the exception and the program exits with no memory leaks. I can't figure out why Effect.FromFile appears to be causing a memory leak if it fails. Anyone have any explanations?

Share this post


Link to post
Share on other sites
I can only offer a guess, but you could use the reflector tool to check out the source code of the MDX assemblies for more information. Anyway, MDX obviously seems to allocate some resource(s) for the effect, even before it's actually loaded.

This would explain why there is no memory leak with an invalid device, since it just cannot allocate those resources. Additionally, the error you get from loading an effect from an invalid source should tell you the effect is invalid IIRC. So somehow it seems to be trying to compile the effect, no matter whether if it could actually be loaded or not.

As for how or why this is, I honestly wouldn't know [smile]

Share this post


Link to post
Share on other sites
Thanks for the advice, the reflector tool is not something I have ever used before. Maybe I should take a look though.

Anyway I managed to sort it out by uninstalling the February06 SDK and installing the April SDK. There is now a first chance exception of Microsoft.DirectX.Direct3D.InvalidDataException that happens. I don't think it happened before, but I could be wrong because I wasn't looking for it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this