this application failed to start because side-by-side-configuration is incorrect

it could be other things but in my case (which is common apparently) is was just caused by having an ampersand (&) within one of the values in the web.config/app.config appsettings key-value pairs

the fix is to simply change & to &

this is because the xml reader is not able to parse the *.config file properly unless the value is xml encoded. this applies for these characters as well (and their correct/encoded representation)

"   "
'   '
<   &lt;
>   &gt;
&   &amp;

there could be various other complex reasons (you can search for the full string online and you will find them)

but hope that helps

.NET Business Intelligence

adding custom SSIS transformation to visual studio toolbox fails

Just very recently I encountered an issue in deploying a custom SSIS component assembly where I cannot add a custom SSIS transformation to the Visual Studio toolbox.

It turns out to be a relative “no-brainer” error if only the clues were more straightforward. Basically after deploying the assembly I could not find my component listed in the “SSIS Data Flow Items” tab list. [more]

There are a number of articles available online on creating custom SSIS objects (control flow tasks, source, destination, data transformation etc).

Here are a few :

Extending SSIS Part 1 – Creating a Custom Data Flow Transformation Component

Developing a Custom Data Flow Component

Developing a Custom Transformation Component with Synchronous Outputs and searching say using keyword “adding custom SSIS transformation” should return more.


At Agilone, we’ve been developing SSIS components to complement our products and one of the issues I’ve faced recently is when I was deploying the custom SSIS components (the assembly) and it’s time to add it to the toolbox (Choose Items > SSIS data flow items tab (since the component was a data flow item)) I was unable to see the component (or any component on the assembly I just added to GAC and the PipelineComponents folders).

I tried these (in different orders and to no avail but for completeness including in the list):

1) close BIDS (Visual Studio Shell) or reset toolbox and close BIDS

2) uninstall the assembly in GAC and reinstall the assembly in GAC

3) make sure that assembly is on the correct folder (e.g. DTSPipelineComponent – here are more details on deployment and testing – Deploying and Testing Custom SSIS Components)

4) restart SSIS service

5) reopen the project and try to re-add the component in the toolbox again.

As mentioned it didn’t do the trick and took me sometime to figure it out.

It turns out that there was a problem with the assembly. I built the version referencing some SQL 2005 libraries (DLL), specific version = true and when I deployed it to that server (which only had SQL 2008 DLLs) it failed silently and simply didn’t appear on the “SSIS Data Flow Items” tab.

There are more complex ways to figure out why it doesn’t appear in the said tab but I would like to share the more straightforward one.

After the step where you clicked Choose Items (for toolbox) when the dialog window appears instead of changing to the “SSIS Data Flow Items” tab, stay on the .NET Components. And then click browse and browse for the assembly which contains your custom SSIS component

If the assembly chosen doesn’t contain an SSIS component then it will say so.

However if the assembly contains errors (e.g. missing referenced assemblies among others) then it will also show an error dialog saying so.

That’s it. I hope it helps and saves you some time (since I wasn’t able to find this information quickly – for a good “googler”)

And for the more “complex” method I believe you can you fuslogvw or similar assembly binding logger/monitoring tool to figure out any issues on assembly binding (missing references) such as the one I encountered. But I suggest doing he “browse” test first before exploring those debugging techniques.

And finally, of course as for any project check that you have the right assemblies referenced, whether you want specific version true/false and make sure that all dependencies are in place.


.NET Web

Register for Visual Studio 2010 Beta Exams (.NET 4.0)

Time for (free) Beta Exams again

Information can be found from here

Register via

For easier reference, exams available are listed below (along with PromoCode)

Exam 71-511, TS: Windows Applications Development with Microsoft .NET Framework 4 – 511BC

Exam 71-515, TS: Web Applications Development with Microsoft .NET Framework 4 – 515AA

Exam 70-513: TS: Windows Communication Foundation Development with Microsoft .NET Framework 4 – 513CD

Exam 70-516: TS: Accessing Data with Microsoft .NET Framework 4 – 516B1

