Monday, November 17, 2014

Could not locate the assembly "System.Web.Mvc,Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35,processorArchitecture=MSIL

Microsoft recent security update has resulted in compilation error.  After spending some time came across this link.  This is a known issue.

Error: Could not load file or assembly 'System.Web.Mvc, Version=4.0.0.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)


Cause of Error: Microsoft recent security update


Solution: Install Nuget Package Microsoft.AspNet.Mvc for all the project referencing System.Web.Mvc dll
Example: Install-Package Microsoft.AspNet.Mvc 

Sunday, November 16, 2014

Attempt by security transparent method 'WebMatrix.WebData.PreApplicationStartCode.Start()' to access security critical method 'System.Web.WebPages.Razor.WebPageRazorHost.AddGlobalImport(System.String)' failed.


Error: Attempt by security transparent method 'WebMatrix.WebData.PreApplicationStartCode.Start()' to access security critical method 'System.Web.WebPages.Razor.WebPageRazorHost.AddGlobalImport(System.String)' failed.


Solution: Install Nuget Package Microsoft.AspNet.WebHelpers
Example: Install-Package Microsoft.AspNet.WebHelpers


Could not load file or assembly 'WebMatrix.Data, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)


Error: Could not load file or assembly 'WebMatrix.Data, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Solution: Install Nuget Package Microsoft.AspNet.WebPages.Data
Example: Install-Package Microsoft.AspNet.WebPages.Data


Monday, September 08, 2014

Solution: SSD Drive not getting detected on Win 10 OS

Recently I have purchase Samsung - 850 EVO 500GB Internal Serial ATA Solid State Drive for Laptops - Black (Model: MZ-75E500B)  in order to boost the performance of my laptop.


Issue:  SSD Drive was not getting detected on Win 10 OS.

Solution:

This issue was occurring because SSD drive was new and their was no previous partition and disk was not been formatted.  Steps to overcome this problem:

  1. Open Control Panel
  2. Click on Administrative Tools
  3. Click on Computer Management
  4. Double click on Disk Management from the left pane.
  5. Select the unlabeled drive from middle pane. i.e. Select SSD Drive which will be unlabeled.
  6. Select disk from lower pane and right click > New Simple Volume...
  7. Click Next to the wizard for Size and drive letter.
  8. And then give drive a volume label name of your choice and begin format.
  9. Ones formatting is completed it will show: Healthy (Primary Partition).
  10. Now your disk drive will appear in windows explorer.


Refer to this video for more details and exact steps on how to perform: Why can I not see my new SSD or hard drive?



Issue:  Samsung Data Migration for cloning was not working on Win 10.

Error: Samsung Data Migration Cloning failed target disk has been disconnected -00001 (ffffffff)

Solution:

Samsung data migration utility CD which comes with SSD Drive hardware is still not compatible with Win 10, so you can either used different software for drive cloning or can degrade to previous version of windows on which samsung data migration utility will works just good.


Few other references you would find useful if run into any such issues:


Monday, July 07, 2014

Update Table from Another Table in SQL Server

Update Table from Another Table in SQL Server:  A simple scenario demonstrating how we can update Persons table with data from Employees table using update statement.  A simple but very effective query which can saves you from creating unnecessary cursor for updating from different tables.  By performance wise also Update statement is more efficient compared to creating update cursor.


Update DestTbl
Set DestTbl.ColumnABC = SourceTbl.ColumnXYZ
FROM    Employees SourceTbl
JOIN    Persons DestTbl
ON      DestTbl.KeyCol1 = SourceTbl.KeyCol5


Here:
SourceTbl stands for Source Table
DestTbl stands for Destination Table



Friday, July 04, 2014

C# Object to Json Object String Example

Single C# Object to Json Object String Example

Download:  https://github.com/dotnetguts/json2csharpAndcsharp2json

Install NewtonSoft.Json Nuget Package

C# Object we will be using in following example
class MemberPics
{
    public string PhotoName { get; set; }
    public bool IsModerated { get; set; }
}

Json Object String we will be using in following example
@"{'PhotoName':'mypic.jpg','IsModerated':'false'}"

