Specflow Custom Plugin Error Assembly missing - specflow

I have a simple custom plugin which was working in January and recently has stopped working with the following message:
"Custom tool error: Generation error: Missing [assembly:GeneratorPlugin] attribute in _PATH_TO_PLUGIN_"
I went through the other stackoverflow question on this but it didnt resolve the issue.
The following is the plugin code which has the attribute and was built using the Specflow 2.2.1 nuget packages.
[assembly: GeneratorPlugin(typeof(CustomPlugin))]
namespace Tests.SpecFlowPlugin
{
public class CustomPlugin : IGeneratorPlugin
{
public void Initialize(GeneratorPluginEvents generatorPluginEvents, GeneratorPluginParameters generatorPluginParameters)
{
generatorPluginEvents.CustomizeDependencies += GeneratorPluginEvents_CustomizeDependencies;
}
private void GeneratorPluginEvents_CustomizeDependencies(object sender, CustomizeDependenciesEventArgs e)
{
e.ObjectContainer.RegisterTypeAs<IgnoreDecorator, ITestClassTagDecorator>("ignore");
e.ObjectContainer.RegisterTypeAs<IgnoreDecorator, ITestMethodTagDecorator>("ignore");
}
}
}
This is my partial app.config:
<specFlow>
<unitTestProvider name="MsTest" />
<stepAssemblies>
<stepAssembly assembly="SpecFlow.Assist.Dynamic" />
</stepAssemblies>
<plugins>
<add name="Tests.CustomPlugin" type="Generator"/>
</plugins>
<trace stepDefinitionSkeletonStyle="MethodNameUnderscores" />
</specFlow>
This is the trace when I use the Run Custom Tool on the .feature file:
[16:14:29.3990135] Tracing: Tracing enabled for all categories
[16:14:29.3990135] VsGeneratorServices: Discover project settings
[16:14:29.4065488] VsGeneratorInfoProvider: Discovering generator
information... [16:14:29.4435543] VsGeneratorInfoProvider: Runtime
found at _SOLUTION_DIR_\packages\SpecFlow.2.2.1\lib\net45
[16:14:29.4445556] VsGeneratorInfoProvider: Generator found at
_SOLUTION_DIR_\packages\SpecFlow.2.2.1\tools\TechTalk.SpecFlow.Generator.dll
[16:14:29.4450553] RemoteGeneratorServices: Creating remote wrapper
for the project's generator (2.2.0 at
_SOLUTION_DIR_\packages\SpecFlow.2.2.1\tools) [16:14:29.4810888] RemoteAppDomainTestGeneratorFactory: TestGeneratorFactory:
TechTalk.SpecFlow.Generator.TestGeneratorFactory [16:14:29.4810888]
RemoteAppDomainTestGeneratorFactory: AssemblyResolve Event added
[16:14:29.5071116] RemoteAppDomainTestGeneratorFactory:
GeneratorAssemlbyResolveEvent: Name:
TechTalk.SpecFlow.RemoteAppDomain, Version=2017.1.12.0,
Culture=neutral, PublicKeyToken=0778194805d6db41; [16:14:29.5076129]
RemoteAppDomainTestGeneratorFactory: GeneratorAssemlbyResolveEvent:
Name: TechTalk.SpecFlow.RemoteAppDomain, Version=2017.1.12.0,
Culture=neutral, PublicKeyToken=0778194805d6db41; [16:14:29.5436452]
RemoteAppDomainTestGeneratorFactory: GeneratorAssemlbyResolveEvent:
Name: TechTalk.SpecFlow.Generator, Version=2.2.0.0, Culture=neutral,
PublicKeyToken=0778194805d6db41; [16:14:29.5486501]
RemoteAppDomainTestGeneratorFactory: GeneratorAssemlbyResolveEvent:
Name: TechTalk.SpecFlow.Generator, Version=2.2.0.0, Culture=neutral,
PublicKeyToken=0778194805d6db41; [16:14:29.5496502]
RemoteAppDomainTestGeneratorFactory: AppDomain for generator created
[16:14:29.5496502] VsGeneratorServices: Discover project settings
[16:14:29.7108192] RemoteAppDomainTestGeneratorFactory:
GeneratorAssemlbyResolveEvent: Name: TechTalk.SpecFlow,
Version=2.2.0.0, Culture=neutral, PublicKeyToken=0778194805d6db41;
[16:20:43.6703331] RemoteAppDomainTestGeneratorFactory:
GeneratorAssemlbyResolveEvent: Name:
Microsoft.TestPlatform.VsTestConsole.TranslationLayer,
Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a;
The odd thing is when I use the following command from the nuget package directory then all feature files are correctly built and it has no issue loading the plugin using the exact same app.config settings. This only appears to be an issue when inside visual studio
specflow generateall "_PATH_TO_TEST_PROJECT_"
I have tried updating/reinstalling the specflow extension, updating to Specflow 2.3.1, deleting caches, copying the custom plugin into the nuget directory etc. I have no clue what its doing but its currently affecting all members of our team despite it working correctly 2 months ago and no obvious changes impacting this area or updates in the interim.

