You are on page 1of 11

16.

 What is .xap file?

A .xap file is a Silverlight-based application package (.xap) that is generated when the
Silverlight project is built. .xap file is the compressed output file for the Silverlight
application. The .xap file includes: AppManifest.xaml

Compiled output assembly of the Silverlight project (.dll)

Resource files referred by the Silverlight application

Web pages like .aspx files and .html files use the Silverlight components by loading the .xap
files using the <object> tag in the HTML or by using <asp:Silverlight> tag in the ASP.NET
pages.

".xap" files (pronounced "zap") use the standard .zip compression algorithm to minimize
client download size. 

Rename this file to SilverlightTest.zip and open it using any decompression tool. You can
see that this is just like any other zip file and it includes the projects output dll and another
file called "AppManifest.xaml".

17. How does XAP work? 

Once you have created the .xap file (explained below), the Silverlight 2 plug-in downloads
the file and runs it in a separate work space.

19. Can we add the reference of a Class library project in Silverlight application


project?

No, you can't add the reference of a Class library inside the Silverlight application project.
You can only add the reference of another Silverlight application project inside a Silverlight
application project. 

However, you can add the reference of a Web Service or WCF services.

20. What is Silverlight.js file?

Silverlight.js is a helper file which enables Web sites to create advanced Silverlight
installation and instantiation experiences. You can call the createObject and createObjectEx
functions defined in this file to embed the Silverlight plug-in in a Web page. 

21. What is the use of ClientBin folder?

ClientBin folder is used to place the .xap file of Silverlight application. You can keep this
anywhere in your web application but this is the default that is used by the Silverlight.

22. How to change the default page of the Silverlight application?

To change the default page of Silverlight application, you need to set the RootVisual
property inside the Application_Startup even of App.xaml file. 

private void Application_Startup(object sender, StartupEventArgs e)


{
this.RootVisual = new MainPage();
}

23. What is XAML?

XAML stands for eXtended Application Markup Language. XAML contain XML that is used to
declaratively specify the user interface for Silverlight or WPF applications.

For example, if you need to display a rectangle, this is the XAML you need to use:

<UserControl x:Class="SilverlightApplication1.SilverlightControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="400" Height="300">
<Canvas Width="500" Height="500" Background="White">
<Rectangle Canvas.Left="75" Canvas.Top="90" Fill="red" Width="100"
Height="100" />
</Canvas> 
</UserControl>  

When the above XAML is executed, it will display a rectangle filled with red color.

You may notice is that XAML is very similar to HTML in nature.  

XAML stands for eXtensible Application Markup Language is the declarative markup
language follows the XML rule and is used for developing User Interface in WPF and
Silverlight technology. XAML files are XML files that generally have the .xaml extension and
then separate the UI definition from the run-time logic by using code-behind files, joined to
the markup through partial class definitions.

XAML has a set of rules that map object elements into classes or structures, attributes into
properties or events, and XML namespaces to CLR namespaces. XAML elements map to
Microsoft .NET types as defined in referenced assemblies, and the attributes map to
members of those types.

24. What is AppManifest.xml file?

First let's look at an example AppManifest.xaml file: 

<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
EntryPointAssembly="SilverlightApplication1" EntryPointType="SilverlightApplication1.App"
RuntimeVersion="2.0.30226.2">
  <Deployment.Parts>

    <AssemblyPart x:Name="SilverlightApplication1" Source="SilverlightApplication1.dll" />

    <AssemblyPart x:Name="System.Windows.Controls"
Source="System.Windows.Controls.dll" />

    <AssemblyPart x:Name="System.Windows.Controls.Extended"
Source="System.Windows.Controls.Extended.dll" />

  </Deployment.Parts>

</Deploymnt>

The first element in the AppManifest.xaml is a Deployment node. This node defines the
application and contains child AssemblyPart nodes. 

As you can see the AssemblyPart nodes define what assemblies (DLLs) are contained within
the .xap file, and give each of them a name. 

