# Thursday, June 09, 2005

   Diagnosys: In the background, ngraphviz generates a temporary dot file for each graph that gets rendered and shreds it afterwards. If you are running Ngraphviz from a folder that does not have write support, you get something like the exception below.

   Workaround: Do not run reflector from a share!

Access to the path "\\xxxxxxxx\a26d8897-1b11-4f40-8d50-301cc6503ba2.dot" is denied.

System.UnauthorizedAccessException

  at System.IO.__Error.WinIOError(Int32 errorCode, String str)
  at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share,
Int32 bufferSize, Boolean useAsync, String msgPath, Boolean bFromProxy)
  at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share,
Int32 bufferSize)
  at System.IO.StreamWriter.CreateFile(String path, Boolean append)
  at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize)
  at System.IO.StreamWriter..ctor(String path)
  at NGraphviz.Helpers.Dot.Run(GraphvizImageType imageType, String dotCode, String outputFileName)
  at QuickGraph.Algorithms.Graphviz.GraphvizAlgorithm.Write(String outputFileName)
  at Reflector.Graph.Graphs.InstructionGraphRenderer.Render(String fileName)
  at Reflector.Graph.IlGraphControl.Translate()
  at Reflector.Framework.InternetExplorerControl.OnParentChanged(EventArgs e)
  at System.Windows.Forms.Control.AssignParent(Control value)
  at System.Windows.Forms.ControlCollection.Add(Control value)
  at _134._1(IWindow )
  at _121._1(String )
  at _4.set_Visible(Boolean value)
  at Reflector.Framework.PackageBase.commandBar_Click(Object sender, EventArgs args)
  at _78.OnClick(EventArgs e)
  at _78.PerformClick()
  at _1.OnClick(EventArgs e)
  at System.Windows.Forms.MenuItemData.Execute()
  at System.Windows.Forms.Command.Invoke()
  at System.Windows.Forms.Control.WmCommand(Message& m)
  at System.Windows.Forms.Control.WndProc(Message& m)
  at System.Windows.Forms.TreeView .WndProc(Message& m)
  at _2.WndProc(Message& message)
  at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
  at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
  at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

 

posted on Thursday, June 09, 2005 9:11:15 AM (Pacific Daylight Time, UTC-07:00)  #    Comments [1]
# Wednesday, June 08, 2005

The SVG viewer and NGraphviz can causes some common failure that are easy to workaround, i.e. I don't plan to fix them soon ;)

1.

 Diagnosys: The first time you run the Adobe SVG viewer, a copyright dialog pops up. After that, you will hit this failure.
 Workaround: Close Reflector and rerun. The dialog is gone and everything works fine.

Object reference not set to an instance of an object.

System.NullReferenceException

  at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
  at System.Windows.Forms.ComponentManager.System.Windows.Forms.UnsafeNativeMethods+
IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
  at System.Windows.Forms.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
  at System.Windows.Forms.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
  at System.Windows.Forms.Application.DoEvents()
  at _121._1(String )
  at _4.set_Visible(Boolean value)
  at Reflector.Framework.PackageBase.commandBar_Click(Object sender, EventArgs args)
  at _78.OnClick(EventArgs e)
  at _78.PerformClick()
  at _1.OnClick(EventArgs e)
  at System.Windows.Forms.MenuItemData.Execute()
  at System.Windows.Forms.Command.Invoke()
  at System.Windows.Forms.Control.WmCommand(Message& m)
  at System.Windows.Forms.Control.WndProc(Message& m)
  at _76.WndProc(Message& message)
  at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
  at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
  at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

2.

    Diagnosys: You don't have the necessary C++ libraries on your machine to run NGraphviz.
    Workaround: make sure msvcp71.dll and msvcr71.dll are available.

The specified module could not be found. (Exception from HRESULT: 0x8007007E)

