Showing posts with label silverlight. Show all posts
Showing posts with label silverlight. Show all posts

Friday, October 21, 2011

ServiceReference.ClientConfig build management in Silverlight projects

I’ve blogged a before for web.config transformations and how I would like to see them in other projects. While for Windows Azure cloud service project there is already similar feature implemented, I wonder why there is no out of the box support for other project types.

Here I will reveal the powerful, yet simple implementation of such transformation over your ServiceReferences.ClientConfig files. Thus you will no longer wonder what are your service endpoints, and which endpoint you are using. And this is not Windows Azure specific. It is relevant for any Silverlight project.

Just implement these simple steps:

1. Edit your .csproj file of the Silverlight application. Add the following block:

<UsingTask TaskName="TransformXml"

   
AssemblyFile="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.dll"
/>
   <
Target Name="BeforeBuild"
Condition="exists('ServiceReferences.$(Configuration).ClientConfig')">
     <!--
Generate transformed app config in the intermediate directory –
>    
<
TransformXml Source="ServiceReferences.ClientConfig"
      Destination="$(TargetDir)\ServiceReferences.ClientConfig"
      Transform="ServiceReferences.$(Configuration).ClientConfig"
/>
     <!--
Force build process to use the transformed configuration file from now on. –
>
     <
ItemGroup
>
       <
Content Remove="ServiceReferences.ClientConfig"
/>     
<
ContentWithTargetPath 
Include="$(TargetDir)\ServiceReferences.ClientConfig"
>      
<
TargetPath>ServiceReferences.ClientConfig</TargetPath
>
       </
ContentWithTargetPath
>
     </
ItemGroup
>
   </
Target>

right after:

 <Import 
Project="$(MSBuildExtensionsPath32)\Microsoft\Silverlight\$(SilverlightVersion)\Microsoft.Silverlight.CSharp.targets" />

2. Add new XML file to your project. Name it ServiceReferences.[BuildConfiguration].ClientConfig. Where [BuildConfiguration] can be the name of *any* build configurations you have defined for your project. The default build configurations are “Debug” and “Release”, but you may add as many as you like, to suit your development/testing/staging/live environments. Remember to set “Build Action” to “None”, and “Copy to output directory” to “Never”:



3. Add the required content in that custom file. For example, if you want to just change an endpoint for a service, you will have something like this (ServiceReferences.Debug.ClientConfig):

<?xml version="1.0" encoding="utf-8"?>
<
configuration
  xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"
>
     <
system.serviceModel
>
         <
client
>
             <
endpoint 
address="http://127.0.0.1:81/DummyService.svc"
xdt:Transform="SetAttributes"
/>
         </
client
>
     </
system.serviceModel
>
</
configuration>

For more information on XML transformations supported, please take a look at the MSDN documentation for Web.Config transformations. Do not panic! The documentation is for “web.config” transformations, but these are just XML transformations that can transform any XML file Winking smile

Move Silverlight applications to the Cloud

While moving a typical ASP.NET application to the cloud might require more actions, and would have more “points of break” when moving to the cloud, a Silverlight application is much more amenable to move to the Cloud.

At last Windows Azure User group meeting we covered most common scenarios of Silverlight applications and moved them to Windows Azure. We had a Silverlight application communicating with WCF Services, application that uses WCF RIA services, and application that uses Media services (video player). We moved entire application into the cloud and showed how one can leverage the Windows Azure CDN to achieve better user experience in terms of application load.

Here you can find the source files for the Demos I used: http://bit.ly/okjFNn 

Here you can find the slides: http://bit.ly/nugWoP

The TCP Server I used for the demos is based on “A very basic TCP Server written in C#” article in CodeProject. Second TCP demo (SilverCloudBase_05_Sockets_Adv) is a bit edited version of that server, to support message broadcasting to all connected clients.

The session recording will be available soon, so stay tuned!

Thursday, March 24, 2011

Retrospective

