Fiddler–Compare two sessions

clock November 13, 2011 00:30 by author Galcho |

I’ve just found very useful feature in Fiddler – comparing two sessions (HTTP request and response). Even more useful – the compare tool can be configured via registry settings:

To configure Fiddler to point to it:

  • Close Fiddler.
  • Run RegEdit
  • Navigate to HKCU\Software\Microsoft\Fiddler2
  • Add a new REG_SZ named CompareTool
  • Set the new registry value to the path to your text comparison tool.


How to add Google+1 button to BlogEngine.net

clock October 9, 2011 08:36 by author Galcho |

After adding Facebook “Like” button to my blog I’ve decided to add Google+1 button as well Smile. I guess I am also going social although a little old fashioned with blog.

Again it is very easy to add it with two simple steps:

1. Add the tag to the template in order to appear in every post.

Open ~/themes/MY-BLOG_THEME and edit PostView.ascx by adding following script where appropriate:

<!-- Place this tag where you want the +1 button to render -->
<g:plusone size="small" annotation="inline" href="<%=Post.PermaLink %>"></g:plusone>

2. Add google JS at the end of the page.

Open ~/themes/MY-BLOG_THEME and edit site.master and add this at the end:

<!-- Place this render call where appropriate -->
<script type="text/javascript">
  (function() {
    var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
    po.src = 'https://apis.google.com/js/plusone.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
  })();
</script>

Please refer to google documentation for more information and to configurator to customize



T-SQL Number Generator

clock November 3, 2010 20:55 by author Galcho |

Here is some more T-SQL fun: number generator Smile I found this code in comments of this blog post and it is so cools so I decided to save it here for reference:

-- use number generation
WITH Numbers3( n ) AS ( SELECT 1 UNION SELECT 0 ),
     Numbers2( n ) AS ( SELECT 1 FROM Numbers3 n1 CROSS JOIN Numbers3 n2 ),
     Numbers1( n ) AS ( SELECT 1 FROM Numbers2 n1 CROSS JOIN Numbers2 n2 ),
     Numbers0( n ) AS ( SELECT 1 FROM Numbers1 n1 CROSS JOIN Numbers1 n2 ),
     NumbersBase ( n ) AS ( SELECT 1 FROM Numbers0 n1 CROSS JOIN Numbers0 n2 ),
     Numbers ( Number ) AS 
     ( 
         SELECT n
         FROM ( SELECT ROW_NUMBER() OVER (ORDER BY n)
         FROM NumbersBase ) D ( n )
         WHERE n <= 50
      )
      
SELECT * FROM Numbers


T-SQL: Get Date and Hour

clock November 3, 2010 18:36 by author Galcho |

I am back in T-SQL fun and had interesting problem to solve – group rows by date and hour but eliminate minutes, seconds and milliseconds. Thus here is a handy function to do that:

DECLARE @Date datetime= getdate();

SELECT DATEADD(ms, -1*DATEPART(ms, @date), -- remove milliseconds
    DATEADD(SECOND, -1*DATEPART(SECOND, @date), -- remove seconds
    DATEADD(MINUTE, -1*DATEPART(MINUTE, @date), -- remove minutes
        @date)))

I hope you know how to create function from this code Smile.

Have fun!



MSBuild - Debug a msbuild script–enters the debug switch

clock October 23, 2010 00:11 by author Galcho |

It would be great if it was possible to debug msbuild script. Step in, step out, see properties and values… Seems like there is a way to do it via VS2010 although unsupported. What needs to be done is:

  1. Ensure you debug “Just my code”:
  2. Enable undocumented "/debug" switch on MSBuild.exe by adding registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\4.0 key to have debuggerenabled=true. Execute this in command prompt:
    reg add HKLM\SOFTWARE\Microsoft\MSBuild\4.0 /v DebuggerEnabled /t REG_SZ /d true
  3. Check /debug switch:
    MSBuild /?
  4. Run your build with /debug switch:
    MSBuild MyCode.proj /debug
  5. Once you get standard JIT debugging prompt make sure you select "Manually choose the debugging engines".
  6. Select Managed mode only:
  7. Enjoy

 

Thanks to Visual Studio blog and Dan Smile

Also John Robins has a way to do it but I didn’t try it…



VS2010: Cannot change the specified .NET framework version or profile for a test project

clock October 6, 2010 19:21 by author Galcho |

I received the error message "attempted re-targeting of the project has been canceled. You cannot change the specified .NET framework version or profile for a test project" when trying to target the .NET 3.5 framework after upgrading to Visual Studio 2010.

And this was tricky – we want to move to VS 2010 but still compile against .NET .3.5. Although having tests target .NET 4 is not critical is not very nice. We don’t want to have bugs slipped out because production code and test code are compiled against different .NET versions.

