Saturday, July 6, 2013

The cache file C:\Users\Admin\AppData\Local\Microsoft\Team Foundation\4.0\Cache\VersionControl.config is not valid and cannot be loaded.

If you are working with TFS and get the above error, the possibility is the VersionControl.config file is corrupted and because of which you are not able to connect to TFS Server from Visual Studio.

 To get rid of the problem I had to just delete the VersionControl.config file and tried connecting to TFS from Visual Studio, it creates a new config file and everything works fine.

Monday, July 1, 2013

Cannot create/shadow copy 'XXX' when that file already exists

By default shadow copy is enabled on every appdomain created by ASP.NET. Assemblies loaded will be copied to a shadow copy cache directory, and will be used from there. So that the original file is not locked and can be modified. An error you may encounter when running ASP.Net apps with the debugger is "Cannot create/shadow copy 'XXX' when that file already exists"

Quick Fix
You have to tell ASP.NET not to shadow copy the project assemblies to the ASP.NET temporary folders file by updating your web.config with the following entry:


<configuration>
   <system.web>
      <hostingEnvironment shadowCopyBinAssemblies="false" />
   </system.web>
</configuration>

Then restart your application.

Friday, June 21, 2013

Problem with converting int to string in Linq to entities

With EF v4 you can use SqlFunctions.StringConvert. There is no overload for int so you need to cast to a double or a decimal. Your code ends up looking like this:
var items = from c in contacts
        select new ListItem
        {
            Value = SqlFunctions.StringConvert((double)c.ContactId),
            Text = c.Name
        };

Saturday, April 27, 2013

MVC 4 Web Api IIS7.5 HTTP web config issues


<system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true" />
        
            <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
            <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv4.0" />
        </handlers>
</system.webServer>
ref : http://stackoverflow.com/questions/9703090/mvc-4-web-api-iis7-5-http-404-page-not-found
I was struggling with this as well. Fortunately, Steve Michelotti documented a solution that worked for me here.
At the end of the day, I enabled all verbs (verb="*") to the ExtensionlessUrlHandler-Integrated-4.0 handler in my web config.

How to change File and Folder permissions on windows OS using Command Line (CLI)?

The following commands will help to take the ownership of the directory and files:
D:\>takeown /f D:\path\to\directory /r /d y
D:\>icacls D:\path\to\directory /grant administrators:F /t

Thursday, April 18, 2013

jquery click event not firing?


Is this markup added to the DOM asynchronously? You will need to use live in that case:
The fact that you are able to re-run your script block and have it work tells me that for some reason the elements weren't available at the time of binding or the binding was removed at some point. If the elements weren't there at bind-time, you will need to use live (or event delegation, preferably). Otherwise, you need to check your code for something else that would be removing the binding.
Using jQuery 1.7 event delegation:
$(function () {

    $('.play_navigation').on('click', 'a', function (e) {
        console.log('this is the click');
        e.preventDefault();
    });

});
You can also delegate events up to the document if you feel that you would like to bind the event before the document is ready (note that this also causes jQuery to examine every click event to determine if the element matches the appropriate selector):
$(document).on('click', '.play_navigation a', function (e) {
    console.log('this is the click');
    e.preventDefault();
});


ref : http://stackoverflow.com/questions/5540561/jquery-click-event-not-firing