Trouble hosting application using ServiceStack.Razor - servicestack

When installing the servicestack.razor-package, it transforms the web.config file
<assemblies>
<add assembly="System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
When developing this runs fine, but when I'm deploying the solution to Windows Server 2012, the assembly cannot be found, giving me this error when loading the application:
<assemblies>
<add assembly="System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
Can anyone please give me any insight to how I can get my environment to host my application? Copying this single dll or installing Visual Studio on my server isn't my preferred option.
Thanks!

If System.Web.WebPages.Razor is a dependency that your application needs and it's not in the GAC of your server then you do need to copy that file.
MVC and Razor support are not included in the standard .NET Framework deployment, because they should be deployed as part of the solution.
You could install Microsoft WebMatrix v1 on the server, which should then add that library to the GAC on your server, but to me that seems like overkill when copying should be sufficient.
I would copy System.Web.WebPages.Razor.dll to the bin folder.

Related

CS0012 The type 'XtraReport' is defined in an assembly that is not referenced

I recently updated my visual studio to 2017 Enterprise.
I used to use DevExpress v15.1
Today, I upgraded my DevExpress to version 18.1 and when I build my .Net MVC5 Application Solution, I got the following error
The type 'XtraReport' is defined in an assembly that is not
referenced. You must add a reference to assembly
'DevExpress.XtraReports.v15.1, Version=15.1.8.0, Culture=neutral,
PublicKeyToken=b88d1754d700e49a'.
The above Error is located in ReportController.cs
I checked my references Folder under the project to find that the DevExpress.XtraReports.v18.1 is there.
What might be the cause of this error?.
Thank you for your help.
Based from the message, the XtraReport still references the older version of its DLL assembly:
'DevExpress.XtraReports.v15.1, Version=15.1.8.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a'
Usually this problem occurred because Project Converter failed to update XtraReport related references after upgrade. In this case, you can manually remove all references to older assemblies (version 15.1) and then add references to new assemblies (version 18.1).
Also make sure that web.config file has these assembly information like below example (X indicates revision number):
<add assembly="DevExpress.XtraReports.v18.1, Version=18.1.X.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
<add assembly="DevExpress.XtraReports.v18.1.Web, Version=18.1.X.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
If the solution above failed, try install the assemblies to the Global Assembly Cache (GAC) by navigating to X:\Windows\assembly (X stands for the system drive letter) and copy all new DevExpress assemblies to that folder (including DevExpress.XtraReports.v18.1), as mentioned in this issue.
Related issues:
Errors after upgrading DevExpress version
DevExpress.XtraReports.UI.XtraReport is not defined after upgrade
The type 'DevExpress.XtraReports.UI.XtraReport' is defined in an assembly that is not referenced

ASP.NET Boilerplate MVC 5.x template fails to start

After downloading ASP.NET MVC 5.x template, I update the connection string, restore NuGet packages and then try to run Update-Database command in Package Manager Console, but I consistently get the following error:
Could not load file or assembly 'Castle.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
I was able to solve this once by removing all packages and adding them back one at a time, but this is extremely time-consuming.
I have had this same experience with both the Angular and Multipage versions, and I am using VS2017 Community.
What am I doing wrong?
in the Web project's web.config it reads:
<dependentAssembly>
<assemblyIdentity name="Castle.Core" publicKeyToken="407dd0808d44fbdc" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
You can remove that binding redirect.

Error doing web.config transformation for different environments