Looking back in 2010 when I was a technical evangelist for Infragistics I can’t say that I regret for anything. Evangelism is not a job. Evangelism is belief! That’s my honest opinion. I was evangelist before I stepped officially into that role, and I continue to be evangelist now. I’m inspired by a presentation from Guy Kawasaki (The Art of the Start – a great session by the way, worth watching the full presentation!), where he states something like “You don’t hire evangelists, they find you”. You can read more of his great posts on his blog.

So, back to the subject, one of the projects I was involved in 2010 was the new MyWorldMaps reporting site. We went through a lot of changes during technical implementantion, but in the end it became a really neat Silverlight 4 application, that uses MVVM, Azure (my passion) and of course the amazing DataVisualistion suite from Infragistics.  I can only be proud to have been part of it. And now I see it is so liked by the original requester Brian Hitney from Microsoft.

I formed maybe the toughest part of it – Distribution Stats. It is based on the Motion Framework (officially announced here), which on the other hand is a result of hard working DataVisualization team. This type of statistics shows you multidimensional data. How many is multi? 4! Yes, four dimensions! X-axis will show you cumulative hits for given browser/region. The Y-axis shows you percentage each item occupy based on the total hits cumulated. Third dimension is obvious – time (data changes over time). And finally change in size of a bubble represents relative change of hits for given time point over the previous.  It is so great to see that it finally went LIVE. Good work all, and thanks Infragistics!

Tuesday, April 6, 2010

Solution to Silverlight Design Time issues in a Windows Azure Cloud Service

I just want to share a blog post from Azure team, where they reveal how to deal with bunch of irritating issues that one would have if developing Silverlight based application for the cloud. You can read the full story here: http://blogs.msdn.com/jnak/archive/2010/03/23/fixing-the-silverlight-design-time-in-a-windows-azure-cloud-service.aspx

Monday, January 25, 2010

Jason Beres to speak in Sofia on Visual Studio 2010 and .NET 4

Next week we will be a host for an amazing session. It will be held on 2nd of February 2010 at Elieff Center for Education and Culture, 1 University Park str., Studentski grad 1700, Sofia.

“Building Better Experiences using Visual Studio 2010 and .NET 4”

As Visual Studio 2010 is right around the corner, and it's a completely new IDE based on WPF, chock full of exciting new features and productivity enhancers. So now is a great time to figure out the answers to these 2 key questions:
  • What's in Visual Studio 2010 and .NET 4 for me?
  • What is going to take to learn all of this?
In this talk, Jason will answer those questions. You'll get an understanding of the full run down of new features in Visual Studio 2010, including the new testing and debugging features, new data options, new deployment scenarios, new code editor features and many other new time savers and coding enhancers. You'll also get an understanding of new language features in Visual Basic and C#, as well as the new support for the F# language and the new project support for Silverlight 4, Windows Azure, SharePoint and Microsoft Office applications. At the conclusion of this talk, you'll know exactly why you need Visual Studio 2010 and .NET 4, and how they will improve your coding experience and capabilities to build even better software in 2010 and beyond!
Jason Beres is the VP of Product Management for Infragistics, the world leader in user interface development tools and experts in the User Experience (UX) market. Jason is a founder of Florida .NET User Groups, he is the founder of the Central New Jersey .NET User Group, he is a Microsoft MVP, and he is on the INETA Speakers Bureau. Jason is the author of several books on .NET development, including the recently published Silverlight 3 Programmers Reference from Wrox Press and the upcoming Silverlight 4 Professional from Wrox Press. Jason is a national and international conference speaker; he is a frequent columnist for several .NET publications, and keeps very active in the .NET community.
Expected duration of the lecture is about 1.5 hours and there will be catering party, excellent for networking after it.
See you there!

Friday, March 7, 2008

First impression on Silverlight 2.0

As I told there is a fresh new build of Silverlight - Silverlight 2.0. Happy to hear that I downloaded and install ....

