Sunday, October 11, 2009
I created a simple Silverlight 3 app.
<UserControl x:Class="SilverlightApplication2.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"
mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">
<Grid x:Name="LayoutRoot">
<TextBlock Text="Hello World!" ></TextBlock>
</Grid>
</UserControl>
When I run it I get this error
Line: 56
Error: Unhandled Error in Silverlight Application
Code: 2104
Category: InitializeError
Message: Could not download the Silverlight application. Check web server settings
Well if you look in the ClientBin folder you will see it is empty so the xap file is not available to be used
To fix this right click on the web application and select Build Order. On the Dependencies tab make sure the Checkbox next to the Silverlight app is checked.

6/17/2009 6:30:00 PM
6/17/2009 8:00:00 PM
About
John Papa is a Microsoft C# MVP, INETA speaker, member of the WPF and Silverlight Insiders, consultant, speaker, author, and trainer for ASPSOFT who specializes in professional application development with Microsoft technologies including Silverlight, WPF, C#, .NET and SQL Server. John has written over 70 articles and authored 9 books including his latest book Data Driven Services with Silverlight 2 by O’Reilly Media. John is currently working on a follow up to his Silverlight book, with a working title of Silverlight for Business.
He can often be found speaking at industry conferences such as MIX, VSLive and DevConnections, speaking at user groups around the country, and viewed on MSDN Web Casts. John also spearheaded the 1st annual Silverlight MIXer, a gathering of some of the most influential members of the Silverlight community for a great night a MIX09. You can always find John at johnpapa.net.
John Papa will be showing Astoria using Silverlight 3 beta as the client.
ADO.NET Data Services (codenamed Astoria) exposes entity models through RESTful services. It can dramatically simplify the code required to expose business objects through web services and reduce a tremendous amount of code. This session will show how to expose entity models using ADO.NET Data Services, how to consume and save data, and how to debug the communications using various tools. When the technology does not quite do what you need out of the box, it also allows for customizations to create custom service operations, intercept queries, and enforce permissions. Attendees will walk away with an understanding of the capabilities of ADO.NET Data Services, how to use them with Silverlight, and when and where it is ideal to use in an application architecture and when there are better options.
Street: 8045 N. Wickham Road
City: melbourne
Country: USA
State: Florida
Saturday, May 23, 2009
I upgraded my laptop the other day to use Windows 7 RC. I am really liking the speed improvements and the windows virtual pc that it comes with. Dont forget to enable virtualization on your microprocessor in your computer's bios settings if you want to use windows virtual pc.
The other day after the upgrade I was not able to log into my account. I got an message User Profile Service Failed the Logon. The error was caused by a messed up registry key for the user profile for my account. Well I was able to boot into safe mode and follow the instructions in this post in the Windows Vista Forums and fix the problem.
http://www.vistax64.com/tutorials/130095-user-profile-service-failed-logon-user-profile-cannot-loaded.html
Hope this helps
Thursday, March 26, 2009
I got email today asking me how to get the device ID from a pocket pc with vb
Imports System.Text
Public Class Form1
<System.Runtime.InteropServices.DllImport("coredll.dll")> _
Private Shared Function GetDeviceUniqueID(ByVal appdata As Byte(), ByVal cbApplictionData As Integer, ByVal dwDeviceIDVersion As Integer, ByVal deviceIDOuput As Byte(), ByRef pcbDeviceIDOutput As Integer) As Integer
End Function
Private Function GetDeviceId(ByVal appData As String) As Byte()
Dim appDataBytes As Byte() = System.Text.Encoding.ASCII.GetBytes(appData)
Dim outputSize As Integer = 20
Dim output(19) As Byte
Dim result As Integer = GetDeviceUniqueID(appDataBytes, appDataBytes.Length, 1, output, outputSize)
Return output
End Function
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim sbId As New StringBuilder
Dim bID() As Byte = GetDeviceId("MyAppName")
For Each b In bID
sbId.Append(String.Format("{0:x2}", b))
Next
Debug.WriteLine(sbId.ToString)
End Sub
End Class
References
http://www.peterfoot.net/GetDeviceUniqueIDForVB.aspx
http://msdn.microsoft.com/en-us/library/ms893522.aspx
Wednesday, March 25, 2009
The Patterns and Practices team has released VB versions of the Quick Starts, Hands on Labs, and How to Topics. You can download them here
http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=537da1cd-43e1-4799-88e7-a1da9166fb46
Thursday, October 09, 2008
With SilverLight 2.0 you can interact and handle events with the html elements on your page. Here is a simple example that places a select (drop down control) on a web page which will change the color of a ellipse on a SilverLight app. So lets start with the html
<body style="height: 100%; margin: 0;">
<form id="form1" runat="server" style="height: 100%;">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<br />
<span>Select a Color </span>
<select id="ddColor">
<option>Red</option>
<option>Blue</option>
<option>Green</option>
</select>
<br />
<br />
<div style="height: 100%;">
<asp:Silverlight ID="Xaml1" runat="server" Source="~/ClientBin/HtmlAndSilverlight.xap"
MinimumVersion="2.0.30923.0" Width="100%" Height="100%" />
</div>
</form>
</body>
Now the XAML
<UserControl x:Class="HtmlAndSilverlight.Page"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="400" Height="300">
<Canvas x:Name="LayoutRoot" Background="Tan" >
<Ellipse x:Name="el" Width="400" Height="300" Fill="Red"></Ellipse>
</Canvas>
</UserControl>
Now build the app so we have intellisense for the controls. Ok first off lets get access to the drop down (select) on the web page. Then we can use AttachEvent to handle the onchange event.
Dim cbo As HtmlElement
Private Sub Page_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded
cbo = HtmlPage.Document.GetElementById("ddColor")
cbo.AttachEvent("onchange", AddressOf ColorChanged)
End Sub
Once the user selects a color we will change the color of the ellipse. Here is the complete code listing
Imports System.Windows.Browser
Partial Public Class Page
Inherits UserControl
Public Sub New()
InitializeComponent()
End Sub
Dim cbo As HtmlElement
Private Sub Page_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded
cbo = HtmlPage.Document.GetElementById("ddColor")
cbo.AttachEvent("onchange", AddressOf ColorChanged)
End Sub
Private Sub ColorChanged(ByVal sender As Object, ByVal e As HtmlEventArgs)
Dim x = CInt(cbo.GetAttribute("selectedIndex").ToString)
Select Case x
Case 0
el.Fill = New SolidColorBrush(Colors.Red)
Case 1
el.Fill = New SolidColorBrush(Colors.Blue)
Case 2
el.Fill = New SolidColorBrush(Colors.Green)
End Select
End Sub
End Class
Hope this helps
Monday, January 12, 2009
REST which stands for Representational State Transfer is a way of sending data over the Internet without an additional message layer. Standard web services use soap for there message header. In this example we will create a service that uses the northwind database to send a list of the products for a category.
Lets start by create a new VB web application. In that web application add a Ado.Net Entities data model. In that class add the northwind database's product class.
Now add a service named Service1 to the web application. Lets start by modify the web.config for the service to support rest. First remove the ServiceBehavior section and add a endpointBehaviors section for webHttp. In the endpoint we have to change the binding to webHttpBinding and the behaviorConfiguration to the webBehavior we created.
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="webBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="True"></serviceHostingEnvironment>
<services>
<service name="RestTest.Service1">
<endpoint address="" behaviorConfiguration="webBehavior" binding="webHttpBinding" bindingConfiguration="" contract="RestTest.IService1">
</endpoint>
</service>
</services>
</system.serviceModel>
When we added the service we got 2 items the wcf service and an interface for the service. Before we go any further we need to add a reference to system.servicebehavior.web
In the Interface we need to define the how the categoryId is passed to the service. In this example it expects product/categoryID in the url for the service
Imports System.ServiceModel
Imports System.ServiceModel.Web
<ServiceContract()> _
Public Interface IService1
<OperationContract()> _
<WebGet(UriTemplate:="Product/{categoryID}", ResponseFormat:=WebMessageFormat.Xml, BodyStyle:=WebMessageBodyStyle.Bare)> _
Function GetProducts(ByVal categoryId As String) As List(Of Products)
End Interface
In the service we need to set the AspNetCompatibilityMode and write some code to return the products
Imports System.ServiceModel.Activation
<AspNetCompatibilityRequirements(RequirementsMode:=AspNetCompatibilityRequirementsMode.Allowed)> _
Public Class Service1
Implements IService1
Public Function GetProducts(ByVal categoryId As String) As System.Collections.Generic.List(Of Products) Implements IService1.GetProducts
Dim dc As New NorthwindEntities
Dim q = From p In dc.Products Select p Where p.CategoryID = CInt(categoryId)
Return q.ToList
End Function
End Class
To call the service you would use a url like http://localhost:2050/Service1.svc/Product/7
you will get an xml file like this returned
Tuesday, March 24, 2009
Microsoft released IE8 during Mix 2009. Microsoft spent a lot of time making IE8 comply with the browser standards. When you upgrade your browser to IE8 if you find the web site does not render right. Do not worry there is a simple fix for this.
There is a tag you can place in the Head section of your webpage which will force IE8 into IE7 compatibility mode.
<html>
<head>
<!-- Mimic Internet Explorer 7 -->
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<title>My Web Page</title>
</head>
For more info on IE8 compatibility read this article
http://msdn.microsoft.com/en-us/library/cc288325(VS.85).aspx
Hope this helps
Wednesday, February 25, 2009
Next Orlando DNN User Group meeting
Speaker: Chris Hammond
Topic: Scenario based usage of the new features in DotNetNuke 5.0
When: Thursday, March 5th @ 7:00-9:00 PM
Where: ABC Fine Wine & Spirits, Inc. Corporate Office
Address: 8989 South Orange Ave., Orlando, FL 32824
Live Map: http://maps.live.com/default.aspx?v=2&FORM=LMLTCP&cp=28.437205~-81.366381&style=r&lvl=15&tilt=-90&dir=0&alt=-1000&phx=0&phy=0&phscl=1&where1=8989%20South%20orange%20avenue%2C%20orlando%2C%20florida&encType=1
Description: There has been a lot of talk about new features and functionality in DotNetNuke 5.0, but it is not always easy to understand how these new features may apply to your website. This session will cover a wide variety of the new features, and how they apply directly to various scenarios for DNN based websites. See the new features as they were meant to be used.
About The Speaker: Chris Hammond (DotNetNuke Core Team Member), VP of Training Services at Engage Software in St. Louis, MO
Speaker Bio: Chris Hammond is a Technical Evangelist with Engage Software (www.engagesoftware.com) in St. Louis, Missouri. Chris has worked with DotNetNuke (DNN) since its inception and been a DNN Core Team member for nearly five years. Solidifying his role within the DNN community as a leading expert and evangelist on the platform Chris has been a frequent presenter at conferences, user groups and companies around the world. Chris started the St. Louis DNN User Group (www.dnnug.com), and provides tips and tricks through his blogs at DotNetNuke.com and EngageSoftware.com. He is also an active DNN Community member, providing support in the DNN Forums. You can read more about Chris on his personal blog at www.chrishammond.com.
URL: http://orlando.dotnetnukeug.net/WhatsNew/Events/tabid/91/ctl/Details/Mid/428/ItemID/18/Default.aspx?selecteddate=3/5/2009
Saturday, February 21, 2009
This week Microsoft Release an GDR to silverlight 2 which included some minor fixes.
Here is a list of the main changes in the GDR (build 2.0.40115.0):
- Fixes problems that were caused by Silverlight and McAfee scanning tools interactions
- UI automation stability fixes, including:
- graceful failures when attempting to use features that require .NET
Framework 3.0 or 3.5 on machines that do not have either framework
installed
- improved Tablet support
- Fixes an issue that arises when Mac users customize their environment by removing Arial and Verdana fonts
- Fixes a known issue with Isolated Storage IncreaseQuotaTo method (see this post for more information)
The one fix which bothered me a lot is the graceful failures when attempting to use features that require .Net framework 3.0 or 3.5 on machines that do that nave either framework installed. Silverlight 2 has its own version of the .net framework why should it use .net 3.0 or 3.5 and of course the .net framework is not available for the mac. Well after looking around some I found this in the comments on Tim Sneath's Blog
" apologies - we could probably be clearer here on what this
means. Essentially, this was a bug that could be triggered in certain
situations where you were using the accessibility tools (e.g.
magnifier) on Silverlight content on a machine without .NET Framework
installed. In short, the bug was an accidental dependency that has now
been removed." - Tim Sneath
http://blogs.msdn.com/tims/archive/2009/02/18/silverlight-2-gdr1-now-available.aspx
For More info on the Update please check out Tim Heuer's Blog entry
http://timheuer.com/blog/archive/2009/02/19/silverlight-2-gets-minor-update-gdr1.aspx