Tuesday, June 14, 2016

Fiddler and vshub requests

If you debug a web-site project using Visual Studio 2015 or higher, you may see a ton of requests to the URL /vshub/ in fiddler. These requests are used by Visual Studio and the VsHub process to communicate with each other and are not actually related to your website.

So what can you do?

1. You can setup a filter to filter out the /vshub/ uris.

2. I prefer custom rule that I can turn on or off and here is what it looks like:

Edit the customRules.js file (Rules > Customize Rules).

Add the following lines to class Handler

public static RulesOption("Display VSHUB Requests")
var m_bShowVshubRequests: boolean = false;

In “OnBeforeRequest” add the following code:

static function OnBeforeRequest(oSession: Session) {
      
        if (!m_bShowVshubRequests && oSession.uriContains("/vshub/"))
        {
            oSession.Ignore(); //oSession["ui-hide"] = "true";
        }

And now by default it will never show and if you want to look at it, you can do so by enabling it at:

image

Tuesday, May 24, 2016

How to feed your baby step by step

Its hard to know how much to feed your new-born. Here is a hand out that we received from our doctor (Partners in Pediatrics) that I found extremely helpful.

image

HOW TO FEED YOUR BABY STEP BY STEP 
Every baby is very special. This is a general guide for feeding your baby, so don't worry if your baby eats a little more or a little less than this guide suggests.

Tuesday, April 26, 2016

CRM XRM service including error information

Here is what you need to add to the web.config of the CRM website so that you can see why the XRM service maybe failing on a call:

<system.serviceModel>

    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />

     <behaviors>

      <serviceBehaviors>

        <behavior>

          <serviceDebug includeExceptionDetailInFaults="true" />

        </behavior>

      </serviceBehaviors>

    </behaviors>

  </system.serviceModel>

Friday, April 15, 2016

RegionManager.RequestNavigate is not working!

This is not so much a solution, but a debugging hint.

Recently I was banging my head for hours on a RequestNavigate not working. After a lot of googling and head banging, I found out that RequestNavigate has a callback and it has useful error information that can help in determining the issue.

The signature is: public static void RequestNavigate(this IRegionManager regionManager, string regionName, Uri source, Action navigationCallback)

And here is how you can use it:

_regionManager.RequestNavigate(RegionNames.MainRegion, uri, nr =>
{
if (nr.Result.HasValue && nr.Result == false)
{
//put a breakpoint in here to determine why. nr.Error will have the data
var error = nr.Error;
}
});

In my case, I found out that the caller was on a background thread and hence, the navigation was failing silently. By subscribing to my event on the UI thread, I was able to solve my issue!

Saturday, December 19, 2015

TMS Dining Nook Assembly Instructions

I had a hard time finding the instructions for this dining nook. NOw that I have it, thought I would post it for others that might have lost it and need it again: https://drive.google.com/file/d/0BzvtUeIvT94walYzbGl4R2o3VTA/view

Thursday, October 15, 2015

Windows 10 – BSOD on resuming from hibernate

After upgrading my machine to Windows 10, I found that after I hibernated by computer, it would always BSOD on resuming with the error: SYSTEM_SERVICE_EXCEPTION (cng.sys). After a whole bit of troubleshooting and nothing working, I found an old post regarding a similar failure on Windows 7. It suggested turning off Hyper-V (via Windows Features).

image

Turning it off on my Windows 10 machine, seemed to make the BSOD issue go away.

Monday, September 28, 2015

Importing Windows Event Log into SQL Server

LogParser is your friend: http://www.microsoft.com/en-us/download/details.aspx?id=24659

Here is a sample command to import the data into SQL Server:

LogParser -i:EVT "SELECT * into prodEvents FROM  c:\temp\prod.evtx" -o:SQL -server:sqlServerName -driver:"SQL Server" -database:testDb -createtable:ON  -cleartable:ON -transactionRowCount:-1  -maxstrfieldlen:8000

note: use -username:test -password:test to specify username and password if you need to.
note: I cant seem to find a way around the 8000 character limit in LogParser. So it always truncates at 8000 characters :(

The table definition is:

CREATE TABLE [dbo].[prodEvents](
    [EventLog] [varchar](8000) NULL,
    [RecordNumber] [int] NULL,
    [TimeGenerated] [datetime] NULL,
    [TimeWritten] [datetime] NULL,
    [EventID] [int] NULL,
    [EventType] [int] NULL,
    [EventTypeName] [varchar](8000) NULL,
    [EventCategory] [int] NULL,
    [EventCategoryName] [varchar](8000) NULL,
    [SourceName] [varchar](8000) NULL,
    [Strings] [varchar](8000) NULL,
    [ComputerName] [varchar](8000) NULL,
    [SID] [varchar](8000) NULL,
    [Message] [varchar](8000) NULL,
    [Data] [varchar](8000) NULL
) ON [PRIMARY]

Keep in mind that you can run many SQL like queries directly against the EVT file locally on your machine without importing the data into a table.

Other useful queries:

logparser.exe -i:evt "select * from c:\temp\prod.evtx where timegenerated > '2015-09-01 00:00:00'"

More info:

Useful commands and tips: (for ASP.net, but useful even for Event Logs) https://support.microsoft.com/en-us/kb/910447

Monday, March 30, 2015

Visual Studio rebuilds all projects instead of just the projects referenced by the current project

One of our Visual Studio solutions all of sudden started building all projects in the solution, even when I was trying to build one single project.

I found that Visual Studio allows you to set a flag in the registry that allows you to see more information regarding why it thinks a project is out of date and is trying to build it. The setting is called: U2DCheckVerbosity, which I believe stands for “Up to Date Check” verbosity level. By setting it to a value of 1, you get information in the output window that specifies why VS believes a project is not up to date and is causing it to build.

You can either create the new key manually, or copy the following text into notepad and save it as a REG file and run it.

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0\General]
"U2DCheckVerbosity"=dword:00000001

Once thats done, if you look in the output window, you will see messages like:

Project ‘xxxxxx’ is not up to date. Project item ‘some_file_path\log4net.config' has 'Copy to Output Directory' attribute set to 'Copy always'.

I had not realized that “Copy Always” would cause a project to consider itself dirty and had gone through and set it on some config files I had recently added. So it turned out, it was I that was at fault. Fixed the config issue and everything is good now.

Wednesday, June 11, 2014

The ASP.Net MVC 5 Application Lifecylce

from: http://www.asp.net/mvc/tutorials/mvc-5/lifecycle-of-an-aspnet-mvc-5-application

Highlevel Overview:

image

Detail – Execution pipeline:

image

HTTPApplication Processing Pipeline

image

HttpApplication Processing Pipeline – Process of request (MvcHandler executes the controller action)

image

image

Authentication:

image

image

Authorization:

image

Sunday, June 01, 2014

Please do not implement a finalizer willy-nilly!

I see many people implement the finalizer when they implement the dispose pattern in c#.

class MyDisposableClass : IDisposable
{
   public void Dispose()
   {
      Dispose(true);
      GC.SuppressFinalize(this);          
   }

   protected virtual void Dispose()
   {
   }

   ~MyDisposableClass()
   {
      Dispose();
   }
}

Please don’t do this (implement the finalizer)  unless your class uses unmanaged resources! One reason for this is that if you access managed resources in your Dispose method, they may have already been garbage collected if the Dispose method was called via the finalizer!

Here are some things to consider: (all pulled from MSDN documentation)

  1. The dispose pattern is used only for objects that access unmanaged resources, such as file and pipe handles, registry handles, wait handles, or pointers to blocks of unmanaged memory. This is because the garbage collector is very efficient at reclaiming unused managed objects, but it is unable to reclaim unmanaged objects. (http://msdn.microsoft.com/en-us/library/fs2xkftw(v=vs.110).aspx)
  2. Finalizers are notoriously difficult to implement correctly, primarily because you cannot make certain (normally valid) assumptions about the state of the system during their execution. (http://msdn.microsoft.com/en-us/library/b1yfkh5e(v=vs.110).aspx)
  3. If a type does override the Finalize method, the garbage collector adds an entry for each instance of the type to an internal structure called the finalization queue. The finalization queue contains entries for all the objects in the managed heap whose finalization code must run before the garbage collector can reclaim their memory. The garbage collector then calls the Finalize method automatically…. (http://msdn.microsoft.com/en-us/library/system.object.finalize(v=vs.110).aspx)

Remember: Finalizers are typically not needed and even when needed there are better patterns available that allow you to side-step implementing the finalizer (eg: SafeHandle).

Note:

  1. Even if you implement the Finalizer “correctly” such that when you call Dispose, it only cleans out unmanaged resources, if you don’t have unmanaged resources, you have introduced a tiny performance penalty into your app and allow someone else to introduce bugs. So if you see a finalizer, check to see if you REALLY need it and if you don’t, get rid of it (and maybe even the implementation of the IDisposable interface.
  2. Sometimes the Dispose pattern is implemented to free up managed memory being used by the class. Again if you have written your code well, you should be able to rely on the .Net garbage collector to free up the memory for you.

Correctly implemented Dispose pattern

class CorrectlyImplementedDisposableClass: IDisposable
{
   bool disposed = false;

   public void Dispose()
   { 
      Dispose(true);
      GC.SuppressFinalize(this);           
   }

   protected virtual void Dispose(bool disposing)
   {
      if (disposed)
         return; 

      if (disposing) {
         // Free any other managed objects here.  }

      // Only Free unmanaged objects here.  disposed = true;
   }
}
 
class CorrectlyImplementedFinalizedClass: CorrectlyImplementedDisposableClass
{
   ~CorrectlyImplementedDisposableClass()
   {
      Dispose(false);
   }
}