Silverlight Print Plugin

by Administrator 13. März 2012 13:18

PiBa sent me a mail with a project he did based upon the silverlight injection article I did. He did a hook based on the method that allows printing silverlight applications. Pretty cool. He asked me to post his project here, so here it is. Please note, that I did not look into it too deeply, perhaps give some feedback.

Thanks alot for contributing PiBa.

SilverlightInjectPrintPlugin.7z (887,68 kb)

Tags: , , ,

Silverlight

SilverDebugView

by Administrator 16. Juni 2010 15:03

Ok, this visual tree dumping thing actually kept me thinking, whether there is a way to have a GUI displaying the visual tree instead of just dumping it to the console. I came across things like calling WCF services or writing a debugging visualizer, but none of this seems really feasable. Then I found out about the LocalMessageReciever/LocalMessageSender mechanism which is out there since Silverlight 3. In a nutshell it allows for posting messages in between multiple Silverlight applications running on the same box. So I made a prototype that goes ahead and serializes the visual tree into such messages and have a Silverlight app on the other hand decoding and displaying the tree. The effect is really stunning. For my test solution I created 3 projects:

  • The project containing the debug library that can either be invoked via the immediate window when debugging or just be called via code.
  • A test application that dumps it's visual tree.
  • A Viewer application that displays the visual tree.

To dump a visual tree, just use this command:

d.vt ([RootObject});

I wired up this call to the click handler of the button in the test application, but as I said it works in the immediate window as well.

The viewer application will pick the dump packets up reassemble them. Packets using the LocalMessageReciever/LocalMessageSender Api may not supercede a size of 40k which might now be enough in some cases, so I added a fragmentation mechanism. The receiver is pretty straightforward and allows navigating in between received packets.

As you can see from the screenshot, we received three visual tree messages. I kept the format for messages open, so that it's possible to implement other message types and viewers for those. This is just a proof-of-concept solution, so it won't be valuable for debugging at this point, I'm note sure, whether I will add more to it or just leave it as an example. The dumping logic for the tree is an extended version of the one from this article. If you're interested in the source, you can download it here:

SilverDebugTestApplication.zip (38,51 kb)

Tags: , , ,

My Stuff | Projects | Silverlight

Debugging Visual Trees in Silverlight

by Administrator 12. Juni 2010 01:08

Sometimes when debugging Silverlight applications, you might want to inspect the visual tree. There is a good visualizer for WPF that allows you to do it, unfortunately there is none for Silverlight as far as I know. However I found this post, that contains a class you can embed in your project and then use in the immediate window to dump parts of the visual tree.

I played around with it at work and it works as expected, thanks alot Kiener for this one.

 

 

Tags: , ,

Silverlight

Enumerating Dependency Properties in Silverlight

by Administrator 3. Juni 2010 04:51

For a binding problem I wrote some helper code to enumerate dependency properties of a class. To pull that off, you have to use reflection to gather the static public fields of type DependencyProperty  and do the same for all base classes up to dependency object. To minimize the performance hit, resolved properties are cached, which is really good for you, wenn you use inheritance for your own crafted controls.

private class DependencyPropertyList : List<DependencyProperty>
{
}

private Dictionary<Type, DependencyPropertyList> m_TypeDependencyProperties = new Dictionary<Type, DependencyPropertyList>();

protected virtual IEnumerable<DependencyProperty> GetDependencyPropertiesRecursive(Type type)
{
    if (!m_TypeDependencyProperties.ContainsKey(type))
    {
        DependencyPropertyList propertyList = new DependencyPropertyList();

        foreach (FieldInfo field in type.GetFields(BindingFlags.Public | BindingFlags.Static))
        {
            if (field.FieldType == typeof(DependencyProperty))
            {
                propertyList.Add((DependencyProperty)field.GetValue(null));
            }
        }
        m_TypeDependencyProperties.Add(type, propertyList);
    }

    foreach (DependencyProperty property in m_TypeDependencyProperties[type])
    {
        yield return property;
    }

    if (type != typeof(DependencyObject))
    {
        foreach (DependencyProperty property in GetDependencyPropertiesRecursive(type.BaseType))
        {
            yield return property;
        }
    }
}

Tags: , ,

Silverlight

XapDump v1.1

by Administrator 31. Mai 2010 13:25

Ok, there was some stuff important enough to pack a new release:

  • Bug fixed, when extracting files in subfolders (either via copy&paste or Reflector)
  • Fixed a display bug with filtering
  • Added the option to select a reflector directory. If the executable is not found at %PROGRAMFILES%\Reflector, a browse dialog opens to select the executable.

Tags: , ,

My Stuff

XapDump v1.0

by Administrator 30. Mai 2010 02:45

Ok, I cleaned up a little, added a textual filter for the list of files and added sorting. This should do for a while.

Tags: , , ,

My Stuff | Projects | Silverlight

XapDump

by Administrator 29. Mai 2010 05:07

I added a little extension for Fiddler that i hacked together this moring. Check this page to find out more.

Enjoy :P

Tags: , ,

My Stuff | Projects | Silverlight

Silverlight 4 Apps with Elevated Permissions

by Administrator 22. Mai 2010 02:13

Writing my first Silverlight 4 application today I had a major turnoff. One of the highly praised new features of Silverlight 4 is the elevated permission feature, where you can - when the user consents - access the local file system, circumvent cross domain policies and more. My plan was to write a Silverlight telnet client that can run embedded in the browser. Well, the client did really fine, when debugging (which happens as an out of browser experience), however when searching for the flag where you can request the elevated permissions, I came to the conclusion that there is none. Silverlight only allows utilizing elevated permissions out of browser as this article states.

This is in my opinion the dumbest thing ever, since you actually do not blur the line between browser and desktop applications. From the users perspective, if the application has to be launched differently to allow these elevated permission related functionality, it is another application. I don't see any reason why you should not have a confirmation mechanism in place in the browser where you have to acknowledge elevated permissions (the way you acknowledge stuff like unsecure content, potentially risky certificates, ...).

This was the coffin nail, for what I wanted to do, since desktop applications are available in large masses.

Here are the sources for the client so far, perhaps you find some interesting stuff, of course the project is in an unfinished state. Perhaps I should also have added a recording of my howls when I found out about the out of browser shit :P

SilverTelnet.zip (15,99 kb)

Tags: , , ,

Silverlight

Cruise Control.NET & StatLight

by Administrator 29. April 2010 06:45

As posted some weeks ago we ran into issues with hung IE instances in a continuous integration environment running Silverlight unit tests. We switched to the StatLight which runs really good so far. To get the results in the build report, you need to adjust the stylesheet that transforms the unit test results to html.

Our build/integration guru Klaus was kind enough to provide this.

Check the readme.txt for instructions on how to install this.

CCNet-StatLight.zip (2,48 kb)

Tags: , , ,

General

Silverlight, Wcf Services in ASP.Net Compatibility Mode and Threading

by Administrator 14. Oktober 2009 13:05
I added an article on threading issues with silverlight and wcf in compatibility mode, perhaps this saves you some hassle in similar situations.

Tags: , , ,

Silverlight | Wcf

About the author

for comments and suggestions contact:

 

Month List