Related

SQLite as an Elmah source

I'm trying to get SQLite working with Elmah, but it keeps complaining about the attached version.
I've read numerous blogs on the topic but none of the recommended approaches has worked for me thus far.
Elmah.MVC has been installed, as the latest version found in NUGET, then installed the SQLite core framework has been attached, as per the current version in NUGET as well.
From what I can gather, it's in the way that NUGET appends the SQLite entries into the web.config file, but I cannot see a difference.
My packages.config (entries left out for readability):
<?xml version="1.0" encoding="utf-8"?>
<packages>
.....
<package id="elmah.corelibrary" version="1.2.1" targetFramework="net45" />
<package id="Elmah.MVC" version="2.1.1" targetFramework="net45" />
<package id="System.Data.SQLite" version="1.0.94.1" targetFramework="net45" />
<package id="System.Data.SQLite.Core" version="1.0.94.0" targetFramework="net45" />
<package id="System.Data.SQLite.EF6" version="1.0.94.0" targetFramework="net45" />
<package id="System.Data.SQLite.Linq" version="1.0.94.1" targetFramework="net45" />
.....
</packages>
Elmah has been implemented as a View / Controller rather than the standard .axd version that comes predefined, so when I browse http://localhost:3812/Elmah/ the following stack trace gets thrown:
Could not load file or assembly 'System.Data.SQLite, Version=1.0.61.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.FileLoadException: Could not load file or assembly 'System.Data.SQLite, Version=1.0.61.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
And Pre-bind state information
=== Pre-bind state information ===
LOG: DisplayName = System.Data.SQLite, Version=1.0.61.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139
(Fully-specified)
LOG: Appbase = file:///C:/Users/Admin/Documents/Visual Studio 2015/Projects/TestMvc/Site/TestMvc.WebSite/
LOG: Initial PrivatePath = C:\Users\Admin\Documents\Visual Studio 2015\Projects\TestMvc\Site\TestMvc.WebSite\bin
Calling assembly : Elmah, Version=1.2.14318.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\Admin\Documents\Visual Studio 2015\Projects\TestMvc\Site\TestMvc\web.config
LOG: Using host configuration file: C:\Users\Admin\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.Data.SQLite, Version=1.0.61.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139
LOG: Attempting download of new URL file:///C:/Users/Admin/AppData/Local/Temp/Temporary ASP.NET Files/root/65395abf/3be698df/System.Data.SQLite.DLL.
LOG: Attempting download of new URL file:///C:/Users/Admin/AppData/Local/Temp/Temporary ASP.NET Files/root/65395abf/3be698df/System.Data.SQLite/System.Data.SQLite.DLL.
LOG: Attempting download of new URL file:///C:/Users/Admin/Documents/Visual Studio 2015/Projects/TestMvc\Site\TestMvc/bin/System.Data.SQLite.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Build Number
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
I do not believe this to be an issue with Visual Studio 2015 CTP, nor with the latest version of the both Elmah.MVC or SQLite or the build attributes (Any CPU vs x86/x64) as SQLite works fine when doing basic CRUD against the database (not shown in this question).
Any assistance would be greatly appreciated.

How does one use the WebGreaseTask MSBuild Task from WebGrease?