Exam 70-518: Pro: Designing and Developing Windows Applications Using Microsoft .NET Framework 4 – 518PE

Exam 70-519: Pro: Designing and Developing Web Applications Using Microsoft .NET Framework 4 – 519ZS

And as always, word of advice, read and master the items in prep guide to increase your chances of passing the exams.

Good luck!

.NET Business Intelligence Web

Safety settings on this machine prohibit accessing a data source on another domain

Encountered this message many times with sites using PivotTable component of OWC11 (office web components) “Safety settings on this machine prohibit accessing a data source on another domain

This is a browser restriction (at least with IE). Before resolving this, make sure you are accessing a trusted site.


1. Add site to the zone (e.g. it is recommended that you only allow your trusted sites to be exempted from this restriction). So add the site (if you trust it) to your Trusted Zone. Internet Options > Security

2. Modify Security Level of that Zone (e.g. Trusted Zone). Custom Level button. A pop-up dialog should appear. Go the Miscellaneous Settings section. Then you should be a setting for “Access data sources across domains”. Recommended to set it to Prompt. If that option is selected you will be prompted when a component requires this permission.

Hope that helps.

.NET Tools and Utilities

My Simple Talk article on ANTS Profiler and Performance

A couple of weeks back, RedGate/SimpleTalk contacted me for a short article about ANTS Profiler. I've been using it for sometime and has definitely been very useful so I won't think twice about recommending it.

Here's the link (below) and please do drop by to read it. Feel free to rate/comment

Using a profiler to speed (up) application Performance

.NET Web

BlogEngine.NET migrating to IIS 7

This blog running on BlogEngine.NET (and the its parent/main site) is now running on IIS 7 Integrated Mode and would like to share a little of my experience.

There were two major issues with I migrated these blog to IIS 7 [more]

1) Server Error in / Application – Request is not available in this context when I accessed the sites

    *Of course I had customErrors ON so I had to turn it OFF before I was able to see this detail

   Interesting, since the site obviously worked fine in IIS 6 and no changes were made. But after a few google clicks I ran into this written specifically for the error. IIS7 Integrated mode: Request is not available in this context exception in Application_Start from Mike Volodarsky. Implemented the suggestion and that did it.

    Because of IIS 7 architectural changes the request context is not available in the Application Start. And since BlogEngine.NET loads extensions in the Application_Start event and the extension makes extensive use of the request context in path related code (also determining protocol et al) the error occured.

    Based on the article

    "Basically, if you happen to be accessing the request context in Application_Start, you have two choices:

   1. Change your application code to not use the request context (recommended).
   2. Move the application to Classic mode (NOT recommended).

    I chose option one otherwise I would have stayed with IIS 6. So what I did is follow his recommended solution and move the Extension loading part of BlogEngine.NET to the BeginRequest but made provisions so that it is only loaded on the first request (and once).

Copying from the article:

void Application_BeginRequest(Object source, EventArgs e)


    HttpApplication app = (HttpApplication)source;

    HttpContext context = app.Context;

    // Attempt to peform first request initialization





    private static bool s_InitializedAlready = false;

    private static Object s_lock = new Object();

    // Initialize only on the first request

    public static void Initialize(HttpContext context)


        if (s_InitializedAlready)




        lock (s_lock)


            if (s_InitializedAlready)




            // *** Perform first-request initialization here … ***

            s_InitializedAlready = true;





And that's it for the FIRST issue.


2) Site worked, but hmmm.. the styles are not being applied. Looking at the code, BlogEngine.NET uses httpHandlers to link to the stylesheets. Something like (depending on the theme name you have)

<link href="/blog/themes/BrightSide/css.axd?name=style.css" rel="stylesheet" type="text/css" />
Accessing the link directly in the browser didn't return anything (not found) while doing the same on the old hosting account (IIS 6) returned the style info succesfully. So there must be something wrong with the
handlers and modules. 

Luckily I found this IIS 7.0 Integrated Mode Configuration Changes from BE.NET forum