Now what - cannot open the old Silverlight 1.1 projects. The VS gives the following error:
The imported project "C:\Program Files\MSBuild\Microsoft\VisualStudio\v9.0\Silverlight\Microsoft.Silverlight.CSharp.targets" was not found. Confirm that the path in the <Import> declaration is correct and that the file exists on the disk

The hint/solution is here: http://silverlight.net/forums/p/10762/34264.aspx and it appears that we, as developers should not be afraid to edit the .csproj files - why should we ?

Just curious - if I am forced to uninstall any previous versions of Silverlight along with SDKs and VS tools (it is a prerequisite and the installation does not continue until you install them), why then the new Silverlight is put into new folder and there is no automatic backward compatibility.

Looking forward for the next release :)

cheers,
Anton

Saturday, June 16, 2007

More Silverlight

You can view the working example of Hello World with MouseEventHandler here:
http://staykov.net/silverlight/TestPage.html
The XAML file is here:
http://staykov.net/silverlight/Page.xaml
(But I think you will have problems to open it with IE, so just try with Mozilla)
What I like is, that you do not any special hosting to publish silverlight app ;) (well, the Hello World one ;) )
Also, good to mention - if you seek for design time support of silverlight app you must go for Microsoft Expression Blend 2 May 2007 Preview - the only one so-far IDE which supports design-time editing for SilverLight.
Looking forward to see you again!

User Interaction with Silverlight

Let's do a simple user interaction with silverlight.

I will take the example code from the previous post and add some extra attributes to the TextBlock Elements:


I have added the "x:Name" attribute, which will identify the textBlock in the code-behind file.

And also I have set the style of the cursor. I personally think that when there is some interaction with user, one should be reminded for that!

The next is simple MouseEventHandler in the code-behind file:


A simple "state" remembering variable and we are changing the text of the text block every time the user clicks on it.

Hello World with Silverlight

OK, let's begin with the hello world! :)
All we need to do (after installing the Silverlight tools for Orcas and Silverlight 1.1 Alpha) is to create a new project "C# -> Silverlight project".
The project template will create for us several files:

1. Page.xaml
1.1. Page.xaml.cs
2. Silverlight.js
3. TestPage.html
3.1. TestPage.html.js

The first one - Silverlight.js is Javascript required for the silverlight client.
Page.xaml is the Silverlight canvas itself - the project that we will work with.
TestPage.html is the HTML client page that will host our Silverlight control.

Let's go deep into it.
The Page.xaml. XAML stands for eXtensible Application Markup Language, and is pronounced "Zammel", was introduced with Microsoft.NET Framework 3.0 as the User Interface definition language for the next generation of applications. It is a normal XML file, and can be edited with any text-editing tool (we will use better than text editing). The empty project file will look like this:



That's right - we have Page.xaml.cs and this is the "code-behind" file.

Well, we can simply add one TextBlock element to this canvas:

^textblock color="#cc0000">Text="Hello World" FontSize="15" FontWeight="Bold" />

So at finally we have the following XAML code:


See you later on.

Getting Started with Silverlight

There is an old Chinese curse saying "May you live in interesting times" (if you are interested go here). I think the are of Internet is really interesting time ... what will happen next ?
Silverlight the new product of Microsoft, that I think will blow away the FLASH, but it will take some time, of course.
In order to be fully equipped for creating silverlight projects you must have the VS Codename Orcas Beta 1, Silverlight 1.1 Alpha, and Microsoft Silverlight Tools Alpha for Visual Studio codename “Orcas” Beta 1.
At first I tried witht he tools, but had only the Silverlight 1.0 Beta ;) No success ;)
After some puzzling I finally understood that I must install the 1.1 Alpha in order to begin develop Silverlight applications with VS Codename Orcas.
Well, there is also a way to develop Silverlight application with VS 2005 and you can find more info here.
I hope to begin a series of SilverLight articles.
Looking forward for the next ;)