Code Snippet
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace JsonPrac1
{
    class Program
    {
        static void Main(string[] args)
        {          
            string myJsonString = @"{'PhotoName':'mypic.jpg','IsModerated':'false'}";

            //From Json String to C# Object
            MemberPics cSharpObj = JsonConvert.DeserializeObject(myJsonString);         
            Console.WriteLine("Photo Name: " + cSharpObj.PhotoName + ",  IsModerated: " + cSharpObj.IsModerated);


            //From C# Object to Json String
            string jsonString = JsonConvert.SerializeObject(cSharpObj, Formatting.Indented);
            Console.WriteLine(jsonString);

            Console.WriteLine("Press any key to exit");
            Console.ReadLine();
        }
    }

    class MemberPics
    {
        public string PhotoName { get; set; }
        public bool IsModerated { get; set; }
    }
}


Output











C# Object Array to Json Object String Example

Install NewtonSoft.Json Nuget Package

C# Object we will be using in following example
class MemberPics
{
    public string PhotoName { get; set; }
    public bool IsModerated { get; set; }
}

Json Object String we will be using in following example
@"[
    {'PhotoName':'pic1.png','IsModerated':'true'},
    { 'PhotoName':'pic2.jpg','IsModerated':'true'}
]"

Code Snippet
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace JsonPrac1
{
    class Program
    {
        static void Main(string[] args)
        {
            string myJsonArrayString = @"[{'PhotoName':'pic1.png','IsModerated':'true'},{ 'PhotoName':'pic2.jpg','IsModerated':'true'}]";
         
            //From Json String to C# Object          
            List cSharpObjList = JsonConvert.DeserializeObject>(myJsonArrayString);
         
            foreach (var item in cSharpObjList)
            {
                Console.WriteLine("Photo Name: " + item.PhotoName + ",  IsModerated: " + item.IsModerated);
            }
         
            //From C# Object to Json String
            string jsonArrayString = JsonConvert.SerializeObject(cSharpObjList, Formatting.Indented);
            Console.WriteLine(jsonArrayString);

            Console.WriteLine("Press any key to exit");
            Console.ReadLine();
        }
    }

    class MemberPics
    {
        public string PhotoName { get; set; }
        public bool IsModerated { get; set; }
    }
}

Output















Json String to C# Object Example

Single Json Object String to C# Object Example

Download:  https://github.com/dotnetguts/json2csharpAndcsharp2json

Install NewtonSoft.Json Nuget Package

C# Object we will be using in following example
class MemberPics
{
    public string PhotoName { get; set; }
    public bool IsModerated { get; set; }
}

Json Object String we will be using in following example
@"{'PhotoName':'mypic.jpg','IsModerated':'false'}"

Code Snippet
using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace JsonPrac1
{
    class Program
    {
        static void Main(string[] args)
        {          
            string myJsonString = @"{'PhotoName':'mypic.jpg','IsModerated':'false'}";

            //From Json String to C# Object
            MemberPics cSharpObj = JsonConvert.DeserializeObject(myJsonString);         
            Console.WriteLine("Photo Name: " + cSharpObj.PhotoName + ",  IsModerated: " + cSharpObj.IsModerated);

            Console.WriteLine("Press any key to exit");
            Console.ReadLine();
        }
    }

    class MemberPics
    {
        public string PhotoName { get; set; }
        public bool IsModerated { get; set; }
    }
}


Output










Json Object Array String to C# Object List Example

C# Object we will be using in following example
class MemberPics
{
    public string PhotoName { get; set; }
    public bool IsModerated { get; set; }
}

Json Object String we will be using in following example
@"[
    {'PhotoName':'pic1.png','IsModerated':'true'},
    { 'PhotoName':'pic2.jpg','IsModerated':'true'}
]"

Code Snippet
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace JsonPrac1
{
    class Program
    {
        static void Main(string[] args)
        {
            string myJsonArrayString = @"[{'PhotoName':'pic1.png','IsModerated':'true'},{ 'PhotoName':'pic2.jpg','IsModerated':'false'}]";
         
            //From Json String to C# Object          
            List cSharpObjList = JsonConvert.DeserializeObject>(myJsonArrayString);

            foreach (var item in cSharpObjList)
            {
                Console.WriteLine("Photo Name: " + item.PhotoName + ",  IsModerated: " + item.IsModerated);
            }

            Console.WriteLine("Press any key to exit");
            Console.ReadLine();
        }
    }

    class MemberPics
    {
        public string PhotoName { get; set; }
        public bool IsModerated { get; set; }
    }
}