In the documentation for WebGrease, it talks about using an MSBuild task to do minification at build time. However, when I add the task to my project file, it fails.
Here are the lines I've added to my project
<UsingTask TaskName="WebGreaseTask" AssemblyName="WebGrease, Version=1.6.5135.21930, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"/>
<Target AfterTargets="DotLessBuildTasksDotNet" Name="Minify">
<WebGreaseTask />
</Target>
But when I try to build, I get the following error:
The "WebGreaseTask" task could not be loaded from the assembly
WebGrease, Version=1.6.5135.21930, Culture=neutral,
PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL. Could not
load file or assembly 'WebGrease, Version=1.6.5135.21930,
Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its
dependencies. The system cannot find the file specified. Confirm that
the declaration is correct, that the assembly and all its
dependencies are available, and that the task contains a public class
that implements Microsoft.Build.Framework.ITask.
As far as I know, that's the correct assembly name, as I'm using the same reference in my project:
<Reference Include="WebGrease, Version=1.6.5135.21930, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\WebGrease.1.6.0\lib\WebGrease.dll</HintPath>
</Reference>
And all of the code there is working fine.
I want to do the minification at compile time, which I believe is the purpose of the build task. I know there are a plethora of bundling and minification helpers out there, but I'd like to avoid pulling in more packages than I have to.
Edit:
I've tried the various NuGet commands, but those don't affect the UsingTask node in any way, and don't cause the build to work either. Still at a loss on this error.
Looking in the source code there is a class https://webgrease.codeplex.com/SourceControl/latest#WebGrease/WebGrease.Build/WebGreaseTask.cs which looks like the thing you need, but after decompiling my local WebGrease nuget package, I don't see this class or WebGrease.Build assembly there at all. As the error points out it can't find a class that implements ITask and this class exactly implements it.

Problems related to Microsoft HTTP Client Libraries v2.1.10 NuGet update

