»
S
I
D
E
B
A
R
«
HTTP Error 403.14 – Forbidden fix
Jan 26th, 2012 by evereq

You just setup new Windows 2008 R2 Server, enable IIS role, install ASP.NET MVC 1/2/3 or 4, upload your site, configure IIS (i.e. IIS pool, rights, certificates etc) and get following error in browser:

HTTP Error 403.14 – Forbidden
The Web server is configured to not list the contents of this directory.

Hm… EASY to fix with following command (run command prompt as administrator!):
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -i

Done :)

P.S. if for some strange reason you still use 32 bit Windows, you should update framework path in command above.

.NET performance and your hardware
Apr 14th, 2011 by evereq

Was inspired by Ayende post (see http://ayende.com/Blog/archive/2011/04/14/performance-numbers-in-the-pub.aspx) and want to check how much objects my work PC may create :D
Moreover, now seems best time to do that – my company order today new SUPER machines for our team, so it will be interesting to see difference with current PC using such “.NET” test.

My current PC is Intel Q8200 4 Cores / 8Gb memory / SSD Intel 80Gb etc – you get idea :)

Main difference between my code and Ayende code (as well as many blog comments code) is that I create objects using multiple threads. What is interesting for me that most of people even today, just forget the fact that they have multiple cores in PC (or Server) and modern development should be done with that “stick” idea in your mind: “multitask / multithreading / async may be used if you want to utilize optimally your hardware”. Sure it’s not always make sense to go that “hard way” – some tasks just not scale too much with that approach. At the same time, in that specific tests I was able to get about 50% performance gain using very simple threading model compared to the single threaded. Not bad enough, right?

Sure it’s not really optimal strategy (more optimal for sure to just use C / C++) and I think memory speed restrict CPU power in that specific tests (i.e. no matter how many cores you use in CPU, if your memory / memory controller just can’t get / process all that in the parallel).  In addition I also initialize each created object integer field with some value to restrict some possible optimizations in CLI.  You can also found multiple small optimizations to avoid some overhead etc. Sure it’s not best code out there, but effective enough to demonstrate how TPL can improve results even in such a simple task. Maybe later will found time and write same using C++ with Parallel Patterns Library (PPL) to measure the difference :D

On my PC test create 4 new threads and each thread create multiple objects. Note that test works 10 seconds to give you more precise results :)

Tests results: around 150M created and initialized objects per second (don’t forget to build in Release mode if you really want to run it)
I promise to publish new results when new PC arrive to our office;-)

Btw, if you get your own results, will be glad to see and compare :D

Stay tuned :)

P.S. Code is not finally optimized and is not “production ready”. Means that I just want to play a bit with what Ayende originally wrote…
For example, you probably may note that test will take longer than 10 seconds to run if your PC already busy with some tasks (simply because I use too much threads for such environment) etc.

P.P.S. No warranties :) Please do not run that code on your production servers :D

Update #1: My colleague have notebook with Intel i5 CPU (4 Cores) and he just get  215M result :D

Update #2: Just get new PC with CPU Intel i7-2600K (at 3.5Ghz) / 8Gb DDR3 1600Mhz memory etc. I get just amazing result: 700M with same source code :D WOW!

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using System.Timers;

namespace Testing
{
    class Program
    {
        static volatile bool _isContinue = true;

        static long _total;

        const int TestTimeSec = 10000;

        static Stopwatch _sp;

        static void Main(string[] args)
        {

            var tasks = new List<Task>();

            int processors = Environment.ProcessorCount;

            Console.WriteLine("Detected {0} cores"processors);

            var timer = new System.Timers.Timer(TestTimeSec);
            timer.Elapsed += TimerElapsed;
            timer.AutoReset = false;
            timer.Start();

            _sp = Stopwatch.StartNew();

            for (int t = 0t < processorst++)
            {
                tasks.Add(Task.Factory.StartNew(
                    () =>
                    {
                        long i = 0;

                        while (_isContinue)
                        {
                            var obj = new MyClass();
                            i++;
                            obj.B = i;
                        }

                        Interlocked.Add(ref _totali);
                    }
                ));
            }

            // let's complete all the tasks to get results into _total
            Task.WaitAll(tasks.ToArray());

            _sp.Stop();

            Console.WriteLine("Created {0} objects in {1}"_total / 10_sp.Elapsed.TotalMilliseconds / 10);
            Console.ReadKey();

        }

        static void TimerElapsed(object sender, ElapsedEventArgs e)
        {
            _isContinue = false;
            Console.WriteLine("Stopping...");
        }

        public class MyClass
        {
            public string A;
            public long B;
            public DateTime C;
        }

    }
}
Simple Cloud API and maybe I should go to PHP
Nov 2nd, 2010 by evereq

Maybe I should go ….to PHP ;-) ?
(… I mean just go, not “go down” or “go up” or “go away from .NET” – read next why, really!)

