Wednesday, April 22, 2015

Chrome Debugger, setting breakpoints in angularjs


So, If you are like me and you live with the debugger, even in JQuery, Amglar is going to throw you for aloop... because chrome's debuggers breakpoints dont' work..

And you you get the BAtarang tool for "debugging" angular... it's aparent pretty quickly, that i'ts not debugging in a debugger, but something else entlirely...

I'ts like going back to the 1990s when Programemrs would decalre pridefuly "only bad programemrs need to use a debugger"

Fortunately there is a way to get a break point.. stepping through code is harder but if you drop the keyword 'debugger;' into you code, it will force a break point when that anglyuar function is called.

 $scope.SaveScript = function () {
        debugger;// it will break here
        if (($scope.selectedLanguage == -1) || ($scope.selectedCallscript == -1)) {
            return;
        } else {
            var ckData = CKEDITOR.instances.CkEditorId.getData();
            var dataToSend = TestService1.BuildSaveScriptCV(ckData, $scope.selectedLanguage, $scope.selectedCallscript, "test tile");
            var linkUrl = 'http://localhost/Scout3G/Maintenance/SaveScript';
            //var linkUrl = '@Url.Action("SaveScript","Maintenance")';
            TestService1.JcdcAjaxDoPostRetrieveJson1(linkUrl, $scope.DisplaySavedScript, dataToSend);
        }
    };

it's not beautiful, but at least you can tell if a function is gettign called without resoritng to cave man debugging with Alerts.

useful links in debuging angluarjs
http://24days.in/umbraco/2014/debugging-angularjs/
http://ng-inspector.org/
http://stackoverflow.com/questions/18782069/how-to-debug-angular-javascript-code
https://chrome.google.com/webstore/detail/angularjs-batarang-stable/niopocochgahfkiccpjmmpchncjoapek?hl=en-US
http://odetocode.com/blogs/scott/archive/2014/07/29/debugging-angularjs-in-the-console.aspx

Thursday, April 16, 2015

VS2013 MVC4 project as soon as you add json.net package you cant' compile

 As soon as you add the Json>net package in nut get on a new blank mvc 4 applicaiton project, you get this

Server Error in '/' Application.

Could not load file or assembly 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IO.FileLoadException: Could not load file or assembly 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Source Error:

Line 17:             AreaRegistration.RegisterAllAreas();
Line 18: 
Line 19:             WebApiConfig.Register(GlobalConfiguration.Configuration);
Line 20:             FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
Line 21:             RouteConfig.RegisterRoutes(RouteTable.Routes);

Source File: c:\Users\Brown.ericw\Documents\Visual Studio 2013\Projects\AngularTest4\AngularTest4\Global.asax.cs    Line: 19 




This is the fix

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
        <bindingRedirect oldVersion="0.0.0.0-5.0.8.0" newVersion="6.0.0.0"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

The key is that the version on the package is 6.0.8 and you think that's what you are supposed to use , but nope, it 6.0.0.0