Now, if you look back up to the top, you'll see the Deployment node has EntryPointAssembly
and EntryPointType attributes. The EntryPointAssembly attribute defines which assembly
defined below (as a child AssemblyPart node) is the main assembly (DLL) for the
application. And, the EntryPointType attribute specifies the Class contained within the
assembly (DLL), defined in the EntryPointAssembly attribute, is the main class that will be
instantiated to start the application. 
The Deployment node also has a RuntimeVersion attribute that defines the version of
Silverlight the application is built for. 

25. What files are contained within the .xap file? 

The .xap file contains an application manifest (AppManifest.xaml) file and all the necessary
DLL's that are required by the application. The first DLL contained is the compiled version of
you application and has the same name of your application. In my test I created an
application names "SilverlightApplication1", so the DLL is named
"SilverlightApplication1.dll". The rest of the DLL's are the dependancies the application
requires. 

26. What is app.xaml?
 
App.xaml is a file used by Silverlight applications to declare shared resources like brushes,
various style objects, templates etc. Also, the code behind file of app.xaml.cs is used to
handle global application level events like Application_Startup, Application_Exit and
Application_UnhandledException. (Similar to Global.asax file for ASP.NET applications)

When Visual Studio creates the app.xaml file automatically, it creates few event handlers
with some default code. You can change the code appropriately.
 
private void Application_Startup(object sender, StartupEventArgs e)
{
}
private void Application_Exit(object sender, EventArgs e)
{
}

private void Application_UnhandledException(object sender,


ApplicationUnhandledExceptionEventArgs e)
{
}

For ASP.NET developers, the above code will look familiar. This is similar to the application
level event handlers in Global.asax

27. What is the Silverlight official name?

Silverlight was formerly code-named "WPF/E."

28. What are the main features and benefits of Silverlight?

 Compelling cross-platform user experiences.


 Flexible Programming Model with Collaboration Tools.
 High-quality media, low-cost delivery.
 Connected to data, servers, and services.

29. What is MainPage.xaml?

When you create a Silverlight project using Visual Studio, it creates a default xaml file called
"MainPage.xaml". This is just a dummy start page created by Visual Studio and it does not
contain any visible UI elements. The default content of the MainPage.xaml file looks like
this: 

<UserControl x:Class="SilverlightApplication1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="400" Height="300">
<Grid x:Name="LayoutRoot" Background="White">
</Grid>
</UserControl>

30. Which language is Silverlight developed in?

It was developed using a combination of C# and C++.

31. Can I consume WCF and ASP.NET Web Services in Silverlight?

Yes, you can.

32. What are Deep Zoom and Deep Zoom Composer?

Deep Zoom provides the ability to interactively view high-resolution images in Silverlight.
You can zoom in and out of images rapidly without affecting the performance of your
application.
Deep Zoom provides smooth in-place zooming and panning.

DeepZoom Composer allows you to create high resolution image compositions, which are
built for smooth Zooming and Panning. DeepZoom composer is absolutely free and is simple
to use, just load in all your high resolution images and makes your composition on screen. 

Deep Zoom Composer is a tool that allows preparing of images for use with the Deep Zoom
feature in Silverlight 3.

33. What is the difference between WPF and Silverlight? 

Silverlight and Windows Presentation Foundation (WPF) are 2 different products from
Microsoft, but have lot of overlap. Silverlight is a sub set of WPF in terms of features and
functionality.

Silverlight is a Microsoft technology, competing with Adobes Flash and is meant for
developing rich browser based internet applications.

WPF is a Microsoft technology meant for developing enhanced graphics applications for
desktop platform. In addition, WPF applications can be hosted on web browsers which offer
rich graphics features for web applications. Web Browser Applications (WBA) developed on
WPF technology uses XAML to host user interface for browser applications. XAML stands for
eXtended Application Markup Language which is a new declarative programming model from
Microsoft. XAML files are hosted as discrete files in the Web server, but are downloaded to
the browsers and converted to user interface by the .NET runtime in the client browsers.

WPF runs on .NET runtime and developers can take advantage of the rich .NET Framework
and WPF libraries to build really cool windows applications. WPF supports 3-D graphics,
complex animations, hardware acceleration etc. 

Silverlight uses a particular implementation of a XAML parser, with that parser being part of
the Silverlight core install. In some cases, the parsing behavior differs from the parsing
behavior in Windows Presentation Foundation (WPF), which also has a particular
implementation.

