Showing posts with label mvc. Show all posts
Showing posts with label mvc. Show all posts

Monday, June 15, 2015

The "SqlBuildTask" task failed unexpectedly. System.IO.FileNotFoundException

Hey Guys,

While you were building a solution with a DB project inside MVC app, you may see a build error like below.

Error 10 04018: The "SqlBuildTask" task failed unexpectedly.
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.SqlServer.TransactSql, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.
File name: 'Microsoft.SqlServer.TransactSql, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91'
   at Microsoft.Data.Tools.Schema.Sql.Build.SemanticVerification.Verify(SqlSchemaModel model, ErrorManager errorManager, String databaseName, String referencesFilePath)
   at Microsoft.Data.Tools.Schema.Sql.Build.SqlTaskHost.RunExtendedValidation(String databaseName, String referencesFile)
   at Microsoft.Data.Tools.Schema.Tasks.Sql.SqlBuildTask.ExecuteValidateModelStep()
   at Microsoft.Data.Tools.Schema.Tasks.Sql.SqlBuildTask.ExecuteStep(Func`1 step)
   at Microsoft.Data.Tools.Schema.Tasks.Sql.SqlBuildTask.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__20.MoveNext()

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

Solution:

Go to the project properties of the error throwing project and uncheck


That's it, your solution should build as normal.

Tuesday, June 9, 2015

'System.Web.WebPages.Html.HtmlHelper' does not contain a definition for 'DropDownListFor' and no extension method 'DropDownListFor' accepting a first argument of type 'System.Web.WebPages.Html.HtmlHelper' could be found (are you missing a using directive or an assembly reference?)

If you are working on Visual Studio 2013 Premium and started to work on MVC 4 or 5 project. You will be probably experiencing this error while building your solution. MVC Razor mark ups were not recognized and intellisence were not working. I think I have figure out the fix.

I tried below options from several posts (mentioned in the end of this post)

Attempt 1:

1.Check /Views/ web.config
2.Check the Razor reference syntax is like below

<configSections>
    <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
      <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
      <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
    </sectionGroup>
  </configSections>
 
  <system.web.webPages.razor>
    <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.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.Routing" />
        <add namespace="System.Web.Optimization" />
        <add namespace="Orca.Web" />
      </namespaces>
    </pages>
  </system.web.webPages.razor>

(I'm working on MVC 5)

Attempt 2:

Clean the solution and close VS 2013 premium. Deployed Update 4 for Visual Studio 2013 Premium. Start the VS and clean the solution and rebuild. Yup That's it! Worked successfully.