Go ahead and read the article, but the bottomline is : in the web.config move the module and handler configuration sections from the <system.web> to <system.webserver> and a few minor changes. Resulting in (assuming you didn't make changes in this section since you downloaded BlogEngine.NET)


        <add name="UrlRewrite" type="BlogEngine.Core.Web.HttpModules.UrlRewrite" preCondition="managedHandler" />
        <add name="ReferrerModule" type="BlogEngine.Core.Web.HttpModules.ReferrerModule" preCondition="managedHandler" />
<add name="CompressionModule"
preCondition="managedHandler" />
preCondition="managedHandler" />
        <!–The CleanPageModule below removes whitespace which makes the page load faster in IE. Enable at own risk –>
        <!–<add name="CleanPageModule" type="BlogEngine.Core.Web.HttpModules.CleanPageModule, BlogEngine.Core"/>–>

        <!–Remove the default ASP.NET modules we don't need–>
        <remove name="Profile" />
        <remove name="AnonymousIdentification" />

<add name="FileHandler" verb="*" path="file.axd"
type="BlogEngine.Core.Web.HttpHandlers.FileHandler, BlogEngine.Core"
        <add name="ImageHandler" verb="*" path="image.axd"
        <add name="SyndicationHandler" verb="*"
        <add name="SiteMap" verb="*" path="sitemap.axd" type="BlogEngine.Core.Web.HttpHandlers.SiteMap, BlogEngine.Core" />
<add name="TrackbackHandler" verb="*" path="trackback.axd"
BlogEngine.Core" />
        <add name="PingbackHandler" verb="*"
BlogEngine.Core" />
        <add name="OpenSearchHandler" verb="*"
BlogEngine.Core" />
        <add name="MetaWeblogHandler" verb="*"
BlogEngine.Core" />
        <add name="RsdHandler" verb="*"
path="rsd.axd" type="BlogEngine.Core.Web.HttpHandlers.RsdHandler,
BlogEngine.Core" />
        <add name="CssHandler" verb="*"
path="css.axd" type="BlogEngine.Core.Web.HttpHandlers.CssHandler,
BlogEngine.Core" />
        <add name="JavaScriptHandler" verb="*"
path="js.axd" type="BlogEngine.Core.Web.HttpHandlers.JavaScriptHandler,
BlogEngine.Core" />
        <add name="RatingHandler" verb="*"
path="rating.axd" type="BlogEngine.Core.Web.HttpHandlers.RatingHandler,
BlogEngine.Core" />
        <add name="OpmlHandler" verb="*"
path="opml.axd" type="BlogEngine.Core.Web.HttpHandlers.OpmlHandler,
BlogEngine.Core" />
        <add name="MonsterHandler" verb="*"
type="BlogEngine.Core.Web.HttpHandlers.MonsterHandler, BlogEngine.Core"
        <add name="BlogMLExportHandler" verb="*" path="blogml.axd"
BlogEngine.Core" />

And that did it for me 🙂


.NET Tools and Utilities

remove malicious script tags from file

Here's a small Windows Forms application that I created to automate removal of malicious SCRIPT tags inserted into some web files. [more] (or in general – even non malicious scripts).

Of course, you can always do this manually but if we're talking of hundreds or thousands of files, it will be one heck of a job.

The idea is to:

1) retrieve list of all script tags in all files in a given folder (including subfolders)

2) list scripts found

3) select the scripts to remove – ALSO, if the script contains line break, select it then click on the [View Script Detail] button. Also note that the checkedListBox is not set to check on click

4) set a folder to save the "cleaned" file

5) then process (remove the selected scripts and they will be saved on the Target Folder – retaining their folder hierarchy)

That's it

Here's a glimpse at the "core" code for the application. Note that I employed recursion inside of the faster, better performing stack approach for simplicity.

The complete source code can be downloaded below. Along with the output (executable).