Output










Saturday, May 24, 2014

A connection was successfully established with the server, but then an error occurred during the login process. (Microsoft SQL Server, Error 233)

Error: A connection was successfully established with the server, but then an error occurred during the login process. (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.) (.Net SqlClient Data Provider)

Solution:

Step 1: Open SQL Server Configuration Manager

  • Go to Windows 8 Start screen.
  • Start typing in SQLServerManager11.msc if you are looking for SQL Server 2012 configuration manager. Type in SQLServerManager10.msc if you are looking for SQL Server 2008 configuration manager.
  • In the result panel you can see the SQLServerConfiguration Manager.
  • Click the icon to launch the SQL Server Configuration manager.
  • The configuration manager will open in MMC.



Step 2: Enable following configuration settings
  1. ensure Shared Memory protocol is enabled
  2. ensure Named Pipes protocol is enabled
  3. ensure TCP/IP is enabled, and s ahead of the Named Pipes in the settings

Login failed for user. (Microsoft SQL Server, Error 18456)

I was recently facing this error when created a SQL Server login and then try login using that newly created login.

Error: Login failed for user. (Microsoft SQL Server, Error 18456) (.Net SqlClient Data Provider)

Please note:
Solution is available on this link, but since microsoft has bad habit of link breaking issue; I have copied and pasted the solution for my reference.
http://support.microsoft.com/kb/555332



Cause:
Scenario 1: The login may be a SQL Server login but the server only accepts Windows Authentication.
Scenario 2: You are trying to connect by using SQL Server Authentication but the login used does not exist on SQL Server.
Scenario 3: The login may use Windows Authentication but the login is an unrecognized Windows principal. An unrecognized Windows principal means that Windows can't verify the login. This might be because the Windows login is from an untrusted domain.

Solution:

Scenario 1: Configure SQL Server in Mixed Authentication Mode.

SQL Server 2012, SQL Server 2008, and SQL Server 2005
  1. Open SQL Server Management Studio. To do this, click Start, click All Programs, click Microsoft SQL Server 200x (where x is the version of SQL), and then click SQL Server Management Studio.
  2. Right-click the server, and then click PropertiesSee image. 
  3. On the Security page, under Server authentication, click the SQL Server and Windows Authentication mode option button, and then click OKSee image. 
  4. In the SQL Server Management Studio dialog box, click OK to restart SQL Server.

    For more information, see Choose an authentication mode in SQL Server Books Online.
SQL Server 2000
  1. Open the Enterprise Manager. To do this, click Start, click All Programs, click Microsoft SQL Server 2000, and then clickSQL Server Enterprise Manager.
  2. Expand the server group.
  3. Right-click the server, and then click PropertiesSee image. 
  4. Click the Security  tab. See image. 
  5. Under Authentication, click the SQL Server and Windows option button.
  6. Restart SQL Server for the change to take effect.

Scenario 2: Verify that the SQL Server login exists

If you are trying to connect to the SQL Server by using SQL Server Authentication, and the server is configured for mixed mode authentication, verify that the SQL Server login exists. For more information, see Create a login in SQL Server Books Online.

Scenario 3: The login may use Windows Authentication but the login is an unrecognized Windows principal.

If you are trying to connect to SQL Server by using Windows Authentication, verify that you are logged in to the correct domain. 

Thursday, February 06, 2014

Free ASP.NET Training for 2014

Find this useful blog post on Scott hanselman blog

Bookmark for to do list


And more...

Source:
http://www.hanselman.com/blog/BuildingModernWebAppsWithASPNETANewDayOfFreeASPNETTrainingFor2014.aspx

Most Recent Post

Subscribe Blog via Email

Enter your email address:



Disclaimers:We have tried hard to provide accurate information, as a user, you agree that you bear sole responsibility for your own decisions to use any programs, documents, source code, tips, articles or any other information provided on this Blog.
Page copy protected against web site content infringement by Copyscape