System.IO.FileNotFoundException

  at NGraphviz.Helpers.Dot.Run(GraphvizImageType imageType, String dotCode, String outputFileName)
  at QuickGraph.Algorithms.Graphviz.GraphvizAlgorithm.Write(String outputFileName)
  at Reflector.Graph.Graphs.StatementGraphRenderer.Render(String fileName)
  at Reflector.Graph.StatementGraphControl.Translate()
  at Reflector.Framework.InternetExplorerControl.OnParentChanged(EventArgs e)
  at System.Windows.Forms.Control.AssignParent(Control value)
  at System.Windows.Forms.Control.ControlCollection.Add(Control value)
  at _134._1(IWindow )
  at _121._1(String )
  at _121._4.set_Visible(Boolean value)
  at Reflector.Framework.PackageBase.commandBar_Click(Object sender, EventArgs args)
  at _78.OnClick(EventArgs e)
  at _78.PerformClick()
  at _83._1.OnClick(EventArgs e)
  at System.Windows.Forms.MenuItem.MenuItemData.Execute()
  at System.Windows.Forms.Command.Invoke()
  at System.Windows.Forms.Command.DispatchID(Int32 id)
  at System.Windows.Forms.Control.WmCommand(Message& m)
  at System.Windows.Forms.Control.WndProc(Message& m)
  at System.Windows.Forms.TreeView.WndProc(Message& m)
  at _2.WndProc(Message& message)
  at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
  at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
  at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
posted on Wednesday, June 08, 2005 12:41:39 PM (Pacific Daylight Time, UTC-07:00)  #    Comments [0]
# Monday, June 06, 2005
Just updated to dasBlog...
posted on Monday, June 06, 2005 4:23:26 AM (Pacific Daylight Time, UTC-07:00)  #    Comments [1]
# Wednesday, May 25, 2005

A while ago, I mentioned I was planning to build an autonomous agent framework on .NET (this was in fact a long time ago). It’s time to wake this project up with a shiny description:

NSteer is a framework for simulating of autonomous agents for .NET.

Until we get down to the code, here is a little snapshot to get you hooked:

 

A bit of history: boids, flocks, herds, etc…

In 1986, Craig Reynolds wrote a little application that simulated bird group behaviors. The term Boids was born. The beauty of his approach was that the “bird” behavior was not created from some complicated mathematical equation, it all boiled down to 3 simple rules that each agent would follow:

  1. Separation: avoid neighbors,
  2. Cohesion: go towards the group center,
  3. Alignment: align with group velocity.

Since then there has been a lot action in this field and you can see applications of this approach in a lot of the blockbuster hits. Check out Craig’s web site for an impressive list of links to papers (I love this one), samples, frameworks and movies…. It was about time to bring .NET into the play.

Laying down concepts

Let’s start by identifying the concepts in our problem that we can later translate into interfaces:

  • An Agent describes an independent entity that lives in a World. An Agent has a Vision, a Body and a Behavior
  • A Body defines the cinematic properties of the agent (position, acceleration, etc…)
  • A Vision defines the region where the Agent can “see” obstacles or neighbors
  • The Behavior of the Agent will yield a steering force that will move the Agent. This is the “brain” of the agent.
  • Agents are confined in a World.
  • A Simulator that uses an Integrator to integrate the dynamics of the system.

We will also need ways to access the list of Agents, Obstacles, etc… To do so, I chose to use the Service – Component – Container pattern where different services give access to the agents, obstacles, etc...

In .Net, this pattern is already part of the framework. The IComponent, IContainer interfaces are defined in System.ComponentModel and there already exists base class such as Container, Component, ServiceContainer to get started.

For a start, we will define the following services:

  • AgentService, gives access to the Agents,
  • WorldService, gives access to the world dimension and properties,
  • ObstacleService, gives access to the obstacles in the world,
  • NeighorhoodService, let agent query about neighboring agents

At last, we need some concepts for visualization:

  • A Sprite is a 2D drawing with background color, foreground color, etc… It can be hidden or made visible.
  • A Scene is an abstraction of GDI+,(just in case I had the courage to implement the framework using DirectX or XAML).

There might be a couple more going down the road, but this looks like a good starting point. I’ll see on the next post how we lay down the interface and maybe get ready for testing.

posted on Wednesday, May 25, 2005 8:35:00 PM (Pacific Daylight Time, UTC-07:00)  #    Comments [0]
# Sunday, May 22, 2005

