Jan 14

It seems there is lots of confusion about getting Silverlight applications to access Services on a different domain to the one where the Silverlight application comes from.

It probably does not help that the example given here by Microsoft appear not to work:

http://msdn.microsoft.com/en-us/library/cc197955(v=vs.95).aspx

What is not made clear is that by default, the secure setting is set to true, so that this seems to only work for https connections. After much trial and error, I managed to get this to work:

<?xml version="1.0" ?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="*" secure="false" />
<allow-http-request-headers-from domain="*" headers="SOAPAction" secure="false"/>
</cross-domain-policy>

Note the secure=”false”. If you leave these out, they default to true.

The other point to note is that you MUST have domain=”*”. You cannot restrict by domain, you have to allow ALL domains access, which is not always what you want.

In that case, you MUST use a clientaccesspolicy.xml file instead, in which you can restrict the domains, as described in the Microsoft link above.

For example:

<?xml version="1.0" encoding="utf-8"?>
<access-policy>
  <cross-domain-access>
    <policy>
      <allow-from http-request-headers="SOAPAction">
        <domain uri="http://www.electricscribes.com"/>
      </allow-from>
      <grant-to>
        <resource path="/" include-subpaths="true"/>       
      </grant-to>
    </policy>
  </cross-domain-access>
</access-policy>

Good luck! Scribbles Out.

Tags:
Dec 05

With thanks to Jan Van Der Haegen for his ExtensionsMadeEasy, without which I could not have achieved this. Winking smile

Basically, in Lightswitch, I wanted a button on the Ribbon that allows the user to view messages. The Button should update itself to reflect how many unread messages are available, like so:

image

First install Jan’s Extensions, which you can get here.

Then add the following code to the application.cs. This creates an event you can raise when a new message becomes available.

public partial class Application
{
    public delegate void NewMessage();
    public event NewMessage MessageReceived;

    public void RaiseMessageReceived()
    {
        if (this.Details.Dispatcher.CheckAccess())
            MessageReceived();
        else
            this.Details.Dispatcher.BeginInvoke(delegate()
            {
                MessageReceived();
            });
    }
}

Then you need the following code, which creates the command:

public class MessagesCommand : ExtensionsMadeEasy.ClientAPI.Commands.EasyCommandExporter
    {
        private int messageCount = 0;
        public int MessageCount
        {
            get { return messageCount; }
            set { messageCount = value; }
        }

        public new string Description
        {
            get { return string.Format("You have {0} message(s) waiting to be read", MessageCount); }
        }

        public new string DisplayName
        {
            get { return string.Format("Messages ({0})", MessageCount); }
        }

        public MessagesCommand() :
            base("", "", "Screens",
            new Uri(@"/ECSManager.Client;component/Resources/mail-128.png", UriKind.Relative))
        {
            base.Description = this.Description;
            base.DisplayName = this.DisplayName;
            Application.Current.MessageReceived += new Application.NewMessage(Current_MessageReceived);
        }

        void Current_MessageReceived()
        {
            // MessageReceived event is raised on the application's thread
            // so need to do the UI update on a different thread
            MessageCount++;
            Microsoft.LightSwitch.Threading.Dispatchers.Main.BeginInvoke(() =>
                {
                    base.DisplayName = this.DisplayName;
                    base.Description = this.Description;
                });
        }

        public override void Execute(Microsoft.LightSwitch.Client.IScreenObject currentScreen)
        {
            // Open the Messages Screen (put your code here)
        }
    }

Scribbles Out.

Tags:
Jun 20

Had a client today stop receiving inbound emails on their SBS2008 server. It turned out that Windows Update Services – WSUS - had maxed out the hard drive! Devil

So I moved the Exchange database to a new spare drive, as explained so clearly here:

http://www.b4z.co.uk/tag/4-3-1-insufficient-system-resources

and cleaned up WSUS, which is explained clearly here:

http://blogs.technet.com/b/gborger/archive/2009/02/27/what-to-do-when-your-wsuscontent-folder-grows-too-large.aspx

Thanks guys! Thumbs up

Scribbles Out.

Apr 01

If you browse the Silverlight Community site here, you will find plenty of Slideshow type applications. If you want to extend them, you can often get the source code, but many of them are written in previous versions of Silverlight or possibly reference older .net assemblies. 

Since I particularly like the one by Michiel Post from the Netherlands (you can see it on his blog here) I decided to upgrade it to Silverlight 4, which you can download from the file attached to this post. I was going to customise it, hence why the Solution name has changed from Photo Browser to Slideshow. I stopped short of customising it when I found the Vertigo slideshow solution, which is very easy to customise. It is provided on Codeplex by Vertigo here and you can see I've used it (customised of course) here.

Slideshow.zip (543.89 kb)