Just compiled this against SL5RC and Toolkit 5. Working Nicely.
Geoff Webber-Cross - .Net, Windows 8, Silverlight and WP developer. Software problem solver. My Website Obelisk - WP7 MVVM Tombstone Library
Thursday, 3 November 2011
Thursday, 20 October 2011
sllauncher.exe 5.0.60818.0 - OutOfBrowserSettings.Icons Issue
We've been testing an SL4 app which is used both in and out of browser agains SL5RC. Which runs fine in browser, but when launched out-of-browser, sllauncher crashed with the following error:
Faulty module name: unknown v0.0.0.0
Exception Code: 0xc0000005
I created a dummy SL5 test app and it ran OOB fine.
After stripping back our main app to almost nothing I still had the same problem, but I noticed we had icons set in the OOB settings. OutOfBrowserSettings.xml Example:
<OutOfBrowserSettings ShortName="SLApp" EnableGPUAcceleration="True" ShowInstallMenuItem="False">
<OutOfBrowserSettings.Blurb>Install SLApp application out of the browser</OutOfBrowserSettings.Blurb>
<OutOfBrowserSettings.WindowSettings>
<WindowSettings Title="SLApp" Height="60" Width="595" />
</OutOfBrowserSettings.WindowSettings>
<OutOfBrowserSettings.SecuritySettings>
<SecuritySettings ElevatedPermissions="Required" />
</OutOfBrowserSettings.SecuritySettings>
<OutOfBrowserSettings.Icons>
<Icon Size="16,16">Icons/SLApp16x16.png</Icon>
<Icon Size="32,32">Icons/SLApp32x32.png</Icon>
<Icon Size="48,48">Icons/SLApp48x48.png</Icon>
<Icon Size="128,128">Icons/SLApp128x128.png</Icon>
</OutOfBrowserSettings.Icons>
</OutOfBrowserSettings>
(These settings can be set in the SL app OOB properties dialogue as well)
IF THE ICONS BLOCK IS REMOVED:
<OutOfBrowserSettings ShortName="SLApp" EnableGPUAcceleration="True" ShowInstallMenuItem="False">
<OutOfBrowserSettings.Blurb>Install SLApp application out of the browser</OutOfBrowserSettings.Blurb>
<OutOfBrowserSettings.WindowSettings>
<WindowSettings Title="SLApp" Height="60" Width="595" />
</OutOfBrowserSettings.WindowSettings>
<OutOfBrowserSettings.SecuritySettings>
<SecuritySettings ElevatedPermissions="Required" />
</OutOfBrowserSettings.SecuritySettings>
</OutOfBrowserSettings>
The aplication runs fine OOB!
This looks like a bug in sllauncher.exe 5.0.60818.0.
Faulty module name: unknown v0.0.0.0
Exception Code: 0xc0000005
I created a dummy SL5 test app and it ran OOB fine.
After stripping back our main app to almost nothing I still had the same problem, but I noticed we had icons set in the OOB settings. OutOfBrowserSettings.xml Example:
<OutOfBrowserSettings ShortName="SLApp" EnableGPUAcceleration="True" ShowInstallMenuItem="False">
<OutOfBrowserSettings.Blurb>Install SLApp application out of the browser</OutOfBrowserSettings.Blurb>
<OutOfBrowserSettings.WindowSettings>
<WindowSettings Title="SLApp" Height="60" Width="595" />
</OutOfBrowserSettings.WindowSettings>
<OutOfBrowserSettings.SecuritySettings>
<SecuritySettings ElevatedPermissions="Required" />
</OutOfBrowserSettings.SecuritySettings>
<OutOfBrowserSettings.Icons>
<Icon Size="16,16">Icons/SLApp16x16.png</Icon>
<Icon Size="32,32">Icons/SLApp32x32.png</Icon>
<Icon Size="48,48">Icons/SLApp48x48.png</Icon>
<Icon Size="128,128">Icons/SLApp128x128.png</Icon>
</OutOfBrowserSettings.Icons>
</OutOfBrowserSettings>
(These settings can be set in the SL app OOB properties dialogue as well)
IF THE ICONS BLOCK IS REMOVED:
<OutOfBrowserSettings ShortName="SLApp" EnableGPUAcceleration="True" ShowInstallMenuItem="False">
<OutOfBrowserSettings.Blurb>Install SLApp application out of the browser</OutOfBrowserSettings.Blurb>
<OutOfBrowserSettings.WindowSettings>
<WindowSettings Title="SLApp" Height="60" Width="595" />
</OutOfBrowserSettings.WindowSettings>
<OutOfBrowserSettings.SecuritySettings>
<SecuritySettings ElevatedPermissions="Required" />
</OutOfBrowserSettings.SecuritySettings>
</OutOfBrowserSettings>
The aplication runs fine OOB!
This looks like a bug in sllauncher.exe 5.0.60818.0.
Wednesday, 7 September 2011
RichTextBlock XAML Bindable Rich Text Block
I recently needed to use a RichTextBox for a project, but was disapointed to find there is no way of binding the content of the control. Luckily it's possible to access the XAML property and inject RichText format XAML into it. I decided to create a control derived from RichTextBox with a dependency property used to bind the Rich Text XAML.
The first step is to create the control (I re-exposed the mouse click event as the RichTextBox buries it):
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Ink;
using System.Windows.Input;
namespace RichTextBlock
{
/// <summary>
/// Used for databinding to Xaml property via new XamlSource DP
/// </summary>
public class RichXamlTextBlock : RichTextBox
{
public event MouseButtonEventHandler MouseClicked = null;
private static string _xamlStart = "<Section xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"><Paragraph>";
private static string _xamlEnd = "</Paragraph></Section>";
public RichXamlTextBlock()
: base()
{
base.Cursor = Cursors.Arrow;
}
#region XamlSource
public static readonly DependencyProperty XamlSourceProperty = DependencyProperty.Register("XamlSource", typeof(string), typeof(RichXamlTextBlock),
new PropertyMetadata(null, new PropertyChangedCallback(OnXamlSourcePropertyChanged)));
public string XamlSource
{
get { return (string)GetValue(XamlSourceProperty); }
set
{
SetValue(XamlSourceProperty, value);
}
}
private static void OnXamlSourcePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
RichXamlTextBlock rtb = (RichXamlTextBlock)d;
rtb.Xaml = string.Format("{0}{1}{2}", _xamlStart, e.NewValue, _xamlEnd as string);
}
#endregion
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
{
if (this.MouseClicked != null)
{
this.MouseClicked(this, e);
}
}
}
}
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Ink;
using System.Windows.Input;
namespace RichTextBlock
{
/// <summary>
/// Used for databinding to Xaml property via new XamlSource DP
/// </summary>
public class RichXamlTextBlock : RichTextBox
{
public event MouseButtonEventHandler MouseClicked = null;
private static string _xamlStart = "<Section xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"><Paragraph>";
private static string _xamlEnd = "</Paragraph></Section>";
public RichXamlTextBlock()
: base()
{
base.Cursor = Cursors.Arrow;
}
#region XamlSource
public static readonly DependencyProperty XamlSourceProperty = DependencyProperty.Register("XamlSource", typeof(string), typeof(RichXamlTextBlock),
new PropertyMetadata(null, new PropertyChangedCallback(OnXamlSourcePropertyChanged)));
public string XamlSource
{
get { return (string)GetValue(XamlSourceProperty); }
set
{
SetValue(XamlSourceProperty, value);
}
}
private static void OnXamlSourcePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
RichXamlTextBlock rtb = (RichXamlTextBlock)d;
rtb.Xaml = string.Format("{0}{1}{2}", _xamlStart, e.NewValue, _xamlEnd as string);
}
#endregion
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
{
if (this.MouseClicked != null)
{
this.MouseClicked(this, e);
}
}
}
}
The next step is to create a View Model with some XAML rich text. It is important to be careful what you bind as you could end up doing an 'injection attack' on your markup by accident!
using System;
namespace RichTextBlock
{
public class ViewModel
{
private string _xamlSource = "This is a demonstration of the <Run Text=\"RichTextBlock\" FontWeight=\"Bold\" Foreground=\"Green\"/>. The control's XAML can be data bound unlike a normal <Run Text=\"RichTextBox\" FontWeight=\"Bold\" Foreground=\"Red\"/>.";
public string XamlSource
{
get { return this._xamlSource; }
}
}
}
namespace RichTextBlock
{
public class ViewModel
{
private string _xamlSource = "This is a demonstration of the <Run Text=\"RichTextBlock\" FontWeight=\"Bold\" Foreground=\"Green\"/>. The control's XAML can be data bound unlike a normal <Run Text=\"RichTextBox\" FontWeight=\"Bold\" Foreground=\"Red\"/>.";
public string XamlSource
{
get { return this._xamlSource; }
}
}
}
Next the new control needs adding to a view:
<UserControl x:Class="RichTextBlock.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:RichTextBlock"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<UserControl.DataContext>
<local:ViewModel />
</UserControl.DataContext>
<UserControl.Resources>
<Style x:Key="RichXamlTextBlockStyle" TargetType="local:RichXamlTextBlock">
<Setter Property="IsReadOnly" Value="True" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:RichXamlTextBlock">
<Grid x:Name="ContentElement" Background="{TemplateBinding Background}" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
<Grid x:Name="LayoutRoot" Background="White">
<local:RichXamlTextBlock XamlSource="{Binding Path=XamlSource, Mode=OneWay}" Style="{StaticResource RichXamlTextBlockStyle}" />
</Grid>
</UserControl>
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:RichTextBlock"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<UserControl.DataContext>
<local:ViewModel />
</UserControl.DataContext>
<UserControl.Resources>
<Style x:Key="RichXamlTextBlockStyle" TargetType="local:RichXamlTextBlock">
<Setter Property="IsReadOnly" Value="True" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:RichXamlTextBlock">
<Grid x:Name="ContentElement" Background="{TemplateBinding Background}" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
<Grid x:Name="LayoutRoot" Background="White">
<local:RichXamlTextBlock XamlSource="{Binding Path=XamlSource, Mode=OneWay}" Style="{StaticResource RichXamlTextBlockStyle}" />
</Grid>
</UserControl>
I also added a stripped down template to remove the TextBox type appearance to get it looking like a TextBlock.
Wednesday, 10 August 2011
Toolkit Chart ControlTemplate
<ControlTemplate TargetType="toolkit:Chart">
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<toolkit:Title Content="{TemplateBinding Title}" Style="{TemplateBinding TitleStyle}"/>
<Grid Margin="0,15,0,15" Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<toolkit:Legend x:Name="Legend" Grid.Column="1" Header="{TemplateBinding LegendTitle}" Style="{TemplateBinding LegendStyle}"/>
<System_Windows_Controls_DataVisualization_Charting_Primitives:EdgePanel x:Name="ChartArea" Style="{TemplateBinding ChartAreaStyle}">
<Grid Style="{TemplateBinding PlotAreaStyle}" Canvas.ZIndex="-1"/>
<Border BorderBrush="#FF919191" BorderThickness="1" Canvas.ZIndex="10"/>
</System_Windows_Controls_DataVisualization_Charting_Primitives:EdgePanel>
</Grid>
</Grid>
</Border>
</ControlTemplate>
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<toolkit:Title Content="{TemplateBinding Title}" Style="{TemplateBinding TitleStyle}"/>
<Grid Margin="0,15,0,15" Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<toolkit:Legend x:Name="Legend" Grid.Column="1" Header="{TemplateBinding LegendTitle}" Style="{TemplateBinding LegendStyle}"/>
<System_Windows_Controls_DataVisualization_Charting_Primitives:EdgePanel x:Name="ChartArea" Style="{TemplateBinding ChartAreaStyle}">
<Grid Style="{TemplateBinding PlotAreaStyle}" Canvas.ZIndex="-1"/>
<Border BorderBrush="#FF919191" BorderThickness="1" Canvas.ZIndex="10"/>
</System_Windows_Controls_DataVisualization_Charting_Primitives:EdgePanel>
</Grid>
</Grid>
</Border>
</ControlTemplate>
Tuesday, 2 August 2011
WIX 3 NETSH CustomAction
I've been writing a WIX 3 installer for a Windows Service with 2 self hosted WCF services. In order to connect to the WCF services, a Namespace reservation must be made using netsh.exe. I wanted to get the WIX installer to perform this operation during installation so decided to use a CustomAction to achieve this. As anybody who uses WIX will know, it is extremely powerful but sparsely documented and quiet frustrating to use. It took a while to get the CustomAction to work, so I thought I'd share the solution:
!-- Custom action to set WCF namespace reservation -->
<CustomAction Id="ListenerServiceAddReservation"
Directory="INSTALLLOCATION"
ExeCommand="[SystemFolder]netsh.exe http add urlacl url=http://+:8888/ServiceNamespace/TestService/ sddl=D:(A;;GX;;;WD)"
Return="asyncWait" />
<CustomAction Id="ListenerServiceDeleteReservation"
Directory="INSTALLLOCATION"
ExeCommand="[SystemFolder]netsh.exe http delete urlacl url=http://+:8888/ ServiceNamespace/TestService/"
Return="asyncWait" />
<InstallExecuteSequence>
<Custom Action="ListenerServiceDeleteReservation" Before="InstallFinalize">Installed</Custom>
<Custom Action="ListenerServiceAddReservation" Before="InstallFinalize">NOT Installed</Custom>
</InstallExecuteSequence>
!-- Custom action to set WCF namespace reservation -->
<CustomAction Id="ListenerServiceAddReservation"
Directory="INSTALLLOCATION"
ExeCommand="[SystemFolder]netsh.exe http add urlacl url=http://+:8888/ServiceNamespace/TestService/ sddl=D:(A;;GX;;;WD)"
Return="asyncWait" />
<CustomAction Id="ListenerServiceDeleteReservation"
Directory="INSTALLLOCATION"
ExeCommand="[SystemFolder]netsh.exe http delete urlacl url=http://+:8888/ ServiceNamespace/TestService/"
Return="asyncWait" />
<InstallExecuteSequence>
<Custom Action="ListenerServiceDeleteReservation" Before="InstallFinalize">Installed</Custom>
<Custom Action="ListenerServiceAddReservation" Before="InstallFinalize">NOT Installed</Custom>
</InstallExecuteSequence>
Thursday, 9 June 2011
SharePoint 2010 BDC Model Builder - Full Release
There is now a full release of SharePoint 2010 BDC Model Builder to download:
http://bdcmodelbuilder.codeplex.com/
http://bdcmodelbuilder.codeplex.com/
Monday, 6 June 2011
Failed to create receiver object from assembly
I ran into a problem re-installing a WSP package which I'd added a feature receiver to, using powershell; it looked to have worked, but when I looked in Central Administration and looked at the solutions, it had installed with the following error:
ServerX : Failed to create receiver object from assembly "XXXX.YYYY.WebParts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=abcd1234efgh5678", class "XXXX.YYYY.WebParts.Features.Feature1.Feature1EventReceiver" for feature "WebParts_Feature1" (ID: 57cf6cbd-72e9-43a2-bf85-bb947587073f).: System.ArgumentNullException: Value cannot be null.
Parameter name: type
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at Microsoft.SharePoint.Administration.SPFeatureDefinition.get_ReceiverObject()
ServerX : Failed to create receiver object from assembly "XXXX.YYYY.WebParts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=abcd1234efgh5678", class "XXXX.YYYY.WebParts.Features.Feature1.Feature1EventReceiver" for feature "WebParts_Feature1" (ID: 57cf6cbd-72e9-43a2-bf85-bb947587073f).: System.ArgumentNullException: Value cannot be null.
Parameter name: type
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at Microsoft.SharePoint.Administration.SPFeatureDefinition.get_ReceiverObject()
It turns out that the SharePoint Timer service which handles solution installation caches DLLs and it had cached the old DLL which had no feature receiver. A simple re-start on the service solved the problem.
Found solution here after much googling:
http://social.technet.microsoft.com/Forums/en/sharepoint2010setup/thread/55217486-0df5-43ca-9487-cdb7a66334c9
ServerX : Failed to create receiver object from assembly "XXXX.YYYY.WebParts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=abcd1234efgh5678", class "XXXX.YYYY.WebParts.Features.Feature1.Feature1EventReceiver" for feature "WebParts_Feature1" (ID: 57cf6cbd-72e9-43a2-bf85-bb947587073f).: System.ArgumentNullException: Value cannot be null.
Parameter name: type
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at Microsoft.SharePoint.Administration.SPFeatureDefinition.get_ReceiverObject()
ServerX : Failed to create receiver object from assembly "XXXX.YYYY.WebParts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=abcd1234efgh5678", class "XXXX.YYYY.WebParts.Features.Feature1.Feature1EventReceiver" for feature "WebParts_Feature1" (ID: 57cf6cbd-72e9-43a2-bf85-bb947587073f).: System.ArgumentNullException: Value cannot be null.
Parameter name: type
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at Microsoft.SharePoint.Administration.SPFeatureDefinition.get_ReceiverObject()
It turns out that the SharePoint Timer service which handles solution installation caches DLLs and it had cached the old DLL which had no feature receiver. A simple re-start on the service solved the problem.
Found solution here after much googling:
http://social.technet.microsoft.com/Forums/en/sharepoint2010setup/thread/55217486-0df5-43ca-9487-cdb7a66334c9
Subscribe to:
Posts (Atom)