Note: This question was totally rewritten several days after it was originally posted.
I have an ASP.NET MVC app developed in VS 2012, deployed to Azure. The original projects were created from the ASP.NET MVC 4 project template.
NuGet recently started showing a whole slew of updated packages from Microsoft. One of those updates, Microsoft HTTP Client Libraries v2.1.10, causes serious problems when it is installed.
It installs MicrosoftBcl.Build, which is not compatible with my Azure project (see this SO question for the problem and its solution).
It causes a whole slew of "incompatible DLL" problems (see below).
This raises several burning questions:
My MVC app is just a website. It just runs in a web browser. Do I need this package at all? (E.g., is it used by template code, which would break, possibly subtly, if I remove the package?)
According to the Project Site (http://blogs.msdn.com/b/bclteam/p/httpclient.aspx), there are a couple of newer (albeit beta) versions of this product. I assume I'd see them if I told NuGet to show me non-released versions. Do these versions fix the problems described above?
Here are the warnings I get when I build the solution after installing the updated NuGet package...
1>------ Build started: Project: Ruby, Configuration: Release Any CPU ------
1> All packages listed in packages.config are already installed.
1> No way to resolve conflict between "System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" and "System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35". Choosing "System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" arbitrarily.
1> Consider app.config remapping of assembly "DotNetOpenAuth.AspNet, Culture=neutral, PublicKeyToken=2780ccd10d57b246" from Version "4.0.0.0" [] to Version "4.3.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\DotNetOpenAuth.AspNet.4.3.0.13117\lib\net45-full\DotNetOpenAuth.AspNet.dll] to solve conflict and get rid of warning.
1> Consider app.config remapping of assembly "System.Web.Mvc, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "3.0.0.0" [C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 3\Assemblies\System.Web.Mvc.dll] to Version "4.0.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\Microsoft.AspNet.Mvc.4.0.30506.0\lib\net40\System.Web.Mvc.dll] to solve conflict and get rid of warning.
1> Consider app.config remapping of assembly "System.Web.Razor, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "1.0.0.0" [C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.Razor.dll] to Version "2.0.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\Microsoft.AspNet.Razor.2.0.30506.0\lib\net40\System.Web.Razor.dll] to solve conflict and get rid of warning.
1> Consider app.config remapping of assembly "WebGrease, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "1.0.0.0" [] to Version "1.3.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\WebGrease.1.3.0\lib\WebGrease.dll] to solve conflict and get rid of warning.
1> Consider app.config remapping of assembly "System.Web.WebPages.Razor, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "1.0.0.0" [C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.WebPages.Razor.dll] to Version "2.0.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.WebPages.Razor.dll] to solve conflict and get rid of warning.
1> Consider app.config remapping of assembly "Microsoft.Data.OData, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "5.2.0.0" [] to Version "5.5.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\Microsoft.Data.OData.5.5.0\lib\net40\Microsoft.Data.OData.dll] to solve conflict and get rid of warning.
1> Consider app.config remapping of assembly "System.Web.WebPages, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "1.0.0.0" [C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.WebPages.dll] to Version "2.0.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.WebPages.dll] to solve conflict and get rid of warning.
1> Consider app.config remapping of assembly "DotNetOpenAuth.Core, Culture=neutral, PublicKeyToken=2780ccd10d57b246" from Version "4.0.0.0" [] to Version "4.3.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\DotNetOpenAuth.Core.4.3.0.13117\lib\net45-full\DotNetOpenAuth.Core.dll] to solve conflict and get rid of warning.
1> Consider app.config remapping of assembly "System.Web.WebPages.Deployment, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "1.0.0.0" [C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.WebPages.Deployment.dll] to Version "2.0.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.WebPages.Deployment.dll] to solve conflict and get rid of warning.
1>C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3247: Found conflicts between different versions of the same dependent assembly.
1> Ruby -> C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\Ruby\bin\Ruby.dll
2>------ Build started: Project: Ruby.Azure, Configuration: Release Any CPU ------
3>------ Publish started: Project: Ruby.Azure, Configuration: Release Any CPU ------
3>C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\Microsoft.Bcl.Build.1.0.7\tools\Microsoft.Bcl.Build.targets(220,5): warning : All projects referencing Ruby.csproj must install nuget package Microsoft.Bcl.Build.
3> No way to resolve conflict between "System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" and "System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35". Choosing "System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" arbitrarily.
3> Consider app.config remapping of assembly "DotNetOpenAuth.AspNet, Culture=neutral, PublicKeyToken=2780ccd10d57b246" from Version "4.0.0.0" [] to Version "4.3.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\DotNetOpenAuth.AspNet.4.3.0.13117\lib\net45-full\DotNetOpenAuth.AspNet.dll] to solve conflict and get rid of warning.
3> Consider app.config remapping of assembly "System.Web.Mvc, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "3.0.0.0" [C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 3\Assemblies\System.Web.Mvc.dll] to Version "4.0.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\Microsoft.AspNet.Mvc.4.0.30506.0\lib\net40\System.Web.Mvc.dll] to solve conflict and get rid of warning.
3> Consider app.config remapping of assembly "System.Web.Razor, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "1.0.0.0" [C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.Razor.dll] to Version "2.0.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\Microsoft.AspNet.Razor.2.0.30506.0\lib\net40\System.Web.Razor.dll] to solve conflict and get rid of warning.
3> Consider app.config remapping of assembly "WebGrease, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "1.0.0.0" [] to Version "1.3.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\WebGrease.1.3.0\lib\WebGrease.dll] to solve conflict and get rid of warning.
3> Consider app.config remapping of assembly "System.Web.WebPages.Razor, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "1.0.0.0" [C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.WebPages.Razor.dll] to Version "2.0.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.WebPages.Razor.dll] to solve conflict and get rid of warning.
3> Consider app.config remapping of assembly "Microsoft.Data.OData, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "5.2.0.0" [] to Version "5.5.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\Microsoft.Data.OData.5.5.0\lib\net40\Microsoft.Data.OData.dll] to solve conflict and get rid of warning.
3> Consider app.config remapping of assembly "System.Web.WebPages, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "1.0.0.0" [C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.WebPages.dll] to Version "2.0.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.WebPages.dll] to solve conflict and get rid of warning.
3> Consider app.config remapping of assembly "DotNetOpenAuth.Core, Culture=neutral, PublicKeyToken=2780ccd10d57b246" from Version "4.0.0.0" [] to Version "4.3.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\DotNetOpenAuth.Core.4.3.0.13117\lib\net45-full\DotNetOpenAuth.Core.dll] to solve conflict and get rid of warning.
3> Consider app.config remapping of assembly "System.Web.WebPages.Deployment, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "1.0.0.0" [C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.WebPages.Deployment.dll] to Version "2.0.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.WebPages.Deployment.dll] to solve conflict and get rid of warning.
3>C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3247: Found conflicts between different versions of the same dependent assembly.
3> Transformed Web.config using C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\Ruby\Web.Release.config into obj\Release\TransformWebConfig\transformed\Web.config.
3>Ruby(0,0): warning WAT153: The web project 'Ruby' is dependent on the following MVC assembly: C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 3\Assemblies\System.Web.Mvc.dll. MVC assemblies must be added to the package or installed on the virtual machine for your web role. For more details about this, see the following help page: http://go.microsoft.com/fwlink/?LinkId=218227.
3>Ruby(0,0): warning WAT153: The web project 'Ruby' is dependent on the following MVC assembly: C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.Razor.dll. MVC assemblies must be added to the package or installed on the virtual machine for your web role. For more details about this, see the following help page: http://go.microsoft.com/fwlink/?LinkId=218227.
3>Ruby(0,0): warning WAT153: The web project 'Ruby' is dependent on the following MVC assembly: C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.WebPages.Razor.dll. MVC assemblies must be added to the package or installed on the virtual machine for your web role. For more details about this, see the following help page: http://go.microsoft.com/fwlink/?LinkId=218227.
3>Ruby(0,0): warning WAT153: The web project 'Ruby' is dependent on the following MVC assembly: C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.WebPages.dll. MVC assemblies must be added to the package or installed on the virtual machine for your web role. For more details about this, see the following help page: http://go.microsoft.com/fwlink/?LinkId=218227.
3>Ruby(0,0): warning WAT153: The web project 'Ruby' is dependent on the following MVC assembly: C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.WebPages.Deployment.dll. MVC assemblies must be added to the package or installed on the virtual machine for your web role. For more details about this, see the following help page: http://go.microsoft.com/fwlink/?LinkId=218227.
You can use binding redirects in your web.config file to solve issues.
For example, for line:
Consider app.config remapping of assembly "DotNetOpenAuth.AspNet, Culture=neutral, PublicKeyToken=2780ccd10d57b246" from Version "4.0.0.0" [] to Version "4.3.0.0"
Add in Web.config:
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="DotNetOpenAuth.AspNet"
publicKeyToken="2780ccd10d57b246"
culture="neutral" />
<bindingRedirect oldVersion="1.0.0.0-4.3.0.0"
newVersion="4.3.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
and so on... For each dll that creates exception add additional dependentAssembly node.
One situation which causes this error is running the Azure package oder publish commands without having done a clean rebuild for the same configuration (e.g. Release) before.
This fixed it for me:
Reinstall the WindowsAzure.Storage NuGet package by running the following command on the NuGet Package Manager Console:
Update-Package –reinstall WindowsAzure.Storage
Rebuild the MVC web application project (Debug and Release).
If this does not help you could set the "MSBuild project build output verbosity" under TOOLS -> Options -> "Projects and Solutions" -> "Build and Run" to "Diagnostic" and check what causes the Assembly conflict (e.g. look for "Project file item includes which caused reference").
You need to update/create an app.config file with the redirects as mentioned here:
https://cpaterson.wordpress.com/2014/03/28/found-conflicts-between-different-versions-of-assembly-consider-app-config-remapping-of-assembly/