All downloads recompiled against Reflector 4.1.52.0 available at http://www.projectdistributor.net/Groups/Group.aspx?groupId=34 .

Enjoy :)

posted on Sunday, May 22, 2005 7:49:00 PM (Pacific Daylight Time, UTC-07:00)  #    Comments [2]
# Friday, April 22, 2005

Andrew Stopford has agreed to take over the MbUnit and keep it running. This is a very good news for the project. Hopefully, MbUnit can recover a short bug fix cycle and shape up its integration with CruiseControl.NET or Draco.

Good luck Andrew !

 

posted on Friday, April 22, 2005 11:25:00 AM (Pacific Daylight Time, UTC-07:00)  #    Comments [2]
# Friday, April 15, 2005

To whom it may concern:


As many of you probably know, I am now working at Microsoft in the CLR JIT testing team.  As my job load and duties are filling up more and more, I am unable to continue to contribute at a rate that best serves this project.  From this point forward please consider Jamie Cansdale (www.testdriven.net) as the sole owner (work/responsibilities/fun) for the MbUnit project.  I’ll of course be around occasionally.


Cheers,
Peli

posted on Friday, April 15, 2005 9:30:00 AM (Pacific Daylight Time, UTC-07:00)  #    Comments [15]
# Sunday, January 09, 2005

This is a rather funny application of unit testing. Let me state the problem:

We need to write a wrapper for every type that inherits from C. To make sure we don't miss any, we start by writing a combinatorial test that makes sure every type is mapped with a wrapper type*.

[TestFixture]
public class WrapperTest
{
    // get all the types assignable to C, from the assembly SomeAssembly
    [Factory(typeof(Type))]
    public IEnumerable<Type> Types()
    {
        foreach(Type type in SomeAssembly.GetExportedTypes())
        { 
            if (typeof(C).IsAssignableFrom(type))
               yield return type;
        }
    } 

    // tests that all types have a wrapper
    [CombinatorialTest]
    public void EnsureWrapper(
        [UsingFactories("Types")]Type type
    )
    {
        Assert.IsTrue( IsWrapped(type) );
    }
    
    // returns true of the wrapper exists
    private bool IsWrapped(Type type)
    {...}
}

Ok, we can run this test and see a lot of failures. So now we know wich wrapper has to be written.... but wait, why not making the test generate the wrapper as well.

    [CombinatorialTest]
    public void EnsureWrapper(
        [UsingFactories("Types")]Type type
    )
    {
        if (IsWrapped(type))
            return;

        // wrapper not found, 
        // generating the code and dumping it to Console.Out
        ...

        Assert.Fail("Wrapper not found");
    }

Now, we have test cases that give us the fix in case of a failure :)

*: this could be done by a FxCop rule as well since it is pure static analysis.

posted on Sunday, January 09, 2005 4:13:00 PM (Pacific Standard Time, UTC-08:00)  #    Comments [5]
# Saturday, January 08, 2005

Updated Reflector.Framework for Reflector 4.1.27.0.

This version has an automatic *non-intrusive* checking for available updates... based on ProjectDistributor web services :) 

Download it here

posted on Saturday, January 08, 2005 8:44:00 AM (Pacific Standard Time, UTC-08:00)  #    Comments [3]
# Friday, January 07, 2005

ProjectDistributor is a new actor on the scene of inline project managment (thanks for Darren). It provides a simple web site for publishing your little cool applications that have been sleeping on your desktop.

Unlike the big guns like sourceforge, tigris or gotdotnet, ProjectDistributor is simple simple simple. With RSS and webservices, it has the vitual but no more features, anyway who uses all the feature from sf or tigris ?

I've decided to use ProjectDistributor to publish my snippets and other useless samples. Currently, the following applciations are already there:

ps: ProjectDistributor.AutoUpdate is a micro autoupdate framework for your application based on projectdistributor. The next release of the addins with support that .... and have their “Check for Addin update” button :)

posted on Friday, January 07, 2005 5:57:00 AM (Pacific Standard Time, UTC-08:00)  #    Comments [4]