I was trying to deploy my app into different environments then i started following this how to:
Deploying an ASP.NET Web Application to a Hosting Provider using Visual Studio or Visual Web Developer: Web.Config File Transformations - 3 of 12
was perfect until I clicked in Preview Transform, I received this error:
Microsoft Visual Studio
Could not load file or assembly 'Microsoft.Web.XmlTransform, Version=1.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
(I created just one transformation Web.DebugQA.config and of course the default ones, debug and release)
my Web.DebugQA.config looks like this:
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<connectionStrings>
<add name="MyDB"
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
<system.web>
</system.web>
<appSettings>
<add key="EnvironmentName" value="QADev" xdt:Transform="SetAttributes(value)"
xdt:Locator="Match(key)" />
</appSettings>
</configuration>
but then I install this plugin:
SlowCheetah - XML Transforms
and I solved my preview transform error, but then when I was trying to publish using the QADev transform I got this error:
The "ImportParametersFile" task failed unexpectedly.
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Web.XmlTransform, Version=1.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
File name: 'Microsoft.Web.XmlTransform, Version=1.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
at Microsoft.Web.Publishing.Tasks.ImportParametersFile.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].
I'm using Visual Studio Pro 2012.
I fixed this by repairing "Microsoft ASP.NET and Web Tools 2013.1 - Visual Studio 2012" from Control Panel --> Programs and Features.
The file Microsoft.Web.XmlTransform.dll was missing from the path C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web.
I had a similar error, although it was caused for different reasons.
I solved it copying the following DLL from another PC with VS2012 installed:
Microsoft.Web.XmlTransforms.dll
from: C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web
I hope this helps
I had same problem in VS2012, could not 'Preview Transform' for the PublishPackage tranforms e.g. Web.Staging.config complaining about Microsoft.Web.XmlTransform
I got it working by adding the Package https://nuget.org/packages/Microsoft.Web.Xdt to my Mvc 4.5 project. This package is still in pre release.
PM> Install-Package Microsoft.Web.Xdt -Pre
This package contains the Microsoft.Web.XmlTransform.dll
I still get an error during building complaining about "Could not load file or assembly Microsoft.Web.XmlTransform". The Mvc project has still built ok.
I did try adding the Microsoft.Web.XmlTransform.dll to the Gac using the gacutil but that did not fix the problem.
However I use Team Foundation Service build server and it works and creates the correct Web.config after applying the Web.Release.config and then the Web.Staging.config.
I tried below two things but it did not work for me.
1) copying the Microsoft.Web.XmlTransforms.dll DLL to location C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web
2) And repairing "Microsoft ASP.NET and Web Tools 2013.1 - Visual Studio 2012"
Then I uninstalled Microsoft Azure tool V2.6 from control panel -> Programs and Features. And then I can able to publish my site.
This may have been fixed in Visual Studio 2012 Update 2 (and Visual Studio 2013).
Web.config "Preview Transform" gives an error
...
Posted by Microsoft on 3/1/2013 at 2:46 PM
Thanks for reporting the issue! It will be fixed in Visual Studio 2012 Update 2. Please install it when it becomes available.

EntityFramework 5 use dll version 4.4.0.instead 5.0

I have project based on .NET 4.0 but I need to use EntityFramework 5 in my solution. So I install it from the NuGet.
After that I change target framework to .NET 4.5 (I'm using VS 2012) and rebuild project.
But in reference folder I see that project use EntityFramework.dll version 4.4.0.0.
Ho can I use newer version of EntityFramework?
in web.config
<compilation debug="true" targetFramework="4.5">
<assemblies>
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</assemblies>
</compilation>
Newer version (the real EF5) is dependent on .NET 4.5. If you have added EF5 when your project was based on .NET 4.0 you will have only EF 4.4 (EF5 version without features dependent on .NET 4.5). After upgrading to EF 5.0 you need to update EntityFramework package. You can try to use Update-Package command. If it doesn't help you will need to uninstall package first and than add it again.

Error thrown when I'm trying to load log4net assembly

I'm try to build project that use LinqToExcel library. Additionally, I'm use log4net to write logs.
My problem started when I'm tryomg to run this lines of code:
var excel = new ExcelQueryFactory(ExcelPath);
return (from r in excel.Worksheet<RowDetails>(company.Name)
select r).Count();
This line thrown exception:
ERROR MyProj.Program Main:System.IO.FileLoadException: Could not load
file or assembly 'log4net, Version=1.2.11.0, Culture=neutral,
PublicKeyToken=669e0ddf0bb1aa2a' or one of its dependencies. The
located assembly's manifest definition does not match the assembly
reference. (Exception from HRESULT: 0x80131040) File name: 'log4net,
Version=1.2.11.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a'
It's important to note that I'm successful to use log4net before this line.
I would appreciate any help.
Thanks a lots!
As marc_s pointed out, this problem usually appears when trying to load different versions of the same assembly. Make sure, that your project uses the same assembly version as the LinqToExcel library, which is also dependent on log4net. Also any other libraries should use the same assembly version. To solve the issue, you can also try to use assembly redirect in your app.config like so:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="log4net" publicKeyToken="669e0ddf0bb1aa2a" culture="neutral" />
<bindingRedirect oldVersion="1.2.10.0" newVersion="1.2.11.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
try to install it using nuget
Install-Package log4net -Version 2.0.0
Version 2.0.0 is for log4net 1.2.11
I'm having similar problem. I think that the problem is in LinqtoExcel referencing Log4Net version 1.2.11, and you have referenced Log4Net sepratly and you get latest 1.2.13 version. In build output you'll end up with 1.2.13, and when LintoExcel calls Log4Net it expects 1.2.11 and error ocures.
I got this issue after upgrading log4net through NuGet, only to find that the newer version was signed with a different key.
You can grab the 'oldkey' version from the apache log4net site and then it worked for me.

Resources