I cannot use both StackExchange.Redis.Extensions and PersistKeysToRedis to services.AddDataProtection
I get error on PersistKeysToRedis:
cannot convert from 'StackExchange.Redis.IConnectionMultiplexer' to 'System.Func<StackExchange.Redis.IDatabase>'
To reproduce the issue:
Create a WebApp Core 2.2 project
Install-Package StackExchange.Redis.Extensions.Newtonsoft
Install-Package Microsoft.AspNetCore.DataProtection.Redis -Version 2.2.0-preview2-35157
Edit .csproj and add this fix https://stackoverflow.com/a/48758961
Add on ConfigureServices below code
var redis = ConnectionMultiplexer.Connect("Configuration");
services.AddDataProtection().PersistKeysToRedis(redis, "RedisKey");
Using
.PersistKeysToRedis(redis.GetDatabase(), "RedisKey");
always return an error.
So, how I can use PersistKeysToRedis keeping StackExchange.Redis.Extensions (I need it for the StackExchangeRedisCacheClient)
Related
When i build my .net core MVC web project i get this error 190 times :
CS1056 Unexpected character '[]' .
This problem is seen after a few builds. Any suggestions?
This is about a file in my temp folder which is on
users\[My User]\AppData\temp\.NETCoreApp,Version=v2.0.AssemblyAttributes.cs, when I delete this my project completely built.
If you're getting this error during publishing, you can alternatively resolve the issue by creating a new release profile.
I'm attempting to programmatically build a project which uses C#7, and therefore MSBuild 15, but this task is failing seemingly because of mismatched assembly references.
Here is my code:
string projectFilePath = Path.Combine(args.Any() ? args.First() :#"C:\Users\newsoni\Documents\Visual Studio 2017\Projects\ConsoleApp2\ConsoleApp2.sln");
ProjectCollection pc = new ProjectCollection();
Dictionary<string, string> globalProperty = new Dictionary<string, string>();
globalProperty.Add("Configuration", "Debug");
globalProperty.Add("Platform", "x86");
BuildParameters bp = new BuildParameters(pc);
bp.Loggers = new ILogger[] { new Logger(), new ConsoleLogger(), };
BuildRequestData BuidlRequest = new BuildRequestData(projectFilePath, globalProperty, "4.0", new string[] { "Build" }, null);
BuildResult buildResult = BuildManager.DefaultBuildManager.Build(bp, BuidlRequest);
Here is the error message:
C:\Users\newsoni\Documents\Visual Studio 2017\Projects\ConsoleApp2\ConsoleApp2.sln.metaproj : error MSB4127: The "Error" task could not be instantiated from the assembly "Microsoft.Build.Tasks.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". Please verify the task assembly has been built using the same version of the Microsoft.Build.Framework assembly as the one installed on your computer and that your host application is not missing a binding redirect for Microsoft.Build.Framework. Unable to cast object of type 'Microsoft.Build.Tasks.Error' to type 'Microsoft.Build.Framework.ITask'.
C:\Users\newsoni\Documents\Visual Studio 2017\Projects\ConsoleApp2\ConsoleApp2.sln.metaproj : error MSB4060: The "Error" task has been declared or used incorrectly, or failed during construction. Check the spelling of the task name and the assembly name.
Here is a link to a project you can use to recreate the issue:
https://drive.google.com/a/xibis.com/file/d/0B-mqMIMqm_XHcVRJQmtxQkd1b3c/view?usp=sharing
You will have to change the path in the code to a project on your own machine, but it doesn't seem to matter if this is a VS 2017 project or earlier.
One other thing that may or may not be relevant, I noticed that the Microsoft.WebApplication.Build.Tasks.Dll in this folder:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0\WebApplications
Still seems to be referencing Microsoft.Build.Framework.dll version 14, not 15 as I would have expected.
It turns out there are two issues in my test project. The first is due to the naming of the project.
However there is a second issue which is due to the references not being correct. To use MSBuild 15 programmtically you must install the following packages:
Install-Package Microsoft.Build -Version 15.1.1012
Install-Package Microsoft.Build.Framework -Version 15.1.1012
Install-Package Microsoft.Build.Tasks.Core -Version 15.1.1012
Install-Package Microsoft.Build.Utilities.Core -Version 15.1.1012
Install-Package Microsoft.Net.Compilers -Version 2.2.0
There is one more step which is nuts and completely undiscoverable. You must now add a reference to this DLL which should be relative to your solution folder:
packages\Microsoft.Net.Compilers.2.2.0\tools\Microsoft.Build.Tasks.CodeAnalysis.dll
I opened a support ticket with Microsoft and they have confirmed that this is a bug in Visual Studio 2017.
They are aiming to get a fix for this into update 3 for Visual Studio, but this may slip.
This issue tracks the bug:
https://github.com/Microsoft/msbuild/issues/2194
There is no workaround at present for this API, but you can invoke the MSBuild exe using Process as an alternative.
If you have MSBuild installed on your PC, either directly or through Visual Studio, the proper fix is to use the package Microsoft.Build.Locator which will find that installed version and execute the build using it.
Install these packages
Microsoft.Build
Microsoft.Build.Framework
Microsoft.Build.Locator
The first 2 are needed so that the code can compile but should be excluded from the project output.
In your application startup add the following line of code, this only has to run once.
Microsoft.Build.Locator.MSBuildLocator.RegisterDefaults();
Remove any additional binding redirects in your app.config that are specific to Microsoft.Build or other build libraries. The call to the Microsoft.Build.Locator assembly will ensure that these redirects take place automatically.
References
Update an existing application for MSBuild 15
Github MSBuildLocator.
i recently have been using Nancy fx and i'm in love with it, but when i try to make a structuremap ioc like the documentation page suggested i get the error
Field not found: 'Nancy.Bootstrapper.NancyBootstrapperLocator.Bootstrapper'.
i have override the getApplicationContainer function like shown in the file
https://github.com/CarlosBolanos/apadrina/blob/master/Application/Bootstrapper.cs
but still get the same error, i look on the code on the rnancy repository
https://github.com/NancyFx/Nancy.Bootstrappers.StructureMap/blob/master/src/Nancy.Bootstrappers.StructureMap/StructureMapNancyBootstrapper.cs
and i cant see the bootstrapper property
does any1 else have this error too i've been trying to set this up for hours,
if i remove the nancystructuremap in nugget the error goes away.
or do i need to set something else on the bootstrap class.
I ran into this scenario after installing Nancy.Bootstrappers.Ninject from Nuget. My Nancy project was created using the Nancy Visual Studio templates, and were referencing Nancy 0.21.1.
What I found was installing the bootstrapper package caused the base Nancy package to get upgraded from 0.21.1 to 0.23.2. This is fine, except that the Nancy.Hosting.Aspnet and the Razor engine packages were NOT upgraded from 0.21.1.
To fix the error, I had to update all of the Nancy-related packages I was using to match the 0.23.2 package.
I am following this tutorial for getting started with Hot towel, I have installed the ASP.NET Web Tools 2012.2 update and have also downloaded and installed the VSIX for the Hot towel template, but when I try create a new project with this template it is not working correctly. If I open a new project in Visual Studio 2012 and select ASP.NET MVC 4 Web Application I see the HotTowel Single Page Application template listed there, but I select the project gets created with a lot of files missing.
What I would expect to see in my Scripts folder is the following:
But instead my project looks like this:
The project created also does not compile, it throws the following exception:
Error 1 The name 'BundleConfig' does not exist in the current context
This exception is being thrown here:
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
}
Does anyone know why the Hot towel template is not working correctly in Visual Studio 2012 and what I could do to get it working?
UPDATE:
I tried installing Hot Towel with Nuget instead of the template, but that also did not work correctly. Install-Package got as far as installing Q and then gave an exception. Here is the Nuget output:
PM> Install-Package HotTowel
Attempting to resolve dependency 'Breeze.WebApi (≥ 1.4.1)'.
Attempting to resolve dependency 'Breeze.Client (≥ 1.4.2)'.
Attempting to resolve dependency 'Q'.
Install-Package : External packages cannot depend on packages that target projects.
At line:1 char:1
+ Install-Package HotTowel
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], InvalidOperationException
I solved this problem by updating NuGet Package Manager. I updated it from here:
http://docs.nuget.org/docs/start-here/installing-nuget
I am working PluralSight Video Tutorials on ASP.NET MVC. And i couldn't enable migrations on package console..
when i wrote enable-migrations, i am receiving this error;
More than one context type was found in the assembly 'eManager.Web'.
To enable migrations for eManager.Web.Infrastructure.DepartmentDb, use Enable-Migrations -ContextTypeName eManager.Web.Infrastructure.DepartmentDb.
To enable migrations for eManager.Web.Models.UsersContext, use Enable-Migrations -ContextTypeName eManager.Web.Models.UsersContext.
when i wrote Enable-Migrations -ContextTypeName eManager.Web.Infrastructure.DepartmentDb., i am receiving this error;
The context type 'eManager.Web.Infrastructure.DepartmentDb.' was not found in the assembly 'eManager.Web'.
Thanks for your help.
I strongly suspect that your issue is similar to the one in this question:
How to Enable Migration to update my database in MVC4?
Check the selected answer and see if that helps with your issue.
The solution for the mentioned error "The context type .... was not found" is to select the correct project that holds the context type before running the enable-migration command. You can choose the correct project from the "default project" drop down at the top of Nuget manager tool window.
The solution to this problem is simple, just remove the dot (.) at the end of this statement "Enable-Migrations -ContextTypeName eManager.Web.Infrastructure.DepartmentDb." and run the package manager console again, the migration should be enabled.