Debug Visual Studio 2010 on Windows x64 global.asax

I have Windows 7 on x64. I have installed Visual Studio on top. Besides it is a 32 edition ( as the FF ), he does not know Edit and Continue (see http://blogs.msdn.com/b/rmbyers/archive/2009/06/8/anycpu-exes-are-usually-more-trouble-then-they-re-worth.aspx )

However, I did not expect that he does not know how to debug in Application_Start . Read and found this hack : http://blogs.msdn.com/b/webdevtools/archive/2007/12/13/workaround-debugging-global-aspx-cs-application-start-with-asp-net-web-server-within-visual-studio.aspx

However, this does not work as Edit and Continue does not work.

So, after thinking a bit, I have come to another hack . There are another server that comes with Visual Studio : Cassini. I do not use this , because there are many difficulties. However, for debugging Application_Start there is very convenient:

So Project, Properties and change from IIS:

image

 

to :

image

 

That will be all. Works with WebForms and MVC.

friday links 7

  1. Introduction to PRISM – Online Training Course for .NET Developers
  2. Free Databases in the Window Azure Marketplace — Visual Studio Magazine
  3. Download: {0} – Microsoft Download Center – Download Details – Windows Azure Platform Training Kit
  4. The Secret to Success at Work: Stop Working | Psychology Today
  5. Author Guidelines – SQLServerCentral
  6. How can I display the result of a View in a popup window? : The Official Microsoft ASP.NET Forums
  7. Razor, Nested Layouts and Redefined Sections – Marcin On ASP.NET – Site Home – MSDN Blogs
  8. Convert text into PDF using ASP.NET and C# – CodeProject
  9. How to handle errors in ASP.NET MVC | jgauffin's coding den
  10. Rands In Repose: How Can I Help You?
  11. WhatsNewNET45-en.png (PNG Image, 4448×3145 pixels) – Scaled (26%)
  12. jgauffin's coding den – Thoughts and ideas about architecture and programming (in c#/.net) | jgauffin's coding den
  13. Quote by Marilyn Monroe: "I'm selfish, impatient and a little insecure. I ma…"
  14. Being IN in LINQ to SQL – Or How I learned to Love Contains (aka Getting Linq to SQL to generate a T-SQL WHERE clause that includes an IN) – Greg's Cool [Insert Clever Name] of the Day
  15. Everything SQL Server Compact: SQL Compact 3rd party tools
  16. unfinished work – I Believe In The Internet – The Content Industry Doesn't
  17. .NET Framework Libraries
  18. Founder's Blog – Jitbit: "90% of your users are idiots"
  19. Founder's Blog – Jitbit: Go Get A Cofounder [Mistakes I Made #5]
  20. Using T4 to generate Configuration classes
  21. Using T4 to Auto Generate web.config Files | Fryer Blog

runtime loading versus compile time loading

How is started :

We have had a .NET meeting in Romania where one of the presenters load the MaxMind GEO-IP database to see from where the user comes from.
He loads from csv into an List .
He was insisting on the speed of the algorithm to find IP range.

And I was thinking : ok, the algorithm speed is one argument.

What if, instead of loading at runtime the csv file and putting into an List , I will load at compile time ?

So I have made a .tt file that parses the MaxMind csv file and generates something like

public class Location:List<GeoLocation> 
    {
        public Location():base()
        {
                            this.Add(new GeoLocation(1, "O1", "", "", "", 0f, 0f));
                            this.Add(new GeoLocation(2, "AP", "", "", "", 35f, 105f));
                            this.Add(new GeoLocation(3, "EU", "", "", "", 47f, 8f));
                            this.Add(new GeoLocation(4, "AD", "", "", "", 42.5f, 1.5f));
                            this.Add(new GeoLocation(5, "AE", "", "", "", 24f, 54f));
                            this.Add(new GeoLocation(6, "AF", "", "", "", 33f, 65f));
                            this.Add(new GeoLocation(7, "AG", "", "", "", 17.05f, -61.8f));
                            this.Add(new GeoLocation(8, "AI", "", "", "", 18.25f, -63.1667f));
                            this.Add(new GeoLocation(9, "AL", "", "", "", 41f, 20f));
                            this.Add(new GeoLocation(10, "AM", "", "", "", 40f, 45f));
                            this.Add(new GeoLocation(11, "AN", "", "", "", 12.25f, -68.75f));
                            this.Add(new GeoLocation(12, "AO", "", "", "", -12.5f, 18.5f));
                            this.Add(new GeoLocation(13, "AQ", "", "", "", -90f, 0f));
//and so on
 

The .cs generated file has 30 MB. The compiled exe of a test Console application have some 19 MB.

I have put each code into a console application and the results were:

The Console application that have csv parser loads in 1 second This is the runtime loading the file.
The Console application that have the class with all predefined does not loads after 1 minute – and the memory is increasing. This is the compiletime loading the contents.

And this is the problem – after all, the csv parser loads all those in memory the same – and , more, it’s the hard drive access time that counts. So the compiled one should be faster , right ?
Not so fast . The JIT comes into action . And it compiles the exe. So it takes MORE time.
I submit the question to some list and they come with 2(big) suggestions:

Suggestion 1 : NGEN-ing takes 1 hour on my PC (x64, 4 GB of RAM, 4 core ) and did not finish.( 4GB used at maximum). Not a good idea apparently.
Suggestion 2 : put struct. Same time…

For you to try please download

http://msprogrammer.serviciipeweb.ro/wp-content/uploads/runcomp.7z

However, the final question arises : from what number of data we should load from runtime insteand of compiletime ?
( For 1 item,the compile time is better. For 2, the same. … For all data in the csv, – runtime is required)
What I expect is a function that takes a parameter ( data that have x bytes long) and says :

loading < 1000 records is faster on compile time rather than from hard disk ( runtime) loading > 2000 records is faster on hard disk ( runtime) rather from compile time

From 1000 to 2000 depends on RAM, RPM and others
( or some algorythm for that)

How we calculate this number ?
( Take note is a pure mathematical question of minimizing the time by using both compile time and run time . Does not matter in practice since the time in runtime is so small)

friday links 6

  1. SerialSeb: Why Mock frameworks suck, and how to write delegate-based test doubles
  2. Mocks and Stubs – The difference is in the flow of information – Blog – Osherove
  3. Mocks Aren't Stubs
  4. Configuring Relationships with Fluent API
  5. Some myths of 'Textbook-TDD', and why they are wrong
  6. Mocking Comparison – Part 1: The Basics : Richard Banks – Agile and .NET
  7. A delicious toolbox
  8. The Pragmatic Bookshelf | PragPub 2011-11 | Self-Inflicted Scope Creep
  9. Scott Hanselman's 2009 Ultimate Developer and Power Users Tool List for Windows – Scott Hanselman
  10. Seeing the SQL Generated by LINQ to Entity Queries — Visual Studio Magazine
  11. I am a programmer | jacquesmattheij.com
  12. Don’t Call Yourself A Programmer, And Other Career Advice | Kalzumeus Software
  13. Monitoring SQL Server database transaction log space
  14. MSSQLTips Contribute
  15. 9GAG – Seems legit
  16. 20 Innovative Startups
  17. Setup – App Inventor for Android
  18. 25 Secrets of the Browser Developer Tools – AndiSmith.com
  19. Field Level Auditing using Change Data Capture – Part 2 – SQLServerCentral
  20. Update 4.0.2 for Microsoft .NET Framework 4 – Runtime Update
  21. Building HTML5 Applications – Better Web Forms with HTML5 Forms
  22. Universal Type Extender – CodeProject
  23. My 3 Favorite Connection String Tips | Brent Ozar PLF | Brent Ozar PLF
  24. mvc-mini-profiler – A simple but effective mini-profiler for ASP.NET and WCF – Google Project Hosting
  25. Home // Think Like (a) Git
  26. On Programming Deadlines – Randall Degges
  27. A List Apart: Articles: Dark Patterns: Deception vs. Honesty in UI Design
  28. Roach Motel – Dark Patterns
  29. Store / Xamarin
  30. Extending DataTables Range Filter – CodeProject
  31. Rapid Prototyping For Any Device With Foundation – Smashing Coding
  32. ASP.NET MVC: Expression Trees as Parameter to Simplify Query – CodeProject
  33. HTML Parsing with JavaScript – davidflanagan.com
  34. JavaScript in the small | Ola Bini: Programming Language Synchronicity
  35. Extension Method to help with EF Code First updating – CodeProject
  36. nVLC – CodeProject
  37. Fast Track to the Mobile App – Windows Phone App Design Challenge by Core77
  38. WCF Data Services Providers – CodeGuru
  39. How To Successfully Compete With Open Source Software
  40. Why I’m Done Making Desktop Applications: MicroISV on a Shoestring
  41. Work Less, Get More Done: Analytics For Maximizing Productivity | Kalzumeus Software
  42. Developers and Professionalism – Girl Developer
  43. Globalization, Internationalization and Localization in ASP.NET MVC 3, JavaScript and jQuery – Part 1 – Scott Hanselman
  44. NuGet gallery
  45. galaktor's blawg

Differences MVC versus WebForms

Rule of thumb for differences between ASP.NET MVC versus ASP.NET WebForms 1 :

  1. If it is a Web Form Control ( asp:textbox, asp:gridview) it does not work in MVC. Period. 2. Use DisplayTemplates/EditorTemplates/PartialView/HtmlHelpers and some jquery (or your favorite javascript framework) magic. See http://msprogrammer.serviciipeweb.ro/2010/05/30/mvc-helper-templates .3
  2. Security is NOT on web.config ( location ). Security is on Actions. ( Authorize or derive from ). However, enforce your Repository /Business Layer for security. Do not rely unique on Web security.
  3. Anything else it works in MVC like in WebForms . ( it means Session, Cache, Application, Cookies , IIS and so on)1. However, please note that MVC have TempData, ViewData, Filters, Models4 , ModelBinders4 and more features . Please learn those as they are important to MVC.

Notes:
1 : I am not using anymore WebForms. Too troublesome getting all those events. And which order it is when Ajax comes in action?! And I can tell you another 1000 reasons. But please follow tutorials from http://www.asp.net/mvc

2 : Ok, ok, it might work on display on HttpGet. But on HttpPost in 99,99% cases no.And no events. And will be more troublesome than advantages! So basic instinct: NO WEB FORMS CONTROLS ON ASP.NET MVC!

3No, the login controls are not available in MVC. Did you take a chance to see the default source code for a new MVC template ? There are controller and partial views implemented. Even remote validations! (Please follow tutorials from http://www.asp.net/mvc)

4 Ok, ok,so ASP.NET vNext will have strongly typed Models on controls.  And a ModelBinding over ValueProviders ( see [QueryString] on this post ) . But see note 1

friday links 5

  1. New cool list of Linux must-have programs
  2. calvin.jpg (JPEG Image, 900×628 pixels)
  3. Google App Inventor – CodeProject
  4. My 3 Favorite Connection String Tips | Brent Ozar PLF | Brent Ozar PLF
  5. Fast Track to the Mobile App – Windows Phone App Design Challenge by Core77
  6. Author information in search results – Webmaster Tools Help
  7. NuGet – Manage Project Libraries with NuGet
  8. Ubuntu One : Downloads : Windows : More Info
  9. mvc-mini-profiler – A simple but effective mini-profiler for ASP.NET and WCF – Google Project Hosting
  10. Home // Think Like (a) Git
  11. On Programming Deadlines – Randall Degges
  12. A List Apart: Articles: Dark Patterns: Deception vs. Honesty in UI Design
  13. I am a programmer | jacquesmattheij.com
  14. Roach Motel – Dark Patterns
  15. Store / Xamarin
  16. Extending DataTables Range Filter – CodeProject
  17. Rapid Prototyping For Any Device With Foundation – Smashing Coding
  18. ASP.NET MVC: Expression Trees as Parameter to Simplify Query – CodeProject
  19. 4.3 Scripting — HTML Standard
  20. HTML Parsing with JavaScript – davidflanagan.com
  21. JavaScript in the small | Ola Bini: Programming Language Synchronicity
  22. Extension Method to help with EF Code First updating – CodeProject
  23. nVLC – CodeProject
  24. Getting Started: Syntax Analysis
  25. WCF Data Services Providers – CodeGuru
  26. How To Successfully Compete With Open Source Software
  27. Why I’m Done Making Desktop Applications: MicroISV on a Shoestring
  28. Work Less, Get More Done: Analytics For Maximizing Productivity | Kalzumeus Software
  29. Don’t Call Yourself A Programmer, And Other Career Advice | Kalzumeus Software
  30. Developers and Professionalism – Girl Developer
  31. Building HTML5 Applications – Better Web Forms with HTML5 Forms
  32. shanselman / Psuedoizer / overview — Bitbucket
  33. Globalization, Internationalization and Localization in ASP.NET MVC 3, JavaScript and jQuery – Part 1 – Scott Hanselman
  34. NuGet gallery
  35. galaktor’s blawg
  36. Setup – App Inventor for Android

Programmer tools 2011

List of programmer tools

I have re-installed the PC and I have been taken notice of what tools I have on the system now:

  1. Magic Disc – can mount .iso files ( for  2 )
  2. Visual Studio – must have for a easy developing path
  3. Sql Server 2008 – primary database for me
  4. 7-zip  – archiver
  5. Firefox ( plus addons, see below)
  6. Smtp4dev – to see messages
  7. AspNetMVC3ToolsUpdateSetup
  8. FreeCommander –  dual panels for windows explorer
  9. Foxit reader – pdf viewer
  10. Notepad ++ ( with hex addon)
  11. Winmerge – files/ folders difference
  12. Clean project – archive solution
  13. SqlSearch from RedGate – fast search after names
  14. SSMS tools – record every operation you do in sql server
  15. EntityFramework41  – code first development
  16. XUnit – automated testing + samples  to do BDD style
  17. SSCERuntime_x86-ENU –SqlCompact provider. Works with EF4.1
  18. SqlCe40Toolbox – SqlCompact viewer
  19. NuGet.Tools.vsix – Nuget is awesome!
  20. ImgBurn  – burn cd-s
  21. consolas font  – see  1 and l ?
  22. LogParser  – never know when you need to parse some files
  23. Moq  – mocking tool
  24. PreviewHandlerPack  -see c# code in preview window
  25. Regulator and Regulazy – regular expression helpers
  26. StringTemplate.NET  – templating generator. Maybe replaced by razor ?
  27. NLog –  logging tool. Log4Net was pretty unreliable in .NET 4
  28. FileHelpers – reading writing text data.
  29. Tcmdwincearm – Total Commander for mobile. Free.
  30. Jquery and Jquery UI.
  31. DataTables – html tables supports sorting , filtering, others.
  32. Windows Live Essential – blogging fast.
  33. InsertFilePlugin – Live writer extension to insert files to upload.
  34. OfficeOpenXMLPart4-MarkupLanguageReference  – markup for Office XML. Used with StringTemplate
  35. SharpZipLib – knows how to zip multiple files.
  36. AutoFixture – generating sample data
  37. HtmlAgilityPack – parsing web pages
  38. T4MVC – get rid of magic names for controllers, actions
  39. Itextsharp – save as pdf
  40. Ninject – DI provider
  41. Hudson – continous integration
  42. AutoMapper  – transferring data between DAL and BLL
  43. Selenium – testing web interfaces
  44. Svn  -source control
  45. MVC Contrib – pages list and more
  46. Msbuildtask from tigris – build make it easy
  47. Psr – help made easy in Windows 7
  48. Firefox addons here

https://addons.mozilla.org/en-US/firefox/collections/ignatandrei/ignatandrei/

For every tool search for it . The first link will give you all details.

You can have as pdf here:List of programmer tools 2011

Implementations GUI details

When creating a GUI you must think to give user some good feeling about what the software can do – so I started to MVC 4 website, that have mobile support integrated.

More, you must demonstrate some features right away to the user – so what’s best if not a message from system admin to the user  to “welcome” him ?

For this , I have to  implement a template with RazorEngine – simple to used from his code

string template = "Hello @Model.Name! Welcome to Razor!";
  string result = Razor.Parse(template, new { Name = "World" });

Summary of modifications for this simple operation – send and display a message  from Admin when a user registers

  1. Add connectionstrings to web.config – to connect to database + SiteUtils static class to retrieve it.
  2. RegisterAdmin user in Application_Start – in order to have user Admin in the database ( generate a GUID and put into a const)
  3. Add “welcome.txt” file
  4. Add RazorEngine to parse message
  5. Modify  Register action in order to send message after a user registers
  6. Add an area “Messaging” in order to can have the messaging separated from main site( to be easier to xcopy)
  7. Add an Index action( display read/unread messages) + View
  8. Add an DisplayMessage action (display a message) + View

All for this picture where it shows number of unread messages(1) and list :

image

You will find code at http://messagemvc.codeplex.com/SourceControl/changeset/changes/81924

Homework:

Think about the user actions . He will be interested in the following for existing messages:

  1. Unread messages
  2. View of all messages (paginating)
  3. Search messages:
    • Messages from a date
    • Messages from someone
    • Search

What do you think it will be done for implementing those?