34. What is the difference between Silverlight and Flash?

Adobe Flash is the most popular competitor to Silverlight both supports browser plug-in and
enables execution of rich content for the Web. Flash is not the new technology, which is
already having long life span as compared to Silverlight. But it does not have huge
community as expected; it may be cause of limited development tools, which are not kwon
to most of the developers.  Flash uses ActionScript as programming language and Flex as
programming environment, which most of the developer are far from these technologies.

For ASP.NET developers to extend their websites using flash content is not so simples, they
need to learning development environment as mentioned above like ActionScript and Flex,
apart from that there is no way to generate Flash content using server-side .NET code,
which means it's difficult to integrate ASP.NET content and Flash content
Silverlight aims to give .NET developers a better option for creating rich web content.
Silverlight provides a browser plug-in with many similar features to Flash, but one that's
designed from the ground up for .NET. Silverlight natively supports the C# language and
uses a range of .NET concepts. As a result, developers can write client-side code for
Silverlight in the same language they use for server-side code (such as C# and VB), and
use many of the same abstractions (including streams, controls, collections, generics, and
LINQ).

35. What is the difference between Silverlight and ASP.NET AJAX?

Microsoft ASP.NET AJAX, a set of JavaScript libraries built into ASP.NET 3.5, is available as a
separate download for ASP.NET 2.0. Being an integral part of ASP.NET 3.5 and the AJAX
Controls Toolkit for ASP.NET 3.5, now ASP.NET AJAX client-and server-side libraries are
more integrated with Visual Studio 2008. The client-side library allows you to implement
client-level processing such as processing and validating information entered by the end
user, refreshing a portion of the web page, and developing rich, interactive user interfaces.
You can also efficiently integrate the client-side library components with the server-side
ASP.NET controls library in asynchronous mode. The key technology driver of ASP.NET AJAX
is scripting. In general, script-based web applications face several challenges due to
different browser settings (e.g., JavaScript is not enabled by default) on PCs and mobile
devices. As a result, scripting is often not always the best strategy for enterprises to use to
develop secured and scalable RIAs.

ASP.NET AJAX also supports limited features of RIAs and does not support effective
multimedia integration, managed code-behind integration, or metadata and information
management. Microsoft ASP.NET AJAX is a widely accepted model for building RIAs, but it is
very likely that, having Silverlight as an option, .NET developers will migrate ASP.NET AJAX
applications to Silverlight RIAs. Visit www.asp.net/ajax/ if you want to learn more about
Microsoft ASP.NET AJAX.

36. What are the different Layout controls available in Silverlight Application?

There are 3 different types of layout controls provided by Silverlight 

 Canvas - Position child elements absolutely in x,y space.


 StackPanel - Position child elements relative to one another in horizontal or vertical
stacks.
 Grid - Position child elements in rows and columns. 

You have to add a layout panel to every xaml page we create. All other UI elements must
be added inside one of the layout panels. Each page can have exactly one layout panel
control.

37. Are XAML file compiled or built on runtime?

XAML files are usually compiled rather than parsing on runtime. But it also supports parsing
during runtime. When we build a XAML based project, you will see it creates g.cs extension
in obi\Debug folder. Therefore, for every XAMl file you will find a g.cs file. For instance, a
MainPage.XAML will have MainPage.g.cs file in obi\Debug folder. In short, in runtime you
actually do not see the XAML file. But if you want to do runtime, parsing of XAML file it also
allows that to be done.

38. What is the long-term goal or vision for Silverlight?


 Microsoft Silverlight is a cross-browser, cross-platform, and cross-device plug-in for
delivering the next generation of .NET based media experiences and rich interactive
applications for the Web. 
 Silverlight offers a flexible programming model that supports AJAX, VB, C#,
IronPython, and IronRuby, and integrates with existing Web applications. 
 By using Expression Studio and Visual Studio, designers and developers can
collaborate more effectively using the skills they have today to light up the Web of
tomorrow. 
 By leveraging Silverlight's support for .NET, High Definition video, cost-effective
advanced streaming, unparalleled high-resolution interactivity with Deep Zoom
technology, and controls, businesses can reach out to new markets across the Web,
desktop, and devices.

39. Do I need to have the .NET Framework installed in order to use Silverlight?

The answer to this is no - a cross platform version of the .NET Framework is included in the
6 MB Silverlight 4 download, which means you do not need to have anything extra installed
on the client in order to access Silverlight application in the browser.  

The Silverlight version of the .NET framework includes the same CLR engine (same GC,
type-system, JIT engine) that ships with the full .NET Framework, and a subset of the .NET
Framework namespace libraries.  You can see the full list of all classes/namespaces that are
included by opening up the Object Browser when you create a new Silverlight application
using Visual Studio.

40. What are the other RIA technologies besides Silverlight?

Adobe Flex, Java FX, Adobe Flash are some of the other RIA technologies besides
Silverlight.

41. What is meant by RIA?

RIA stands for Rich Internet Applications which are Web applications with rich user
interfaces including media elements such as audio, video etc. You can think of them as
being similar to powerful and rich desktop applications except that RIA applications are Web
based.

42. What is .NET RIA Services?

Microsoft .NET RIA Services helps to simplify the n-tier application pattern by combining the
ASP.NET and Silverlight platforms. The RIA Services provides a pattern using which you can
write application logic that can run on the mid-tier and controls access to data for queries,
changes and custom operations. It also provides support for data validation, authentication
and roles by integrating with Silverlight components on the client and ASP.NET on the
middle tier.

43. What are the design files and the code-behind files in Silverlight?

The user interface elements of Silverlight applications are defined in XAML files. The logic
and functionality of Silverlight applications is implemented using managed NET code-behind
files that share the same class with the XAML file.

44. Who is using Silverlight?


Yahoo! Japan, NBC, Continental Airlines, NASA, Indian Premier League (yes, our very own
IPL), and National Instruments are some of the organizations currently using Silverlight to
enhance their businesses

45. What features are missing from Silverlight presentation markup that will be
supported in WPF?

Some high-end Windows specific features of WPF, such as real 3D, hardware-based video
acceleration, and full document support, will not be supported in Silverlight. This is by
design in order to serve Silverlight's cross-browser, cross-platform reach scenario that
demands a light weight plug-in. That being said, Silverlight will offer a uniform runtime that
can render identical experiences across browsers on both Mac OS and Windows.

46. Will I need more memory, a faster processor, or a better Graphics Processing


Unit (GPU)?

Microsoft designed Silverlight with the ability to deliver high-fidelity experiences on the
broadest set of system configurations. Some features, such as HD video, may benefit from
the power contained in newer personal computers.

47. How does Silverlight make the Microsoft development system better?

Silverlight is a cross-browser, cross-platform plug-in for delivering the next generation of


media experiences and rich interactive applications (RIAs) for the Web.

Examples include:

 For ASP.NET-based Web applications, Silverlight provides a rich UI front-end that,


with a consistent programming model, adds support for richer interactivity, media,
and audio.
 For Microsoft SharePoint-based content, Silverlight offers the ability to create rich
Web parts.

For Windows Live services, Silverlight offers the ability to consume services and APIs more
effectively.

48. What is the relationship and difference between Silverlight and ASP.NET? 

Technically, Silverlight and ASP.NET are completely different.  The major differences are
listed below:

 Silverlight runs completely on the client, while ASP.NET mainly runs on the server,
but also has a few parts running on the client.
 When an event fires, Silverlight handles the event on the client, but in ASP.NET, the
browser will make an HTTP POST to the server, and after the server handles the
request, it sends a new html page to the client.
 A Silverlight application sends rendering commands to the Silverlight rendering
engine by either write XAML or code, and the Silverlight rendering engine will handle
the rendering task. On the other hand, ASP.NET doesn't have a rendering engine. It
generates an html file on the server, sends it to the client, and allows the browser to
parse the html file and render the content.
 Silverlight can't work with a database directly; instead it consumes data from web
services, while ASP.NET has strong support in working with database directly.

The most important fact to remember is what runs on the client, and what runs on the
server, since this will affect almost every part of your system. Silverlight runs on the client,
and ASP.NET runs on the server. They can work together and are compatible with each
other, but this requires some time and effort.

49. When to use Silverlight, ASP.NET or both?

This depends on different scenarios.  Below are some common approaches:

 Pure Silverlight.
One approach is to completely remove ASP.NET, this solution works best if you're
working on a new development. You only need to work on Silverlight, without any
worry about integration problems. If you need to communicate with the server, you
write web services, such as WCF. It will also help you when you need to port part of
or the whole of your system to other hosting or even other platforms, since the client
and the server are completely separate.
 Major ASP.NET plus a Silverlight island.
This approach is generally used when the Silverlight content and the ASP.NET
content have little relationship. For example, an ASP.NET blog engine with a
Silverlight media player in a blog post. This approach is very easy to implement, and
allows you to reach the broadest audience. For example, if a user hasn't installed
Silverlight, he can still read the blog posts, but he can't watch the videos.
 Use ASP.NET AJAX instead of Silverlight
ASP.NET AJAX is designed to work with ASP.NET. It is mainly an extension to
ASP.NET. While AJAX can't provide you the advance user experience that Silverlight
can, for many scenarios, it should be sufficient. This approach also helps if you have
strong ASP.NET experience, but are still quite new to Silverlight.

Within this approach, there are two branches. One is to mix the client and server
code by using UpdatePanel, AJAX Control Toolkit, and etc.  The other method is to
take the pure AJAX approach, where you write html and JavaScript instead of using
Server Controls, and call web services to communicate with the server. The former
branch is easier to implement, especially if you have strong ASP.NET experience, but
lack JavaScript knowledge. The latter branch proves to be better in architecture
when you want to port the AJAX application to other technologies such as Silverlight.
Especially since you only need to rewrite the client side code, and can keep the web
services as they are. The programming model for the later branch is similar to
Silverlight. Therefore, this approach is rarely taken if you're experienced in
Silverlight.
 Mix Silverlight with ASP.NET.
More often, you may want to port an existing ASP.NET application to Silverlight, but
you don't want to completely rewrite the entire application. This is the most difficult
approach since you're mixing client side and server side technologies.

Before going with this approach, please consider if the above approaches can solve your
problem. Ask yourself the following questions:

1. Do you really need a rich interactive user experience?    


This is normally a requirement for consumer oriented applications, but for most
business applications, you only need a "good" user experience, which AJAX is
sufficient to provide.
2. Can you add Silverlight islands to your existing ASP.NET application instead of
mixing the contents? 
This should work for most scenarios. For example, Windows Live Mail is built in
ASP.NET, with a few Silverlight islands, such as a slide show program that allows you
to view photo attachments with enhanced experience (actually most Microsoft
created web applications takes this approach).
3. Will this be a good chance to revise your architecture? 
Most traditional ASP.NET applications use the B/S or three tire architecture, in which
the application works with a database either directly, or through a business logic
layer. When porting applications to other platforms, these architectures will introduce
many problems. When investigating Silverlight, it is also a good chance to adopt
SOA. Add a service facade layer on top of the business logic layer, and you can work
with the services from almost any client, such as an ASP.NET application and a
Silverlight application. If you are already on SOA, it should be trivial to port to
Silverlight, since you only need to rewrite a client application. With SOA, the
ASP.NET AJAX approach and the Silverlight island approach will also be much easier
to implement.

If none of the above approaches is suitable, you may have to mix Silverlight content with
ASP.NET. When using this approach, keep in mind that Silverlight can't call ASP.NET server
side event handlers, and each post back (either partial or complete) will cause the
Silverlight application to reload.

C#

Can multiple catch blocks be executed?

System.Array.CopyTo() Vs System.Array.Clone()?

What’s the .net datatype that allows the retrieval of data by a unique key?

What’s class SortedList underneath?

Why is it a bad idea to throw your own exception?

What is a delegate? Multicast delegate?

How do you deploy as assembly?

What's the difference between the Debug class and Trace class?

What are the 2 message encoding formats supported by .NET Remoting and when do
you choose one over the other?

What are the two types of .NET remote objects?

What are the ways in which an object can be serialized?


Can an Interface contain fields?

What is the difference between class inheritance and interface inheritance?

Can an interface inherit from another interface?

Can you create an instance of an interface?

http://venkatcsharpinterview.blogspot.com/

http://venkatcsharpinterview.blogspot.com/2009/01/c-interview-questions.html

You might also like