This project is read-only.

WPF Designer Various Problems

Dec 12, 2007 at 9:53 PM
Hello guys,

I can't get the WPF designer to produce working code for even the most trivial project.

I create a new WPF file and then hit F6 nad get "Unknown build error, 'Object reference not set to an instance of an object.'"

Aside from not being able to build, the code that the designer creates is doomed to failure.

It attempts to import from System.Windows without calling 'clr.AddReference' for "PresentationFramework" or "PresentationCore"

Even with this manually added, it fails to load the XAML file - failing with an error like:

File PresentationCore, line unknown, in GetLoadedAssembly
IOError: Could not load file or assembly 'WpfApplication2, Culture=neutral' or o
ne of its dependencies. The system cannot find the file specified.

Any clues as to how I can get this worong. The line that loads the XAML is:

self.Root = Application.LoadComponent(Uri("/WpfApplication2;component/Window1.xaml", UriKind.Relative))

The MSDN docs aren't much help as they assume you are compiling XAML, using MSBuild or using a XAML reader rather than calling LoadComponent. How should the URI be constructed?

Michael Foord
Dec 12, 2007 at 11:35 PM

To fix the issue you need to register the IronPython CodeDOM in the machine config. Please read the readme.html file installed with IronPython Studio.

Dec 13, 2007 at 12:14 PM
Hmmm... when I do that the designer completely fails to load and refuses to create new WPF projects.

I even tried uninstalling and then reinstalling Visual Studio X redist. and the IronPython Studio. Same problem.

Can you confirm that you have got this to work? (I'm using Windows XP).

Michael Foord
Dec 13, 2007 at 6:02 PM
As a further update (still not working...)

I uninstalled Visual Studio 2008 beta - and the VS 2008 shell and IronPython Studio again. Restarted the machine. Reinstalled the shell and IronPython Studio.

Amended my machine.config.

This time round IronPython Studio is incapable of creating wpf projects...

When I create a Windows Forms project and attempt to build, I now get the following error message:

Could not load file or assembly 'IronPython, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Which is interesting...

Dec 14, 2007 at 7:20 PM
That's very similar to the error I get when I try to create a basic WinForm app. Not sure why I'm missing or if it's a bug, but I don't get a whole lot of other information to go on. Of course, I'm still losing the visual side of my form components, but that is probably unrelated.

Dec 16, 2007 at 8:18 AM
I was having the same problem as fuzzyman, but think I just found the solution (while I was in the middle of writing this post as a confirmation of the problem).

Right after installation, I built and ran the default Command line, Forms and WPF apps, but the WPF app refused to run and gave the 'Object reference not set to an instance of an object.' error. I don't see any mention of registering the IronPython CodeDOM in the machine config in the Readme.html of IronPython Studio, so I followed the instructions from this page to register the IronPython CodeDOM:
After that, if I tried to create a WPF app, I get "Package Load Failure" for Microsoft.VisualStudio.WPFPackage.

The root of the problem seems to be that Aaron's blog instruct you to add the new XML "Under the root <configuration> node". I tried locating the new XML block at the beginning and alternatively at the end of the <configuration> node. It was only when I put the new <system.codedom> node between the <system.web> and <system.serviceModel> nodes that the WPF app could be created, built and debugged.

Thank you for making IronPython Studio. I've intended to spend some time learning Python, .Net and WPF each for a while now. Because IPS brings them all together it is enough to get me to finally sit down and dig in.
Dec 16, 2007 at 10:45 AM

Wow, it's already Christmas :)

Thanks Corysama(sensei), your solution works great for me too!
Dec 18, 2007 at 12:02 AM
No dice for me though. :-(

After making thsi change, (and restarting) attempting to create a WPF project fails with the following error:

VSIP: Developer edition, all third-party packages allowed to load.
The Microsoft.VisualStudio.Internal.WPFFlavor.WPFPackage, Microsoft.VisualStudio.WPFFlavor, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ({B3BAE735-386C-4030-8329-EF48EEDA4036}) did not load because of previous errors. For assistance, contact the package vendor. To attempt to load this package again, type 'appenv /resetskippkgs' at the command prompt.

Needless to say I can't find appenv to run this command. I've found nothing useful on the intarwebz but will keep searching.

Dec 18, 2007 at 12:11 AM
Hmm... so I deduced (with a couple of clues) that I should run 'IronPythonStudio.exe /resetskippkgs'

Now the WPF designer is back, yay! However building a project still dies with the exception:

Could not load file or assembly 'IronPython, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
(odd error - failing to load IronPython assembly!? - this textbox does not do the right things with the enter button on Firefox by the way)
sigh - now I'm somewhere closer. The relevant part of my machine.config looks like:

<compiler language="py;IronPython" extension=".py" type="IronPython.CodeDom.PythonProvider, IronPython, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

If any of you can deduce further clues it would be much appreciated... (off to check my GAC)

Michael Foord
Dec 18, 2007 at 12:19 AM
Ok - found this problem. It is copying the IronPython dlls from my Visual Studio 2005 SDK install (!?!) - and they are different versions. Presumably some environment variable or registry entry is wrong. Manually copying the correct dlls over causes the compiled (!) app to work - which is pretty cool (but a pain).

Nice though and it looks like I have it working - thanks for the help and sorry for all the noise.

May 28, 2008 at 3:34 AM
One more delayed thank you -- that worked for me as well:)