SharpDevelop Community

Get your problems solved!
Welcome to SharpDevelop Community Sign in | Join | Help
in Search

Using Silverlight SDK 4

Last post 05-07-2012 2:01 PM by gdorigo. 10 replies.
Page 1 of 1 (11 items)
Sort Posts: Previous Next
  • 08-30-2010 6:48 PM

    • MKX
    • Top 500 Contributor
    • Joined on 08-30-2010
    • Posts 11

    Using Silverlight SDK 4

    Hello dear developers,
    Im currently using SD4(Beta2) and obviously I just can create a Silverlight-Project using Silverlight SDK 3.
    Will it be possible using Silverlight SDK 4 in RTW-Version?
    Thanks much in forward
    Martin

    Edit: I took a closer look at the SilverlightApplication.xpt - File of Ivan Shumilin. Is it correct that I just need to edit this file (or write a new one) to target Silverlight 4?

  • 08-31-2010 11:22 AM In reply to

    Re: Using Silverlight SDK 4

    Yes that should probably be enough to get SharpDevelop to target Silverlight 4. The <TargetFrameworkVersion> would need to change to 4.0 and the $(MSBuildExtensionsPath)\Microsoft\Silverlight\v3.0\Microsoft.Silverlight.CSharp.targets will probably need to change to point to the v4.0 Silverlight targets file.

  • 08-31-2010 2:35 PM In reply to

    • MKX
    • Top 500 Contributor
    • Joined on 08-30-2010
    • Posts 11

    Re: Using Silverlight SDK 4

    Thanks much for your answer, Matt.
    So far all is fine, and I changed the template for use with SDK 4.
    Still I have with both versions a big problem: They compile fine and produce also a Testpage and a .xap-file, but the Silverlight-Output is allways just a white area (as if I wouldnt change anything in MainPage.xaml). Even just changing the color of the Grid or drawing a simple Rectangle doesnt work.
    I know, thats not much info, but has somebody an idea (what I do wrong or what is missing)?
    Martin

  • 08-31-2010 5:01 PM In reply to

    Re: Using Silverlight SDK 4

    There seems to be a problem with the template. I get the same results as you do. The generated project does not seem to work. Looking at a project created with Visual Studio they are slightly different, but it is not immediately obvious why one works and the other does not.

  • 08-31-2010 5:36 PM In reply to

    • MKX
    • Top 500 Contributor
    • Joined on 08-30-2010
    • Posts 11

    Re: Using Silverlight SDK 4

    Thank you, Matt.
    Maybe somebody can see the mistake below, its the template for SDK4, I also formatted the "original" for SDK3 a bit, but the mistake should be the same.

     

    <Template originator = "Martin" created = "31/08/2010">

        <!-- Template Header -->
        <TemplateConfiguration>
            <Name>Silverlight 4 Application</Name>
            <Category>C#</Category>
            <Subcategory>Silverlight</Subcategory>
            <Icon>C#.Project.Form</Icon>
            <Description>Standard Silverlight 4 Application</Description>
        </TemplateConfiguration>
       
        <!-- Actions -->
        <Actions>
            <Open filename = "MainPage.xaml"/>
        </Actions>
       
        <Project language = "C#">
           
            <ProjectItems>
                <Reference Include="mscorlib"/>
                <Reference Include="System"/>
                <Reference Include="System.Windows"/>
                <Reference Include="System.Core"/>
                <Reference Include="System.Net"/>
                <Reference Include="System.Xml"/>
                <Reference Include="System.Windows.Browser"/>
            </ProjectItems>
           
            <PropertyGroup>
                <ProjectTypeGuids>{A1591282-1198-4647-A2B1-27E5FF5F6F3B};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
                <OutputType>Library</OutputType>
                <AppDesignerFolder>Properties</AppDesignerFolder>
                <RootNamespace>${StandardNamespace}</RootNamespace>
                <AssemblyName>${StandardNamespace}</AssemblyName>
                <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
                <SilverlightApplication>true</SilverlightApplication>
                <SupportedCultures>
                </SupportedCultures>
                <XapOutputs>true</XapOutputs>
                <GenerateSilverlightManifest>true</GenerateSilverlightManifest>
                <XapFilename>${StandardNamespace}.xap</XapFilename>
                <SilverlightManifestTemplate>Properties\AppManifest.xml</SilverlightManifestTemplate>
                <SilverlightAppEntry>${StandardNamespace}.App</SilverlightAppEntry>
                <TestPageFileName>TestPage.html</TestPageFileName>
                <CreateTestPage>true</CreateTestPage>
                <ValidateXaml>true</ValidateXaml>
                <UsePlatformExtensions>false</UsePlatformExtensions>
                <ThrowErrorsInValidation>true</ThrowErrorsInValidation>           
                <NoStdLib>true</NoStdLib>
                <NoConfig>true</NoConfig>           
            </PropertyGroup>
           
            <PropertyGroup configuration="Debug" escapeValue="false">
                <DefineConstants>DEBUG;TRACE;SILVERLIGHT</DefineConstants>
            </PropertyGroup>
           
            <PropertyGroup configuration="Release" escapeValue="false">
                <DefineConstants>TRACE;SILVERLIGHT</DefineConstants>
            </PropertyGroup>
           
            <Imports clear="True">
                <Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight\v4.0\Microsoft.Silverlight.CSharp.targets"/>
            </Imports>       
           
            <Files>
           
            <File name="App.xaml" buildAction="ApplicationDefinition" language="XML">
    <![CDATA[<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 x:Class="${StandardNamespace}.App">  
        <Application.Resources>
           
        </Application.Resources>
    </Application>]]>
            </File>

            <File name="App.xaml.cs" SubType="Code" DependentUpon="App.xaml">
    <![CDATA[using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;

    namespace ${StandardNamespace}
    {
        public partial class App : Application
        {
            public App()
            {
                this.Startup += this.Application_Startup;
                this.Exit += this.Application_Exit;
                this.UnhandledException += this.Application_UnhandledException;

                InitializeComponent();
            }

            private void Application_Startup(object sender, StartupEventArgs e)
            {
                this.RootVisual = new MainPage();
            }

            private void Application_Exit(object sender, EventArgs e)
            {

            }
           
            private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
            {
                // If the app is running outside of the debugger then report the exception using
                // the browser's exception mechanism. On IE this will display it a yellow alert
                // icon in the status bar and Firefox will display a script error.
                if (!System.Diagnostics.Debugger.IsAttached) {

                    // NOTE: This will allow the application to continue running after an exception has been thrown
                    // but not handled.
                    // For production applications this error handling should be replaced with something that will
                    // report the error to the website and stop the application.
                    e.Handled = true;
                    Deployment.Current.Dispatcher.BeginInvoke(delegate { ReportErrorToDOM(e); });
                }
            }
           
            private void ReportErrorToDOM(ApplicationUnhandledExceptionEventArgs e)
            {
                try {
                    string errorMsg = e.ExceptionObject.Message + e.ExceptionObject.StackTrace;
                    errorMsg = errorMsg.Replace('"', '\'').Replace(" ", @" ");

                    System.Windows.Browser.HtmlPage.Window.Eval("throw new Error(\"Unhandled Error in Silverlight Application " + errorMsg + "\");");
                }
                catch (Exception) {
                }
            }
        }
    }]]>
            </File>
           
            <File name="MainPage.xaml" buildAction="Page" language="XML">
    <![CDATA[<UserControl x:Class="${StandardNamespace}.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>]]>
            </File>
           
            <File name="MainPage.xaml.cs" SubType="Code" DependentUpon="MainPage.xaml">
    <![CDATA[using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;

    namespace ${StandardNamespace}
    {
        public partial class MainPage : UserControl
        {
            public MainPage()
            {
                InitializeComponent();
            }
        }
    }]]>
            </File>
           
            <File name="Properties\AppManifest.xml">
    <![CDATA[<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
        <Deployment.Parts>
        </Deployment.Parts>

        <!-- Uncomment the markup and update the fields below to make your application offline enabled
        <Deployment.ApplicationIdentity>
            <ApplicationIdentity
                ShortName="Out of Browser Silverlight Application"
                Title="Window Title of Your Silverlight Application">
                <ApplicationIdentity.Blurb>Description of your Silverlight application</ApplicationIdentity.Blurb>
            </ApplicationIdentity>
        </Deployment.ApplicationIdentity>
        -->
    </Deployment>]]>
            </File>
           
            <File name="Properties\AssemblyInfo.cs" src="DefaultAssemblyInfo.cs"/>
               
            </Files>
        </Project>
    </Template>

  • 09-01-2010 4:41 PM In reply to

    • MKX
    • Top 500 Contributor
    • Joined on 08-30-2010
    • Posts 11

    Re: Using Silverlight SDK 4

    Finaly I found the solution! :) (after hours of searching)

    The template is ok, but in the Project-Options it targets 32-bit-Processor, and thats what he dislikes. Changing it to AnyProcessor will solve the problem! (How to insert the AnyProcessor-Option to the template?)

    So the final and working Silverlight 4 Template (fresh formatted, but without the Processor)

    <Template originator = "Martin Krainer" created = "01/09/2010">

        <TemplateConfiguration>
            <Name>Silverlight 4 Application</Name>
            <Category>C#</Category>
            <Subcategory>Silverlight</Subcategory>
            <Icon>C#.Project.Form</Icon>
            <Description>Standard Silverlight 4 Application</Description>
        </TemplateConfiguration>

        <Actions>
            <Open filename = "MainPage.xaml"/>
        </Actions>

        <Project language = "C#">

            <ProjectItems>
                <Reference Include="mscorlib"/>
                <Reference Include="System"/>
                <Reference Include="System.Core"/>
                <Reference Include="System.Net"/>
                <Reference Include="System.Windows"/>
                <Reference Include="System.Windows.Browser"/>
                <Reference Include="System.Xml"/>
            </ProjectItems>

            <PropertyGroup>
                <ProjectTypeGuids>{A1591282-1198-4647-A2B1-27E5FF5F6F3B};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
                <OutputType>Library</OutputType>
                <AppDesignerFolder>Properties</AppDesignerFolder>
                <RootNamespace>${StandardNamespace}</RootNamespace>
                <AssemblyName>${StandardNamespace}</AssemblyName>
                <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
                <SilverlightApplication>true</SilverlightApplication>
                <SupportedCultures>
                </SupportedCultures>
                <XapOutputs>true</XapOutputs>
                <GenerateSilverlightManifest>true</GenerateSilverlightManifest>
                <XapFilename>${StandardNamespace}.xap</XapFilename>
                <SilverlightManifestTemplate>Properties\AppManifest.xml</SilverlightManifestTemplate>
                <SilverlightAppEntry>${StandardNamespace}.App</SilverlightAppEntry>
                <TestPageFileName>TestPage.html</TestPageFileName>
                <CreateTestPage>true</CreateTestPage>
                <ValidateXaml>true</ValidateXaml>
                <UsePlatformExtensions>false</UsePlatformExtensions>
                <ThrowErrorsInValidation>true</ThrowErrorsInValidation>   
                <NoStdLib>true</NoStdLib>
                <NoConfig>true</NoConfig>
            </PropertyGroup>

            <PropertyGroup configuration="Debug" escapeValue="false">
                <DefineConstants>DEBUG;TRACE;SILVERLIGHT</DefineConstants>
            </PropertyGroup>

            <PropertyGroup configuration="Release" escapeValue="false">
                <DefineConstants>TRACE;SILVERLIGHT</DefineConstants>
            </PropertyGroup>

            <Imports clear="True">
                <Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight\v4.0\Microsoft.Silverlight.CSharp.targets"/>
            </Imports>

            <Files>
                <File name="App.xaml" buildAction="ApplicationDefinition" language="XML">
    <![CDATA[<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 x:Class="${StandardNamespace}.App">
        <Application.Resources>
        </Application.Resources>
    </Application>]]>
                </File>

                <File name="App.xaml.cs" SubType="Code" DependentUpon="App.xaml">
    <![CDATA[using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;

    namespace ${StandardNamespace}
    {
        public partial class App : Application
        {
            public App()
            {
                this.Startup += this.Application_Startup;
                this.Exit += this.Application_Exit;
                this.UnhandledException += this.Application_UnhandledException;

                this.InitializeComponent();
            }

            private void Application_Startup(object sender, StartupEventArgs e)
            {
                this.RootVisual = new MainPage();
            }

            private void Application_Exit(object sender, EventArgs e)
            {
            }

            private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
            {
                // If the app is running outside of the debugger then report the exception using
                // the browser's exception mechanism. On IE this will display it a yellow alert
                // icon in the status bar and Firefox will display a script error.
                if (!System.Diagnostics.Debugger.IsAttached)
                {
                    // NOTE: This will allow the application to continue running after an exception has been thrown
                    // but not handled.
                    // For production applications this error handling should be replaced with something that will
                    // report the error to the website and stop the application.
                    e.Handled = true;
                    Deployment.Current.Dispatcher.BeginInvoke(delegate { this.ReportErrorToDOM(e); });
                }
            }

            private void ReportErrorToDOM(ApplicationUnhandledExceptionEventArgs e)
            {
                try
                {
                    string errorMsg = e.ExceptionObject.Message + e.ExceptionObject.StackTrace;
                    errorMsg = errorMsg.Replace('"', '\'').Replace(" ", @" ");

                    System.Windows.Browser.HtmlPage.Window.Eval("throw new Error(\"Unhandled Error in Silverlight Application " + errorMsg + "\");");
                }
                catch (Exception)
                {
                }
            }
        }
    }]]>
            </File>
           
            <File name="MainPage.xaml" buildAction="Page" language="XML">
    <![CDATA[<UserControl x:Class="${StandardNamespace}.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>]]>
            </File>
           
            <File name="MainPage.xaml.cs" SubType="Code" DependentUpon="MainPage.xaml">
    <![CDATA[using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;

    namespace ${StandardNamespace}
    {
        public partial class MainPage : UserControl
        {
            public MainPage()
            {
                this.InitializeComponent();
            }
        }
    }]]>
                </File>

                <File name="Properties\AppManifest.xml">
    <![CDATA[<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
        <Deployment.Parts>
        </Deployment.Parts>

        <!-- Uncomment the markup and update the fields below to make your application offline enabled
        <Deployment.ApplicationIdentity>
            <ApplicationIdentity
                ShortName="Out of Browser Silverlight Application"
                Title="Window Title of Your Silverlight Application">
                <ApplicationIdentity.Blurb>Description of your Silverlight application</ApplicationIdentity.Blurb>
            </ApplicationIdentity>
        </Deployment.ApplicationIdentity>
        -->
    </Deployment>]]>
                </File>

                <File name="Properties\AssemblyInfo.cs" src="DefaultAssemblyInfo.cs"/>

            </Files>
        </Project>
    </Template>

  • 03-17-2011 5:35 AM In reply to

    Re: Using Silverlight SDK 4

    Hi

    Did you find out how to change the processor type to any? I am having the same problem

     

    Thanks Bruce

  • 04-26-2011 4:38 AM In reply to

    Re: Using Silverlight SDK 4

     

    I am trying to build a OOB application using Silverlight & SharpDevelop. I added this portion of code to my AppManifest.xml.

        <Deployment.ApplicationIdentity>
            <ApplicationIdentity
                ShortName="Out of Browser Silverlight Application"
                Title="Window Title of Your Silverlight Application">
                <ApplicationIdentity.Blurb>Description of your Silverlight application</ApplicationIdentity.Blurb>
            </ApplicationIdentity>
        </Deployment.ApplicationIdentity>

    However, I didn't get OOB support. I also tried to copy the OutOfBrowserSetting.xml that has been created in VS2010. But both way don't work.

    OOB is working fine in VS2010 and I am wondering if we could achieve this in SharpDevelop.

  • 04-26-2011 12:53 PM In reply to

    Re: Using Silverlight SDK 4

    I am assuming that you mean you cannot run your Silverlight application out of browser from inside SharpDevelop.

    Visual Studio uses C:\Program Files\Microsoft Silverlight\sllauncher.exe to run the Silverlight application out of browser. SharpDevelop does not currently support this. I tried to change the project options to run this Silverlight launcher instead but it seems that SharpDevelop will always run the test html page if your project is a Silverlight application. The only way I could get it to work was to create a new external tool.

    Command line parameters:

    /overwrite
    /emulate:"d:\projects\SilverlightApplication1\Bin\Debug\SilverlightApplication1.xap"
    /origin:"file:///d:/projects/SilverlightApplication1/Bin/Debug/SilverlightApplication1.xap"
    debug

    Unfortunately you don't seem to be able to debug the Silverlight application if you attach to the sllauncher process.

  • 05-28-2011 5:25 PM In reply to

    Re: Using Silverlight SDK 4

    hello,

    Just to tell you this solution (setting the target processor to "any cpu") also worked for me.

    Here is how to do:

    -Display your Silverlight application project's properties.

    -Under the 'compiling' tab, set the 'target CPU' to 'Any CPU'.  Remark: maybe due to a display bug, I first could not access that option, because it was not visible in the displayed part of the window, and no vertical scrollbar was present.  I had to enlarge the project properties window high enough to be able to see it.

    My symptoms were:

    Chrome displayed a blank page, but no error message (maybe it was simply not configured to, but then it is because the default settings of this browser don't show these errors)

    IE6 displayed a blank page, and a Javascript error saying: 

    Unhandled Error in Silverlight Application

    Code: 2105

    Category: InitializeError

    Message: Failed to load pre-requisites for the application

     

    Hopes this helps someone in the future

  • 05-07-2012 2:01 PM In reply to

    • gdorigo
    • Not Ranked
    • Joined on 05-07-2012
    • Venice Area
    • Posts 5

    Re: Using Silverlight SDK 4

    Thanks, you solved my problems! There is any plan when this bug will be fixed?

Page 1 of 1 (11 items)
Powered by Community Server (Commercial Edition), by Telligent Systems
Don't contact us via this (fleischfalle@alphasierrapapa.com) email address.