locked
DesktopClient crash in Default.htm checkDirty function RRS feed

  • Question

  • Weird bug in my project using the Desktop Client (HTML5 client works fine, but I need the Desktop App to configure security).  This was giving me a blank screen in the OOB Desktop client when I ran it, and when I run it as an in-browser SL app, I get the loading screen, then a Javascript error in the following function within default.htm:

       <script type="text/javascript">
            function checkDirty(e) {
                var needConform = false;
                var message = 'You may lose all unsaved data in the application.'; // default message
    
                var silverlightControl = document.getElementById("SilverlightApplication").Content;
                if (silverlightControl) {
                    var applicationState = silverlightControl.ApplicationState;
                    if (applicationState) {
                        applicationState.OnBrowserClosing();
                        if (applicationState.IsDirty) {
                            needConform = true;
                            message = applicationState.Message;
                        }
                    }
                    else {
                        needConform = true;
                    }
    
                    if (needConform) {
                        applicationState.FocusOnDirtyItem();
                    }
                }
    
                if (needConform) {
                    if(!e) e = window.event;
                    e.returnValue = message;
    
                    // IE
                    e.cancelBubble = true;
    
                    //e.stopPropagation works in Firefox.
                    if (e.stopPropagation) {
                        e.stopPropagation();
                        e.preventDefault();
                    }
    
                    // Chrome
                    return message;
                }
            }
            window.onbeforeunload=checkDirty;
        </script>

    The specific line that fails is

    var applicationState = silverlightControl.ApplicationState;
    Can someone point me to a potential source of the error (I'm guessing the silverlightControl object is inappropriately initialized) and/or any tips on troubleshooting further?

    Friday, August 22, 2014 6:15 PM

Answers

  • Line: 35
    Error: Unspecified error.

    Helpful, right?

    UPDATE:

    There appears to be a problem in the model somewhere.  I've resolved it by building a fresh desktop client-only solution as a workaround.  The HTML5 client is still working okay in the current project so screw it...  I have my work around.

    In the meantime: Please guys - fix the fragility in the models and add some additional instrumentation to the LightSwitch side of things.  I'm losing billable days having to rebuild solutions from scratch because I've renamed something or re-imported a file from source control, only to have the model start whining about being broken.

    Saturday, August 23, 2014 8:11 AM

All replies

  • What is the error?

    David Kidder | Senior SDET | Microsoft | LightSwitch

    Friday, August 22, 2014 8:49 PM
    Moderator
  • Line: 35
    Error: Unspecified error.

    Helpful, right?

    UPDATE:

    There appears to be a problem in the model somewhere.  I've resolved it by building a fresh desktop client-only solution as a workaround.  The HTML5 client is still working okay in the current project so screw it...  I have my work around.

    In the meantime: Please guys - fix the fragility in the models and add some additional instrumentation to the LightSwitch side of things.  I'm losing billable days having to rebuild solutions from scratch because I've renamed something or re-imported a file from source control, only to have the model start whining about being broken.

    Saturday, August 23, 2014 8:11 AM
  • If you run into more model problems you can share your projects with me an we will take a look at them.  You can contact me at

    david (dot) kidder (at) microsoft (dot) com


    David Kidder | Senior SDET | Microsoft | LightSwitch

    Monday, August 25, 2014 1:18 PM
    Moderator
  • Thanks for the offer David - but the code-base is for a client and wraps a highly proprietary data model.  The one thing that you COULD do is convince the powers that be that there needs to be a lot more documentation on how LSML files (and the corresponding infrastructure files - e.g. Targets files, Manifest files, etc...) hang together.  I realize that releasing all of that sort of undermines the "secret sauciness" of how LightSwitch works, but the documentation for LightSwitch at a DEVELOPER level is far lighter than for any other dev-div team offering I can name.  Something as simple as a breakdown of what each file in a projects role is, how it gets populated (model designer vs code, and what you shouldn't change if you want to keep the model intact) would be valuable.

    To put this into perspective - I'm a SQL guy who has fallen into the whole LightSwitch development arena.  I'm not as well-versed in Visual Studio as a hard-core developer, but I'm technical enough to understand documentation if it's provided to me.  The "How To" content is great, but it's focused on how to fix LightSwitch while it's working, and rarely offers any insights into project internals or steps required to resolve the dreaded "No designer available" error.

    One other thing that would make life a LOT easier is to decouple the client projects and the server project to at least the extent where the client project only needs a reference by name to load a designer rather than a load of GUIDs.  That way you could at least import a client project into a fresh server project if you're recovering from some sort of data model malfunction.  From an architectural perspective, the tightness of the binding between the projects could be viewed as a little fragile.

    The alternative to refactoring the tightly coupled client/server modules would be to provide some additional tools for remapping fields/entities/screen objects if something goes askew. 

    Anyway - it's late and I'm ranting.  Sorry to dump it all out like this - it's not directed at you personally but at the LightSwitch universe more broadly for making life with LightSwitch a struggle more often than it should be.

    Cheers

    JH

    Monday, August 25, 2014 4:03 PM