Assembly binding redirect not working

I am trying to deploy a test web app on Azure, but when I run the Azure emulator on my local machine I get this error from the Azure emulator console attached to my WebRole:
System.TypeLoadException: Unable to load the role entry point due to the following exceptions:
-- System.IO.FileLoadException: Could not load file or assembly 'System.Web.Mvc, 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)
File name: 'System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
=== Pre-bind state information ===
LOG: User = COLLAB\mirko.lugano
LOG: DisplayName = System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file:///C:/Code/Application/<MyWebProject>.Azure/csx/Debug/roles/<MyWebProject>/approot/bin
LOG: Initial PrivatePath = C:\Code\Application\<MyWebProject>.Azure\csx\Debug\roles\<MyWebProject>\approot\bin
Calling assembly : ActionMailer.Net.Mvc, Version=0.7.4.0, Culture=neutral, PublicKeyToken=e62db3114c02a1c2.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Code\Application\<MyWebProject>.Azure\csx\Debug\roles\<MyWebProject>\base\x64\WaIISHost.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: Attempting download of new URL file:///C:/Code/Application/<MyWebProject>.Azure/csx/Debug/roles/<MyWebProject>/approot/bin/System.Web.Mvc.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Major Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
---> System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.RuntimeModule.GetTypes()
at System.Reflection.Assembly.GetTypes()
at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.GetRoleEntryPoint(Assembly entryPointAssembly)
--- End of inner exception stack trace ---
at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.GetRoleEntryPoint(Assembly entryPointAssembly)
at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.CreateRoleEntryPoint(RoleType roleTypeEnum)
at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.InitializeRoleInternal(RoleType roleTypeEnum)
[fabric] Role state Unknown
Everything had been working fine as long as I had MVC3 installed on my local machine (the MVC3 assembly was in GAC), but since I removed MVC3 (Azure has no MVC installed), I am getting this error. My web app has MVC4 regularly included and that works fine. I had then thought about assembly binding redirection, and I noticed that in my web.config file I already have:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
...
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
...
</assemblyBinding>
</runtime>
which should be already correct, according to the documentation I have read around in internet. I have also tried setting the SpecificVersion property of my System.Web.Mvc.dll (version 4.0.0.0) to false but to no avail. Am I missing something? Shouldn't the calling assembly ActionMailer.Net.Mvc be automatically redirected to the correct version of the MVC assembly? Any ideas are greatly appreciated. Thanks.
In Azure WebRoles, by default (in Full IIS Mode) the RoleEntryPoint gets walled off from the rest of the WebRole, and runs in a different process.
A side effect of this is that your RoleEntryPoint will not have access to your web.config.
Azure SDK 1.3 -1.7 will look in WaIISHost.exe.config
Azure SDK 1.8+ will look in the WebRoleProjectName.dll.config.
With the newest change to the SDK, you should be able to place an app.config in your project and your role entry point should then have access to it.
You can read more about this in this Microsoft blog post or in this Stackoverflow post
Thank you Rune for the precious hint. That didn't solve my problem but it pointed me to the right direction, because I have the latest version of Azure SDK (1.8) and this WaIISHost.exe.config trick no longer works on the latest version of Azure. HERE is stated what I just said and the solution that worked for me, which is to rename the WaIISHost.exe.config file to MyWebAppName.dll.config (placing it at the same level of your web.config file in your web app and setting its Copy to output Directory property to 'Copy Always'. Of course this config file contains the binding redirect section as I described above.
As of today with the latest SDK a WebRoleProjectName.dll.config will be automatically generated for you with the contents of the Web.config and copied to the output directory.
However this won't be automatically be included in the deployment package! For this to happen you have to employ a kind of hackish solution: include the generated file in the project by selecting "show all files", then including just this file. The resulting change in the csproj should look like this (not, don't select it to be "Copy always"!):
<Content Include="bin\WebRoleProjectName.dll.config" />

