Archive for the ‘Code and Development’ Category
May 5th, 2011
This is a dispersed article about caveats I found when forced to debug javascript in IE7.
Out of date web browser. Out of date script engine. Limping solution.
To fire up the debugger, enter
debugger;
as javasctipt on a row exceuting before where you want to start debugging. One could probably divide by zero or something that makes IE throw up a dialogue asking if you want to debug or not. and then answer yes…
There doesn’t seem to be any good official debugger for IE7, unless you have Visual studio installed. Search the web and there is a NT4-compatible Microsoft Script Debugger; it is not very good. There is one or more solutions but this is the only I have tried.
If you get a dialogue/error message
Request format is invalid: application/json; charset=utf-8
when working with jquery and ajax on an iis / dotnet solution, it might be due to missing lines in web.config. The code below is for Dotnet3.5. I don’t know what it looks like in 2.0 or 4.0.
<system.web>
…
<httpHandlers>
<remove path=”*.asmx” verb=”*” />
<add path=”*.asmx” type=”System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35″ validate=”false” verb=”*” />
<add path=”*_AppService.axd” type=”System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35″ validate=”false” verb=”*” />
<add path=”ScriptResource.axd” type=”System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35″ validate=”false” verb=”GET,HEAD” />
</httpHandlers>
</system.web>
May 4th, 2011
Just a tip up front. IE7 runs an older script engine than IE8 and has no full support for Json.
So your code that calls JSON.stringify does not work.
The remedy is to include json2.js from https://github.com/douglascrockford/JSON-js/blob/master/json2.js. It does not interfere with IE8+. Just download the file (the “raw” button – saveas) to your script lib and include as so:
<script src="Script/json2.js"; type="text/javascript"></script><!-- Needed for IE7. -->
Running IE9 in compatibility mode does not make this error appear – it seems like IE9-in-IE7-mode is running a newer script engine.
That impediment avoided you are free to continue adding value to your site.
May 3rd, 2011
This setting has been around a long time but it seems to still elude users.
There is a way to have the document you have open in Visual studio to also be tracked and highlighted in the Solution explorer window.
Menu->Tools->Options->
Checkbox: Track active item in Solution explorer
April 1st, 2011
I am trying out Visual studio unit testing framework, the Microsoft alternative to, for instance, nUnit which was my old preferred testing framework (and possibly still is).
At the same time I am not in a project devoted to Test driven development so I can’t use its religion to write tests first and refuse to show any UI progress to the customer. Right or wrong – that is how I perceive the reality around me right now. But I do want to have tests and waiting for them I make sure I have place holders.
My compromise is to set the tests to Inconclusive (Ignore in nUnit talk). I guess it will come back to bite me…
What I also do is to make sure I have a test to go with every method.
[TestMethod]
public void AddOrUpdateTest()
{
Assert.Inconclusive();
Elvis.Common.Meta.GetMethodName<BLF.Sample>(x => x.AddOrUpdate(null, null));
}
I used the code from
http://stackoverflow.com/questions/1524290/linq-is-it-possible-to-get-a-method-name-without-a-return-type-via-linq-expressio
but I could probably use CompulsoryCat just as well.
I belive that even adhering TDD this technique is good. There are so many times I don’t know what the classes and methods will look like before having done a simple implementation. To write exhaustive tests for a method that will be deleted is a waste. Better then to make sure the simple code runs and not forget to write the tests by having a yellow Inconclusive flag.
March 27th, 2011
This exception might have to do with the browser calling http://localhost/Views/Home/ instead of http://localhost/Home in an aspnetmvc project.
Also make sure there is a HomeController in /Controllers.
I haven’t delved into this since it just was an obstacle in something else I was playing with.
March 25th, 2011
Since I have been having problems with reaching my company’s TFS server from home I started with SVN. One could say I use SVN as an offline SCM.
#1: Don’t use Visual studio for both version managers in the same solution.
Visual studio takes for granted one solution is against one SCM. Swapping TFS and SVN messes everything up.
#1.1: Use Visualstudio with TFS and SVN with explorer.
I don’t think there is a TFS tool for explorer so the other way around is not possible. This means I checkin TFS from Visual studio and commit SVN from explorer.
#2: Stuctural changes take time. And possibly ruins the history.
I don’t try to keep the SCMs in sync but instead have the TFS as main repository. I make sure folder moves etc. are done properly in TFS and then just reset (get everything – commit whatever it looks like) in SVN.
With these caveats sorted out it works nice.
March 23rd, 2011
When writing an API, be it a global Jquery or private CustomerFacade one has to do a bit of architecting/designing when coming up with method names and parameters. Sometimes they are natural but other times takes a bit of thinking and at other times again refuse to become anything good.
So don’t write the API. Yet. Write the calling code. The API is there to be used by someone (something) and should be readable, preferably easily.
When writing the call first one (i.e. I) often misses a parameter for complex methods. But then I just iterate.
Write the caller. Write the callee. Discover the callee lacks a parameter. Update the callee. Update the caller. Repeat once again. Notice the callee is complex and split it. Update caller. See that the caller shouldn’t be split. Add a method to the API and make the two earlier private. Update callee. Finished with a good working method. Continue to next task/method.
March 22nd, 2011
Due to some reason unknown to man there is in Windows the idea of every window to have a title bar, unusable for anything but dragging and double clicking and holding approximately four buttons. Chrome and Opera have reused the space for tabs, well done!
Visual studio has its own solution. Press shift-alt-enter (or somewhere on the menu) and the application maximizes itself to get rid of caption bar and borders. Unfortunately the menu is still visible (it should be able to set it to auto hide) . Then remove the tool bars and set the tool windows to auto hide; almost everything is now the editor.
Now shift back to the space wasting layout (shift-alt-enter) and the old setting is back. So not only do we get more working space, we get a fast layout switch too the same way it switches layout when and when not debugging.
Also applicable for Sqlserver management studio.
Viusal studion x 2
December 14th, 2010
I have created a very simple cloud application.
It can give back a GUID or a UTC date/time on proper ISO format.
If I have the time I will update it to be formattable and to give back consecutive numbers for a project. The URL would then be something like http://unicow.cloudapp.net/DateTime/yyyy-mm-dd and http://unicow.cloudapp.net/Teller/MyProject Future updates might include XML and Json too.
Since there is no HTML it should be easy to use from clients.
It is just a temporary Azure account so it will vanish by itself when time comes.
November 19th, 2010
A seldom used feature of dotnet config files is the possibility to link to another file. Use configSource=”theotherfile” or file=”theotherfile” as attribute. An example and comments are found here.
This is old news indeed but every time I use it I tend to google for a while since I cannot remember the keywords.
Example of use:
I have an ordinary app.config file. It links to connectionstrings.config which keeps my <drumroll/> development connection string. For creating an installation file I have a normal setup/installation project. This project takes the file connectionstrings.prod.config and incorporates it in the MSI while renaming it to connectionstrings.config.