** Search a root folder (and subfolder and files) for script tags (and their contents ofcourse)

   70 // recursive

   71         private void SearchFolder(string newRootFolder)

   72         {

   73             DirectoryInfo rootDir = new DirectoryInfo(newRootFolder);

   74             foreach (FileInfo fi in rootDir.GetFiles())

   75             {

   76                 SearchFile(fi);

   77             }


   79             foreach (DirectoryInfo di in rootDir.GetDirectories())

   80             {

   81                 SearchFolder(di.FullName);

   82             }

   83         }


   85         private void SearchFile(FileInfo fi)

   86         {

   87             using (StreamReader sr = new StreamReader(fi.FullName))

   88             {

   89                 string fileContent = sr.ReadToEnd();

   90                 MatchCollection ms =

   91                     Regex.Matches(

   92                         fileContent,

   93                         @"<script([^>]*)>.*?</script>",

   94                         RegexOptions.Singleline); // handle line breaks inside script tags


   96                 foreach (Match m in ms)

   97                 {

   98                     if (checkedListBox1.Items.Contains(m.Value))

   99                         continue;


  101                     checkedListBox1.Items.Add(m.Value);

  102                 }

  103             }

  104         }

** Process a root folder (and subfolder and files), check if a script marked as to be removed is found, replace it with empty string (effectively removing it) then save the file on the Target Folder.


  106         // recursive

  107         private void ProcessFolder(string newRootFolder)

  108         {

  109             DirectoryInfo rootDir = new DirectoryInfo(newRootFolder);

  110             foreach (FileInfo fi in rootDir.GetFiles())

  111             {

  112                 ProcessFile(fi);

  113             }


  115             foreach (DirectoryInfo di in rootDir.GetDirectories())

  116             {

  117                 ProcessFolder(di.FullName);

  118             }

  119         }


  121         private void ProcessFile(FileInfo fi)

  122         {

  123             string path = fi.FullName;

  124             using (StreamReader sr = new StreamReader(path))

  125             {

  126                 string fileContent = sr.ReadToEnd();

  127                 StringBuilder sb = new StringBuilder(fileContent);

  128                 int origLength = sb.Length;

  129                 foreach (string stringToRemove in selectedScripts)

  130                 {

  131                     sb.Replace(stringToRemove, String.Empty);

  132                 }


  134                 if (sb.Length != origLength)

  135                 {

  136                     string newFilePath = path.Replace(textBox1.Text, textBox2.Text);

  137                     string newFileDirectory = Path.GetDirectoryName(newFilePath);

  138                     if (!Directory.Exists(newFileDirectory))

  139                     {

  140                         Directory.CreateDirectory(newFileDirectory);

  141                     }


  143                     string newFileContent = sb.ToString();

  144                     using (StreamWriter sw = File.CreateText(newFilePath))

  145                     {

  146                         sw.Write(newFileContent);

  147                     }

  148                 }

  149             }

  150         }

Files for Download: (11.11 kb) (10.57 kb)

Hope this helps in one way or another and as usual, feel free to make comments/corrections. This has been haphazardly made but tried my best to make it useful and working.


*** Note that this has some known limitations (due to the regex expression used):

1) script tags has spaces like <script>abc</script > (note that the end script tag has a script before >)

2) self closing script tags <script src="url" />

as there was no need for me to handle these cases, however should you need to handle them, feel free to drop me a message and I'll try to help out.

By the way, Happy 2009 everyone!

.NET Data Tools and Utilities

Performance, Measure and ANTS Profiler

Might need to create a separate page for notes on performance since I've been doing a lot of C# and database tuning lately but having them on this post so far. Here are some of my notes on performance [more]

* Before you optimize, ensure that your results are accurate first before optimizing. I would suggest Test Driven Development or at least some unit testing but that's another story. Just make sure your results are correct first otherwise your optimization is useless.

* Before you optimize, always MEASURE MEASURE MEASURE

