# .NET and More > Silverlight >  2010 ASP.NET Silverlight Embedded Control Not Firing Events

## gixxer05

I have a solution that includes two projects. One is a Silverlight folder browser project embedded into the a div on the second project's aspx page and runs as a Out of Browser application. The problem I am experiencing is with the Silverlight folder browser project. All functions operate as expected when running as the startup project, solely, by itself outside of the aspx page. However no events are firing when running the Silverlight folder browser in the aspx page. Nothing is triggering the breakpoints. What could be the problem? I can provide whatever code necessary. Thanks.





```
namespace AccessingEntireFileSystemInSL5Beta
{
    public partial class MainPage : UserControl
    {
        EntireFileSystem fileSystem = null;

        public MainPage()
        {
            InitializeComponent();


            // Register script for opening browser in Preferences.aspx page - using via System.Windows.Browser;
            //HtmlPage.RegisterScriptableObject("Page", this);

            // Register Silverlight to be exposed in JavaScript 
            HtmlPage.RegisterScriptableObject("ScriptablePageObject", this); 

            fileSystem = new EntireFileSystem();

            this.folderName.Text = "Folder path : Not selected";

            this.lstFiles.ItemsSource = new List<string>() { "No files in the current folder ! " };

            this.myTreeView.DataContext = fileSystem.RootFolder;
            
        }


        private void myTreeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
        {
            Folder folder = e.NewValue as Folder;

            // If the folder is not null
            if (folder != null)
            {

                // If the full folder path is not null or empty, and child folders do not exist or the folder title is My Computer
                if ((!string.IsNullOrEmpty(folder.FullPath)
                       && folder.ChildFolders.Count == 0)
                       || folder.Title.Equals("My Computer"))
                {

                    // Load the subfolders for the top level folder, and show the directory
                    fileSystem.LoadSubFolders(folder.FullPath, folder);

                    // Show the current folder selection
                    this.folderName.Text = "Folder path : " + folder.FullPath;
                }

                // Create a list to hold the file info for the selected folder
                List<string> fileInfo = new List<string>();

                try
                {
                    foreach (string fileName in Directory.EnumerateFiles(folder.FullPath))
                    {
                        FileInfo file = new FileInfo(fileName);
                        string size = (file.Length / 1024 / 1024) == 0
                                      ? "Less than 1"
                                      : (file.Length / 1024 / 1024).ToString();
                        fileInfo.Add(file.FullName + " |  Size : " + size + " MB |  Created on: "
                                                   + file.CreationTime);
                    }

                    // The following displays a message if there are no files in the selected folder
                    // This is not required for this project
                    if (fileInfo.Count == 0)
                    {
                        this.lstFiles.ItemsSource = new List<string>() { "No files in the current folder ! " };


                    }
                    else

                        // Else, there are files in the folder, so show the file's info
                        // held within the fileInfo list of strings
                        lstFiles.ItemsSource = fileInfo;
                }

                    // Catch the exception that will occur when initiating from the top level 
                catch (Exception) { }
            }
        }




        private void RefreshMyComputer(object sender, RoutedEventArgs e)
        {
            fileSystem.LoadFolder();
            myTreeView.ItemsSource = fileSystem.RootFolder;
        }

        // This function is called from the Apply button and sends the value of the selected path
        // to the asmx page
        [ScriptableMember]
        public void btnApply_Click(object sender, RoutedEventArgs e)
        {
            HtmlPage.Window.Invoke("getFolderPath", folderName.Text);

        }

    }
}
```



```
<div id="SilverlightControlHost" class="slidingDiv" style="display: block;">

                    <object ID="SilverlightPlugin1" data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="508px" height="350px">
                    
                        <param name="source" value="ClientBin/AccessingEntireFileSystemInSL5Beta.xap" />
                        <param name="onerror" value="onSilverlightError" />
                        <param name="background" value="white" />
                        <param name="minRuntimeVersion" value="4.0.60310.0" />
                        <param name="autoUpgrade" value="true" />
                        <param name="isWindowLess" value="true" />

                        <!-- Display installation image. -->
                        <a href="http://go.microsoft.com/fwlink/?LinkID=149156&amp;v=4.0.60310.0" style="text-decoration: none;">

                        <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style: none"/>
                    
                        </a>
                    </object>
                    <iframe id="_sl_historyFrame" 
                        style='visibility:hidden;height:0px;width:0px;border:0px'>
                    </iframe>

                </div>
```

----------


## sapator

Hi. Maybe you can ask at the silverlight forum on this site and get an answer but why are u using silverlight? It will be deprecated soon anyhow, only Microsoft use it.

----------


## gep13

> Hi. Maybe you can ask at the silverlight forum on this site and get an answer but why are u using silverlight? It will be deprecated soon anyhow, only Microsoft use it.


Personally, I think that deprecated is too strong a word, that is not really the case.  While Silverlight has been "passed over" for a more generic style of application development, namely HTML 5, JavaScript and CSS, Silverlight is still a perfectly viable option of Line of Business Applications.  There are a ton of things that you can do in Silverlight that you can't, and will likely never, be able to do in HTML 5, JavaScript and CSS.  Depending on your use case, it still makes a lot of sense to develop in Silverlight.

With regard to the question...

Let me see if I have this right.  When you debug the ASP.Net Application, as the start up project, the embedded Silverlight Application is rendered to the page, but you can't step into the code in the debugger.  However, if you set the Silverlight Project as the start up project, you can bring it up in the browser, and you are able to debug as you would expect?

Does that about sum it up?

Gary

P.S. This does sound like a Silverlight specific problem, so I am going to move it to the Silverlight Forum

----------


## gixxer05

gep13 - Yes, you are partially correct.  The application does compile and steps through debugger when set as the startup project.  However, it is a out of browser app so it does not open in a browser.  The application opens up independently, in it's own bordered form window because I changed it to the startup project for testing purposes.  

When the solution is setup with the main project as the startup project, a web application, the File Browser Silverlight app renders in a div but does not fire events.

----------


## sapator

I've read and posted to this forum that Microsoft will deprecate Silverlight as an entity. I cannot find my post and thus the info. So it is not me that says that it will be deprecated but Microsoft.

----------


## gep13

> I've read and posted to this forum that Microsoft will deprecate Silverlight as an entity. I cannot find my post and thus the info. So it is not me that says that it will be deprecated but Microsoft.


It is my understanding, as per the information here:

http://support.microsoft.com/gp/lifean45

The Microsoft will continue to support Silverlight 5 until 2021.  There are no plans for a new Siliverlight version, Silverlight 5 is as far as it is going to go, but any security vulnerabilities that are identified will be corrected up to 2021.  That, to me at least, doesn't look like it's deprecated.  I agree that there is no active development happening on it, but this is the same as Visual Basic 6, and people are still using that.

Silverlight still has it's place, in my opinion.

Gary

----------


## sapator

It's somewhat the same with VB6, with the difference that VB6 had 10 million programmers using it and silverlight has 7.
 :Smilie:

----------


## gixxer05

Does anyone have an idea where I can begin troubleshooting this issue?

----------


## gep13

> Does anyone have an idea where I can begin troubleshooting this issue?


In post 3, I asked for some more information in order to help you.  Can you answer those questions?

Gary

----------


## gep13

> It's somewhat the same with VB6, with the difference that VB6 had 10 million programmers using it and silverlight has 7.


I think you are under estimating how much it is used in Enterprises.

Gary

----------