Luckily there is a solution – manually editing .csproj file and trick VS2010 to think it is not a test class library but simply class library:

  1. Open .csproj file with notepad.
  2. Search for this line:
  3. <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};
    {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
  4. Remove {3AC096D0-A1C2-E12C-1390-A8335801FDAB} guid
  5. Save file and Open in VS 2010
  6. It is ready to be re-targeted

Hope this helps



TFS 2010 Basic: Server build of Windows Phone 7 project

clock October 4, 2010 06:09 by author Galcho |

I just started taking advantage of TFS 2010 Basic (or TFS 2010 for SourceSafe users as Brian Harry named it Smile) and found something interesting to share. The project I was testing with is Windows Phone 7 one and it was building perfectly form VS 2010. But when triggered a server build the agent fails with following error:

C:\Program Files (x86)\MSBuild\Microsoft\Silverlight for Phone\v4.0\Microsoft.Silverlight.Common.targets (185): The "CompileXaml" task failed unexpectedly. System.IO.FileLoadException: Could not load file or assembly 'PresentationCore, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047) File name: 'PresentationCore, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'  Server stack trace:     at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)    at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks)    at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)    at System.Reflection.Assembly.Load(String assemblyString)    at Microsoft.Silverlight.Build.Tasks.CompileXaml.LoadSilverlightAssemblies(String[] frameworkPaths)    at Microsoft.Silverlight.Build.Tasks.CompileXaml.GenerateCode(ITaskItem item, Boolean isApplication)    at Microsoft.Silverlight.Build.Tasks.CompileXaml.Execute()    at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)    at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)  Exception rethrown at [0]:     at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)    at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)    at Microsoft.Build.Framework.ITask.Execute()    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()    at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask, Boolean& taskResult) 

As the name of TFS 2010 Basic suggests I have everything on same machine – VS 2010, TFS server, build controller, build agent… and it still failed.

The solution is in Build definitions: set MSBuild platform to X86:

image


Seems like Windows Phone 7 projects need to be build using x86 as a target platform only…

Hope this helps



VS 2010: Executing Unit Tests in parallel

clock October 1, 2010 15:27 by author Galcho |

This almost slipped out of my sight. Visual Studio 2010 adds an option to execute unit tests in parallel. Probably it would be obvious but let me emphasis that all multithreading issues could arise and let tests fails in such case. So all tests must be thread safe and tested code as well…

The option to enable this is very hidden Smile It is not exposed via VS GUI but in .testsettings file instead. It has to be edited in XML editor and add to <Execution> parallelTestCount attribute greater than 1(e.g. parallelTestCount=”4”)

Hope this helps



How to install the Windows Phone 7 Developer Tools on Windows Server 2008

clock September 25, 2010 07:27 by author Galcho |

Probably many of of you are like me – working on Windows Server (2008 R2) and wondering how to install the Windows Phone 7 Developer Tools on server OS. Luckily Aaron Stebner posted a solution on his blog:

There is a way you can work around the Windows Server 2008 setup block if needed.  Please note that this is not officially supported, so if you try these steps, you are doing so at your own risk.

  1. Download the Windows Phone Developer Tools web bootstrapper and save it to your hard drive
  2. Extract the contents of the setup package by running vm_web.exe /x and choosing a path to extract to
  3. Go to the folder you extracted to in step 2 and open the file baseline.dat in notepad
  4. Look for the section named [gencomp7788]
    Note - you have to change this exact section - this is the one that controls the OS version blocking behavior in Windows Phone Developer Tools setup.
  5. Change the value InstallOnLHS from 1 to 0
  6. Change the value InstallOnWin7Server from 1 to 0
  7. Save and close baseline.dat
  8. Run setup.exe /web from the folder you extracted to in step 2
    Note - please make sure that you include the /web command line parameter in step 8.  If you don't, setup will not attempt to download the packages it needs to install, and it will fail to install correctly as a result.

Neat… Thanks Aaron!



Silverlight 4: Setting a global application theme

clock August 31, 2010 18:12 by author Galcho |

I am creating a SL4 application and I was looking for a way to make more shinier. Of course themes come to play here but the big questions is “How to setup a global theme?”

Search results returned a bunch of ideas with a lot of code like merging dictionaries etc… And I was thinking it should be simple, very simple.

I came across this post about Silverlight4 Toolkit April 2010 release. But still what suggested there didn’t work for me:

<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
             x:Class="ToolkitSamplesApril10.App"
             xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
             toolkit:BureauBlackTheme.IsApplicationTheme="True">
    <Application.Resources>
    </Application.Resources>
</Application>

For some reason the highlighted part failed come into play. No result was seen…

So I found this very, very simple way. Just put those two lines in App.xaml.cs:

using ActiveTheme = System.Windows.Controls.Theming.BureauBlackTheme;
....
private void Application_Startup(object sender, StartupEventArgs e)
{
    ActiveTheme.SetIsApplicationTheme(this, true);
    this.RootVisual = new MainPage();
}

Hope this helps,