Monday, June 17, 2013

MVC: Intellisense for custom HtmlHelpers or if you want to avoid @using to import namespaces

If you write custom HtmlHelpers its quite tedious to have to add @using your.namespace.to.your.htmlHelpers on top of each page. To be able to use your newly written htmlhelpers

to avoid this just find the web.config in your views folder and locate the following section:
<system.web.webPages.razor>
        <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <pages pageBaseType="System.Web.Mvc.WebViewPage">
            <namespaces>
                <add namespace="System.Web.Mvc" />
                <add namespace="System.Web.Mvc.Ajax" />
                <add namespace="System.Web.Mvc.Html" />
                <add namespace="System.Web.Optimization"/>
                <add namespace="System.Web.Routing" />
                <add namespace="SharpSolutions..MvcApplication.Helpers.BootStrap"/>
                <add namespace="SharpSolutions.MvcApplication.Helpers"/>
            </namespaces>
        </pages>
    </system.web.webPages.razor>

and add your custom namespace to it.

After you have done this reload your mvc project (or close Visual Studio and reopen it).

Tuesday, June 11, 2013

Windows Azure Logging not working Trace.TraceError throws: Not running in a hosted service or the Development Fabric.

I had the following line in my web.config:

<system.diagnostics>
    <trace>
      <listeners>
    <add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
   name="AzureDiagnostics">
     <filter type="" />
    </add>
      </listeners>
    </trace>
  </system.diagnostics>

After removing this: it created WAWSAppLogTable as expected.
More info can be found here: www.windowsazure.com


for local debugging I left the line untouched... I created a new config transformation where I added:

<system.diagnostics>
  <trace>
   <listeners>
    <add name="AzureDiagnostics" xdt:Locator="Match(name)" xdt:Transform="Remove" />
   </listeners>
  </trace>
 </system.diagnostics>


Which is quite logic since Azure websites is not hosted in the AppFabrik

Friday, June 07, 2013

Team Foundation 2012: Run xUnit unit tests

Currently I am using https://tfs.visualstudio.com/ and writing my unit tests with xUnit. To enable this follow the steps outlined on MSDN.


You can find the binaries in the packages folder in your solution directory