Cant seem to get past this exception

Jul 7, 2010 at 10:03 PM
at System.ComponentModel.Composition.CompositionResult.ThrowOnErrors(AtomicComposition atomicComposition) at System.ComponentModel.Composition.Hosting.ComposablePartExportProvider.Compose(CompositionBatch batch) at System.ComponentModel.Composition.Hosting.CompositionContainer.Compose(CompositionBatch batch) at System.ComponentModel.Composition.AttributedModelServices.ComposeParts(CompositionContainer container, Object[] attributedParts) at Balder.Core.RuntimeImports..ctor() at Balder.Core.Runtime.get_Instance() at Balder.Core.Node.NodeLoaded(Object sender, RoutedEventArgs e) at MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args) at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName) Code is based off the programatic teapot example with the teapot replaced by my own object, and the exception occurs directly after App:ApplicationStartup, before any of the override methods in my game class are called To be more specific: I subclassed Game, dropped an instance of the subclassed object on the grid of my user control, copied the code out of the sample, and replaced the teapot with my custom object (an icosahedron based on the Geometry class)
Jul 7, 2010 at 10:04 PM
GRRRR what is it with formatting on this site ?? doesnt codeplex know what a linebreak is ??
Jul 8, 2010 at 5:20 AM
Edited Jul 8, 2010 at 5:21 AM

I'll be releasing a new version today or tomorrow -, which doesn't use MEF, which is causing the problem. 

If you want, you can already download it from here :


Codeplex formatting is random, at best. Sometimes it works, sometimes not.  Can't figure out why. I feel your pain! 


Jul 8, 2010 at 5:50 AM
What happened to IGeometyContext ?? no vertex for face methods/members !!!! Is there an IRC channel or some other way I can get some realtime help with this ??
Jul 8, 2010 at 6:25 AM

IGeometryContext has something called IGeometryDetailLevel which holds all of this now. Also, on a geometry there is now a property called FullDetailLevel, which is a convenience property for getting the full detail level, which is the default (in fact for now, the only) detail level of a any Geometry.

Sorry, no IRC channel - but Twitter works : - close to realtime. 

Jul 8, 2010 at 7:04 AM

ok -- you made me do it -- I'm on twitter -- couldnt figure out how to send you a message though, so we'll do it here :)

I'm catching a null exception trying to instance Game, it seems to have missed the platform type somehow

   at System.Activator.CreateInstance(Type type, Boolean nonPublic)
   at System.Activator.CreateInstance(Type type)
   at Balder.Core.Execution.PlatformKernel..ctor(Type platformType)
   at Balder.Core.Execution.Runtime.GetRuntime()
   at Balder.Core.Execution.Runtime.get_Instance()
   at Balder.Core.Execution.Game..ctor()


Jul 8, 2010 at 7:23 AM

Are adding a reference to the Balder.Silverlight.dll file? Seems like its not finding the Silverlight platform implementation.

Jul 8, 2010 at 7:26 AM

Got Core, Silverlight, and Ninject... thats it

are you seeing any of the tweets I'm doing in reply to yours ??

Jul 8, 2010 at 7:30 AM

Not seeing your replies on Twitter. 

Could you email me your project and I'll see what I can do.

einar [at] dolittle [dot] com

Jul 8, 2010 at 7:33 AM

ok -- I had all 3 on the user control hosting balder, but none of them on the main app, so it wasnt copying the silverlight dll

got a display -- just not what I was expecting from the code -- now to debug my geometry generator

THANKS !! :)

Jul 8, 2010 at 7:36 AM

:)    Its really annoying that Visual Studio doesn't just do that. Good to hear you got it working. 

Hope you'll find whats going on with the code and that I haven't broken everything for you with the new version.

Ping me if there are things you need assistance on.

Jul 8, 2010 at 8:17 AM

my solution is far to large to email :) Client, Server, 2 map editors, Database and Support code :) and getting bigger every day :)

I'm debuging my code to generate an icosahedron and subdivide it (currently just testing the base icosahedron, no subdividing)

I've set up 7 materials to distribute among the triangles, but they are all showing up orangish in color (those that show up at all -- must have the vertex order wrong on a few triangles)

I'm setting the ambient diffuse and specular colors all the same, using flat shading. Setting the same color on the triangle itself;

Not setting vertex colors at all -- so that will be the default.


Ideas ??

Jul 8, 2010 at 8:31 AM

Do you have a light? 

There is a known bug with coloring and lighting that I'll be working on, its adding colors today - instead of multiplying with the lightsource. Just as you know, I guess this has nothing to do with it.

You could also on the material set it to be twosided, that way you'll at least see all the triangles.


Do you have shading set for the materials btw. ?   There is a property called Shade on it.


Jul 8, 2010 at 8:51 AM

Shade is set to Wireframe, but I get the same results with Flat or Gouraud.

I got the triangles fixed up -- all the faces are showing without setting 2-sided on the mat. (vertex order is gonna be important later on for texturing the tiles. so I need to start off with the right vertex order)

            var light = new OmniLight();
            light.Diffuse = Color.FromArgb(0xff, 255, 121, 32);
            light.Specular = Color.FromArgb(0xff, 0xff, 0xff, 0xff);
            light.Ambient = Color.FromArgb(0xff, 0x7f, 0x3f, 0x10);

I think, guessing off hand from those color values, that all I'm getting is color from the light... there is no variation to indicate its adding with the material colors at all

Jul 8, 2010 at 9:16 AM