Program crashes when using Managed DirectX with .Net Framework 4.0

We are having a problem using DirectSound with the Managed DirectX dlls and the .Net Framework 4.0
The program works fine with .Net Framework 2.0 - but we have a requirement to upgrade to 4.0 to use some other components.
When the program invokes the Sound module, it crashes with the exception noted below.
Anybody seen this one and know how to fix it?
==============================================
System.IO.FileNotFoundException was unhandled
Message=Could not load file or assembly 'Microsoft.DirectX, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
Source=Microsoft.DirectX.DirectSound
FileName=Microsoft.DirectX, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
FusionLog=""
[stack dump snipped]
InnerException: System.IO.FileNotFoundException
Message=Could not load file or assembly 'Microsoft.DirectX, Version=1.0.2902.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
FileName=Microsoft.DirectX, Version=1.0.2902.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
FusionLog==== Pre-bind state information ===
LOG: User = *****************
LOG: DisplayName = Microsoft.DirectX, Version=1.0.2902.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file:///C:/Users/*********/Documents/Visual Studio 2010/Projects/************/bin/x86/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : Microsoft.DirectX.DirectSound, Version=1.0.2902.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\***********\Documents\Visual Studio 2010\Projects\****************\bin\x86\Debug\***************.exe.config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Redirect found in application configuration file: 1.0.2902.0 redirected to 2.0.0.0.
LOG: Post-policy reference: Microsoft.DirectX, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: The same bind was seen before, and was failed with hr = 0x80070002.
InnerException:
I know this is a late reply but for me to get this working I had to find two DirectX DLL Microsoft.DirectX and Microsoft.DirectX.DirectInput and add then as a reference to the project.
Then just use the DirectX namespace for calling methods.
<!-- Uncomment this section when switching from Net2.0 to Net 4.0
It is intended to fix problems loading DirectX dlls - per Microsoft-->
<!--
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0"/>
</startup>
-->
Officially the legacy DirectX Managed 1.1 assemblies do not support .NET 4.0. See this blog post for details.
You could look at using SlimDX or some other alternative...

Resources