* If you can measure without introducing extra code, go with it. Aside from saving time, it will keep your code clean and introduce what could be unnecessary complexity. And for this very reason I just purchase ANTS Profiler 4 from RedGate software. Another alternative is dotNetTrace from JetBrains and although I love Resharper from the same company I prefer ANTS profiler. I said prefer because as I haven't explored dotNetTrace that much, i would say it is really preference, UI/usability and being able to view the timings embedded in a window which shows the source code. Also like the call graph, drill down on significant methods in terms of time spent on it. I got a quote for a no support/update version of the software when I emailed RedGate about their pricing which is admittedly very high for a personal purchase when you are earning from a 3rd world country. So will be receiving fixes but not major upgrades (so as they say but haven't dug deep – besides the version looks pretty good and turns out to be very useful for me already). It really sucks to try to optimize something only to find out that it is not the bottleneck

* If your application involves database access and you're slow then more often than not your database is not tuned. And SQL Profiler and Database Tuning Advisor is a very good start. You can apply the recommendations or you can just evaluate them and make your own adjustments. In my experience however the recommended changes does make a lot of performance improvement. You think you know enough about indexes and database design? You might be surprised how much performance you can gain from these tools.

Again measure, measure, measure but if you can only identify some specific parts then data access seems like a good start.

* Then look into you application logic. Even if your code is optimized but your algorithm/logic is wrong, it will still turn out bad

* Also know about database/table statistics, indexed views and partition. If you can take advantage of partitions and involving considerable data access the improvement is quite impressive.

* <string>.SubString(…) does some considerable lifting so if you want to check if the first two chars in a string is equal to some other string then you should consider using <string>.StartsWith instead or avoid the SubString if you can

* Hashtable is faster than SortedDictionary, SortedList or List. I know I should provide stats for this (have a URL somewhere and will update this soon)

* When using nullable types, use <variable>.HasValue as much as possible than comparing using != null. Or even "!<var>.HasValue" vs. "== null". But avoid negation if you have to

Finally this list will grow soon hopefully and if feel like you disagree please feel free to comment and have other benefit from your thoughts too 🙂


Short Scattered Notes

I have some short notes to make and it might not be blogworthy so having them on this page instead 🙂 Will add to this from time to time. [more]

ASP.NET Security

* You have a web site/application deployed to IIS. You use <authentication mode="Windows"/>. You set the IIS site/virtual directory security to allow anonymous. Notice that if you try to get Page.User.Identity.Name you will always get an empty string. So even if you set to windows authentication, the anonymous access will take precedence. To have the windows user name available when accessing Page.User.Identity.Name (Or HttpContext.User.Identity.Name) you have to disable (uncheck) Allow Anonymous access in the site/virtual directory's Directory Security tab.

Performance (General)

* When tuning/optimizing performance the gurus always say "Measure, mesasure, measure" (i think I heard this first from Rico Mariani) and I couldn't agree any better. Premature optimization or optimization without measuring is definitely is most of the time useless. You are likely killing your time fixing something which is actually not a bottleneck.

* Take note of "measure, measue, measure" above but if your application involves data access and of course a data source, chances are high that you would gain a lot of improvement optimizing it. (also see SQL Performance below). I'm definitely not my to being a super optimizer but lately I optimized an application and work made to tune the database ALONE improved the performance by like 10 folds. When you are talking about million of iterations that's a lot of improvement.

SQL Performance

* To optimize query execution plan caching and thus reuse, use fully qualified names in queries. (eg. dbo.OrderDetail vs OrderDetail). For more query optimization tips read more from the following link : Recompilication of Queries from Technet


MCTS ADO.NET 3.5 Applications results out and passed

A good way to start a day. Just got an email regarding another latest addition to my cert list. Microsoft Certified Technology Specialist : .NET Framework 3.5 ADO.NET Applications [more]

The exam I took for this was 71-561 and when going live would become 70-561.

I was excited to come up with a new logo but when I added all MCTS certifications, I got this error: Maximum Lines Exceeded – Please Remove a Certification. 

So had to settle for an all MCTS 3.5 logo 🙂

I actually did not expect much from this exam due to my unfamiliarity with Synchronization Services. But I'm guessing the rest of the beta takers had the same difficulties 🙂


The training kit for 70-442 TS: Designing and Optimizing and Data Access for SQL 2005 also helped for this exam and it's a good read if not a must read for developers involved in Data Access with ADO.NET