Its 4am here -- I'll pick it up again tomorrow -- have a good night and thanks for all the help getting me this far :)

Jul 8, 2010 at 9:35 AM

No problem. Have a good night sleep. Its only 11:30 AM here, so I got a full day ahead of me.. 

Jul 8, 2010 at 3:16 PM

I'm back -- any ideas how to get some color on those faces so I can verify the mesh ?? or do I just have to texture the faces ??

You said something about texturing using materials, but I didnt see anything in the material class about a texture, just the masks for difuse/reflection/opacity.

It looks like if I wanted to create my texture swatches programatically, I would have to convert the pixel array used by the writeablebitmap (array of int in ARGB order) into an array of bytes with RGBA ordering, then use image.imagecontext.setframe to get it into a balder image. Does that sound right ??

Jul 8, 2010 at 3:49 PM

God morning. :)

You could just have a material without a texture and just set the Diffuse property to a color of choice.

Jul 8, 2010 at 4:46 PM

hmmmm code does that and I'm not getting any variation in the color of the faces. In fact I'm setting every possible color value I've found :) Colors in the material, on the verticies, and on the faces.

Can you confirm for me the byte order expected by ImageContext.SetFrame ?? (I'm coding up an extention method Image.FromWriteableBitmap and would like to get the byte ordering right the 1st time)


here is the code that sets up all the materials and colors

            Color[] colors = new Color[]

            Material[] Mats = new Material[colors.Length];
            for (int i=0; i<colors.Length; i++)
                Material mat = new Material();
                mat.Ambient = Balder.Core.Color.FromSystemColor(colors[i]);
                mat.Diffuse = mat.Ambient;
                //mat.Specular = mat.Ambient;
                mat.Shade = MaterialShade.Gouraud;
                mat.Shine = 0.5f;
                mat.ShineStrength = 0.5f;
                Mats[i] = mat;


            for (int i = 0; i < icos.Vertices.Count; i++)
                context.SetVertex(i, icos.Vertices[i]);
                icos.Vertices[i].Color = Balder.Core.Color.FromSystemColor(colors[i % Mats.Length]);

            for (int i = 0; i < icos.Triangles.Count; i++)
                Face tri = icos.Triangles[i];
                context.SetFace(i, tri);
                tri.Material = Mats[i % Mats.Length];
                tri.Color = tri.Material.Ambient;
                tri.DiffuseA = tri.A;
                tri.DiffuseB = tri.B;
                tri.DiffuseC = tri.C;


Jul 8, 2010 at 9:04 PM

This just seems so weird.  What if you don't set any colors or any Materials and just have a light source there. Does it get a color and is it affected by the light?

Anyways, from my initialization of the BufferContainer, deep in the bowls of the engine (Byte positions)

BufferContainer.RedPosition = 2;

BufferContainer.GreenPosition = 0;

BufferContainer.BluePosition = 1;

BufferContainer.AlphaPosition = 3;



Jul 8, 2010 at 9:22 PM

no change from previous versions... I removed the vertex colors, face colors, and materials

I tried applying texure using the DiffuseMap and got nothing there either !! (is that the right way to apply a texture using a material ??)


Jul 8, 2010 at 9:36 PM

just did some additional tests -- its only working from the ambient and specular colors of the light source that I can tell

Jul 9, 2010 at 4:54 AM

Any updates ?? is this material/texture issue a real bug or a problem on my end ?? Anything you would like me to try to narrow down the problem ??

On another track -- I tried to create an image and assign data from a WriteableBitmap, but the image had no ImageContext (void constructor used). How can I attach an ImageContext to the image ??

Jul 9, 2010 at 5:39 AM

Hard to say if this is a bug in Balder or not. 

Are you by any chance setting the Material property of the Geometry itself at some point? There might be an initialization issue that causes the materials on each face to be overridden somehow. 
Would it be possible to schedule a remote help using TeamViewer + Skype? Then I could see for myself in your code?  

Jul 9, 2010 at 5:49 AM

Nope -- never touch the material for the geometry object -- though I will try it just to see if something different happens -- and it DOES  -- showing a very nice purple icosahedron with white edges (the texture is a colored triangle with white edges) -- all my faces are now textured with the selected material (even though the code later on still overrides the material on a per face basis, its using the global material for the object)

I was gonna pull out the 2 projects that make up the test app and send them -- but I have skype and can install teamviewer if you would rather do it that way.

Jul 9, 2010 at 6:00 AM

Tearmviewer is installed (even though I hate the fool thing passionatly !!)

My skype name is trancus2

Jul 9, 2010 at 7:14 AM

I've got you added to Skype, but I guess you're sound asleep - sorry I didn't see the message until now. I was busy doing something else. 

Thing is that the pipeline of Balder works in mysterious ways sometimes. And even though you're setting the Material property for the object at an earlier stage, it will override whatever you're setting after on a per face level. The reason for this has to do with the initialization process of Balder, which is hard to get right in Silverlight. And there is no way to keep track of what you're doing to the Faces individually - that would seriously impact performance. Is there any way you can get it to not have a Material? 

Jul 9, 2010 at 7:33 AM

RESOLVED !!! Because of the way Balder creates the platform specific version of a face (from the generic face that you fill in when constructing a programatic geometry), you must make the call to IGeometryDetailLevel.SetFace LAST -- after setting up all the face properties. If you wish to make changes to a current face, Call IGeometryDetailLevel.GetFace, which returns the platform specific version of the face, make your changes, then call IGeometryDetailLevel.InvalidateFace