Projects like Simple Cloud API (http://simplecloud.org) in PHP, together with Zend Framework and many other PHP related stuff  sometimes KILLS me, .NET developer / architect!

Why, WHY we do not have something like Simple Cloud API in .NET??? Or at least it’s not well known! Is it so hard to build and promote it ?? NO! Why it takes whole a lot of time to introduce ASP.NET MVC, if we do it so many years in Java or PHP !? Great .NET framework, tons of projects, but so limited amount of “innovative” open source projects in .NET! :(

Take a look, most of famous .NET open source projects go in same versions or even few versions behind if compare to corresponding projects from Java (see Lucene.NET for example), but do not introduce really “innovations” in the software programming! Some projects do not even exists in .NET space like Solr (i.e. you should use Java VM to run it)! Some projects like ASP.NET MVC comes much later other MVC frameworks in Ruby (RoR), Python (Django) or even PHP (Zend Framework)… And Microsoft last time spend whole a lot of effort to bring Java  / PHP into Azure… instead of increase sponsorship for example innovative OSS projects in .NET and by this push developers to go for .NET from other frameworks!

Should somebody build library like SimpleCloud in .NET ASAP!? YES! (please don’t tell me that I should build it :D ) Why?

Too many companies really need same thing to be able to abstract away Windows Azure or any other Cloud specific solution using some open source  libraries (like SimpleCloud in PHP) and made solution portable across Clouds, before they spend $$$ and stuck with one Cloud supplier forever :( See my post about this!
And too many developers really expect .NET platform to be more innovative !!!

P.S. sometimes innovations can waste your time / effort, if parent company stop support it – see my post about Silverlight

Silverlight Killed or?
Oct 30th, 2010 by evereq

Silverlight Killed or? I don’t think so…
Unfortunately, in some sense http://mashable.com/2010/10/29/microsoft-silverlgiht-html made correct statement: “Microsoft Shifts From Silverlight to HTML5″ and that’s a FACT now!

Why this happens!?? Here is my thoughts:

  1. Silverlight, like many other interesting concepts from MSFT was implemented with many technology related issues in early versions!
    Performance and fonts issues I can name as most important! I do NOT like how Silverlight apps looks at my TFT monitors (because of fonts issues), same like WPF applications! Sometimes, when I scroll something, it push me think that I should go to doctor to check my eyes again! (and same issues with fonts I see with IE9 beta, not sure MSFT will fix it someway or not before final release)
  2. Silverlight supported on much less devices than HTML / CSS / JS / Flash and it seems like because it’s proprietary this can’t be changed in near future!
  3. Development of Silverlight can be done right only using Microsoft tools like Visual Studio and Microsoft Expression Studio (some apps from it) that cost $$$
  4. If you know Java, Python Django, RoR, PHP, Grails or any other language / platform / framework for web development, it’s much more easy to use HTML5 because you already know HTML / CSS / JS stack (as well as many web frameworks) than to move to something new like XAML / C# etc! I.e. basically only developers in .NET can consider using Silverlight, not other wide audience of Web developers! And while I can’t sure thing compare power of Silverlight and HTML5, MOST of required things can be done easy with nice JavaScript frameworks (think jQuery), HTML5, CSS3 etc.
  5. Silverlight apps are always have big size! Sometimes there are even so heavy that web users probably will not wait so much time! Compare it to current compressed Javascript code and HTML5 compressed using standard gzip compression and / or different other compressors! What to feel it? Go to http://www.microsoft.com/windowsphone/en-us/buy/7/phones.aspx and check how long it takes to really get it in your browser!

I can give many other arguments around it, but generally when Silverlight out I made my choice – AVOID using it (as well as WPF, but that’s other story) for any live projects, until I will really feel the need of “all in one” web client application with really rich and heavy graphics / Video / Voice requirements!
It’s real fact that MOST of flash based sites, where site COMPLETELY was made in Flash FAIL, unless they touch some very specific area! I.e. it so easy to see that web users want “light” pages (HTML / CSS / Javascript) and not heavy as Flash / Silverlight get produced!
But again: I DO see big future anyway for Silverlight as really best framework to build RIAs out there in .NET space! More so, now it seems like Silverlight can take it place in WP7 development!

Just always you should ask yourself – are you sure you want to build (or customers ask you to build) RIA? Maybe you want to build super light, not heavy Web 2.0 (3.0) web site? Or may be you want to build something using only open / cross-platform technologies?
Than don’t even think about Silverlight, at least for now!

How to get current application domain directory in .NET
Oct 17th, 2010 by evereq

Few useful ways to get current application domain directory path in .NET
(some for Winforms, some for ASP.NET, some for both):

  • System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)
  • AppDomain.CurrentDomain.BaseDirectory
  • Directory.GetCurrentDirectory()
  • Environment.CurrentDirectory
  • this.GetType().Assembly.Location
  • Application.StartupPath
  • HttpContext.Current.Server.MapPath(@”~\”);
  • Application.ExecutablePath
  • HttpContext.Current.Request.PhysicalApplicationPath
»  Substance: WordPress   »  Style: Ahren Ahimsa
© Copyright 2008–2010 EvereQ.com All rights reserved. Logos, company names used here if any are only for reference purposes and they may be respective owners right or trademarks.