I am upgrading from 5.3.2 to version 5.5.3 and the following code does not compile. I get the errors
'IReceiveEndpointConfigurator' does not contain a definition for 'BindMessageExchanges' and no accessible extension method 'BindMessageExchanges' accepting a first argument of type 'IReceiveEndpointConfigurator' could be found (are you missing a using directive or an assembly reference?)
'IReceiveEndpointConfigurator' does not contain a definition for 'Bind' and no accessible extension method 'Bind' accepting a first argument of type 'IReceiveEndpointConfigurator' could be found (are you missing a using directive or an assembly reference?)
It seems that p is IReceiveEndpointConfigurator and not IRabbitMqReceiveEndpointConfigurator anymore. There seems to be changes on the overloaded methods or extension methods.
What overloaded method should I use instead? The code is used in testscenarios to hook up temporary queues/exchanges. _host is of type IRabbitMqHost
_handle = _host.ConnectReceiveEndpoint(p =>
{
p.BindMessageExchanges = false;
p.Handler<T>(context =>
{
_receivedMessage = context.Message;
_messageReceived.Set();
return Task.CompletedTask;
});
p.Bind<T>(z =>
{
z.ExchangeType = "direct";
z.RoutingKey = _routingKey;
});
});
The method is right there:
https://github.com/MassTransit/MassTransit/blob/develop/src/MassTransit.RabbitMqTransport/IRabbitMqHost.cs#L47
Are you specifying a queue name?
Related
Before I tested this line on a web application in core 5.
services.AddIdentity<Operator, IdentityRole>().AddEntityFrameworkStores<StorageContext>().AddDefaultTokenProviders();
This works fine in startup class.
Now I want to know how to implement it in windows form, Core 7. Because I just get this error -
'IServiceCollection' does not contain a definition for 'AddIdentity'
and no accessible extension method 'AddIdentity' accepting a first
argument of type 'IServiceCollection' could be found (are you missing
a using directive or an assembly reference?)
Am I missing assemblies? what are they?
this is my code now -
static IHostBuilder CreateHostBuilder()
{
return Host.CreateDefaultBuilder()
.ConfigureServices((context, services) =>
{
services.AddScoped<IStorageRepository, StorageRepository>();
services.AddDbContext<StorageContext>(option =>
{
option.EnableSensitiveDataLogging(true);
option.UseSqlServer(configuration["Data:Storage:ConnectionString"]);
});
services.AddIdentity<Operator, IdentityRole>().AddEntityFrameworkStores<StorageContext>().AddDefaultTokenProviders();
});
}
Does this AddIdentity class works in Winforms?
Just try to install Microsoft.AspNetCore.Identity package.
I had the same problem, just try to add this nugget package Microsoft.AspNetCore.Identity.UI. I add it and it start see it
I am getting following errors:
Code:
string redirectUrl = ConfigurationManager.AppSettings["RedirectUrl"];
AuthenticationParameters ap = AuthenticationParameters.CreateFromResourceUrlAsync(new Uri(redirectUrl)).Result;
Error:
An object reference is required for the non-static field, method, or property 'AuthenticationParameters.CreateFromResourceUrlAsync(Uri)' Pending email for Authorizers C:\Users\handemv\source\Workspaces\Dynamics 365\Trunk-UCI\Tools\Automation_CapGSupport\Pending Email\Pending email for Authorizers\PendingEmailCheck.cs
Code:
AuthenticationContext authContext = new AuthenticationContext(_authority, false);
AuthenticationResult result = authContext.AcquireToken(_serviceUri, clientCred);
Error:
AuthenticationContext' does not contain a definition for 'AcquireToken' and no accessible extension method 'AcquireToken' accepting a first argument of type 'AuthenticationContext' could be found (are you missing a using directive or an assembly reference?)
Can anyone help me for same?
Error : AuthenticationContext' does not contain a definition for 'AcquireToken' and no accessible extension method 'AcquireToken' accepting a first argument of type 'AuthenticationContext' could be found (are you missing a using directive or an assembly reference?)
Solution 1:
This error due to AcquireToken was removed in v3 of the Microsoft.IdentityModel.Clients.ActiveDirectory library.
To fix this downgrade the version in nuget to 2.22.302.111727 to solve this error.
Solution 2:
In V3 of ADAL.NET which appears to no longer have AcquireToken().
But it still has AcquireTokenAsync(). Note however that the parameters have slightly changed in the methods for v2 and v3.
For more details refer this thread
Error: An object reference is required for the non-static field, method, or property 'AuthenticationParameters.CreateFromResourceUrlAsync(Uri)' Pending email for Authorizers
Follow this link :https://github.com/AzureAD/azure-activedirectory-library-for-dotnet/issues/1410
I have ASP.Net MVC application, one part of it is compiling razor views to string. The code is very similar to this example:
https://long2know.com/2017/08/rendering-and-emailing-embedded-razor-views-with-net-core/
I registered Razor engine in Startup.cs in this way:
var viewAssembly = typeof(HtmlGeneratorService).GetTypeInfo().Assembly;
var fileProvider = new EmbeddedFileProvider(
viewAssembly,
"ApplicationServices.Widgets.Html.Templates");
services.Configure<MvcRazorRuntimeCompilationOptions>(options => {
options.FileProviders.Clear();
options.FileProviders.Add(fileProvider);
});
services.AddRazorPages().AddRazorRuntimeCompilation();
In test project i have this setup:
var builder = new HostBuilder()
.ConfigureWebHost(webHost =>
{
webHost.UseTestServer();
webHost.UseStartup<Startup>();
});
var host = await builder.StartAsync();
HttpClient = host.GetTestClient();
But when i call my endpoint using this HttpClient, IRazorViewEngine.GetView starts to throw strange exceptions:
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation.CompilationFailedException: 'One or more compilation failures occurred:
rnouw0xu.21w(4,41): error CS0234: The type or namespace name 'Razor' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
rnouw0xu.21w(4,82): error CS0518: Predefined type 'System.Type' is not defined or imported
rnouw0xu.21w(4,110): error CS0518: Predefined type 'System.String' is not defined or imported
rnouw0xu.21w(4,127): error CS0518: Predefined type 'System.String' is not defined or imported
rnouw0xu.21w(8,11): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
rnouw0xu.21w(9,11): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
rnouw0xu.21w(10,11): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
rnouw0xu.21w(11,11): error CS0246: The type or namespace name 'System' could not be found (are you missing a using directive or an assembly reference?)
rnouw0xu.21w(13,36): error CS0234: The type or namespace name 'Rendering' does not exist in the namespace 'Microsoft.AspNetCore.Mvc' (are you missing an assembly reference?)
rnouw0xu.21w(14,36): error CS0234: The type or namespace name 'ViewFeatures' does not exist in the namespace 'Microsoft.AspNetCore.Mvc' (are you missing an assembly reference?)
rnouw0xu.21w(29,35): error CS0234: The type or namespace name 'Razor' does not exist in the namespace 'Microsoft.AspNetCore' (are you missing an assembly reference?)
rnouw0xu.21w(29,78): error CS0518: Predefined type 'System.String' is not defined or imported
rnouw0xu.21w(29,87): error CS0518: Predefined type 'System.String' is not defined or imported
I trided to fix this erros in many different ways bul it looks like I got stuck here.
Looks like i found answer in this article:
https://github.com/aspnet/Razor/issues/1212
I just added this code to my test.csproj file:
<Target Name="CopyDepsFiles" AfterTargets="Build" Condition="'$(TargetFramework)'!=''">
<ItemGroup>
<DepsFilePaths Include="$([System.IO.Path]::ChangeExtension('%(_ResolvedProjectReferencePaths.FullPath)', '.deps.json'))" />
</ItemGroup>
<Copy SourceFiles="%(DepsFilePaths.FullPath)" DestinationFolder="$(OutputPath)" Condition="Exists('%(DepsFilePaths.FullPath)')" />
</Target>
Just extending the approved answer a bit since the suggested fix didn't work for me when upgrading to .NET 6, runtime was still unable to locate the assemblies until I explicitly added a AddApplicationPart(assembly) call to the IMvcBuilder.
Also a minor simplification is to pass the options lambda to the AddRazordRuntimeCompilation call, in which case services.Configure<MvcRazorRuntimeCompilationOptions> can be removed.
It might have failed due to several reasons (this was a Windows service project, views were in a separate dll), but anyway this is a compilation of various fixes I gathered from the web:
// this part is needed if you don't have a valid IWebHostEnvironment
// service registered, in which case you need to create your own dummy
// implementation because Razor needs IWebHostEnvironment.ApplicationName
// (it should return Assembly.GetEntryAssembly().GetName().Name, and you
// can leave other properties null)
services.AddSingleton<IWebHostEnvironment, DummyHostingEnvironment>();
services.AddSingleton<IHostEnvironment, DummyHostingEnvironment>();
// this also needs to be registered as two separate dependencies
// if you're getting "Unable to resolve service for type
// 'System.Diagnostics.DiagnosticListener'"
// (see https://github.com/dotnet/aspnetcore/issues/14544)
var diagnosticSource = new DiagnosticListener("Microsoft.AspNetCore");
services.AddSingleton<DiagnosticSource>(diagnosticSource);
services.AddSingleton<DiagnosticListener>(diagnosticSource);
// make sure you specify correct assemblies, in case the views
// are in a separate dll
var assemblyWithTemplates = ...;
var assemblyReferencingTheRazorPackage = ...;
services
.AddRazorPages()
.AddApplicationPart(assemblyReferencingTheRazorPackage ) // <-- added this
.AddRazorRuntimeCompilation(options =>
{
// important to clear because some of them are null
options.FileProviders.Clear();
// resolve views as embedded resources
options.FileProviders.Add(new EmbeddedFileProvider(assemblyWithTemplates));
});
And then also add the code from the accepted answer to the .csproj file so that .deps files are properly copied.
i was working on a console application and the word "From" wasn't a problem
ex var Best = db.Select<TopSellingGraph>(
db.From<products>
.Join<SalesOrderDetail>());
but when i start to use the servicestack api i always go into this problem
the error message is Error 1 'System.Data.IDbConnection' does not contain a definition for 'From' and no extension method 'From' accepting a first argument of type 'System.Data.IDbConnection' could be found (are you missing a using directive or an assembly reference?)
and i put in the apphost this code
var conString = ConfigurationManager.ConnectionStrings["AdventureWorks"].ConnectionString;
var conFactory = new OrmLiteConnectionFactory(conString, SqlServerDialect.Provider, true);
container.Register<IDbConnectionFactory>(c => conFactory);
i did exactly like the git-hub course
https://github.com/ServiceStack/ServiceStack.OrmLite
anyone have any idea ?
Most of OrmLite's APIs are extension methods over ADO.NET's IDbConnection interfaces which are made available when using the ServiceStack.OrmLite namespace:
using ServiceStack.OrmLite;
Tools like ReSharper help identify, add and can alleviate the burden of dealing with namespaces in C#.
I discovered NHaml some days ago and it's a great project.
When I try to use MVC2 Html helpers like Html.LabelFor(), Html.TextBoxFor(); the views won't compile.
Example:
error CS1061: 'System.Web.Mvc.HtmlHelper' does not contain a definition for 'LabelFor' and no extension method 'LabelFor' accepting a first argument of type 'System.Web.Mvc.HtmlHelper' could be found (are you missing a using directive or an assembly reference?)
0185: textWriter.Write(" ");
0185: textWriter.Write(Convert.ToString(Html.LabelFor(model => model.Username)));
0187: textWriter.WriteLine();
error CS1061: 'System.Web.Mvc.HtmlHelper' does not contain a definition for 'TextBoxFor' and no extension method 'TextBoxFor' accepting a first argument of type 'System.Web.Mvc.HtmlHelper' could be found (are you missing a using directive or an assembly reference?)
0194: textWriter.Write(" ");
0194: textWriter.Write(Convert.ToString(Html.TextBoxFor(model => model.Username)));
0196: textWriter.WriteLine();
I tried to add assemblies and namespaces in the nhaml's Web.config section but it doesn't change anything.
I'm using :
System.Web.Mvc 2.0
.NET Framework 3.5 SP1
Nhaml 1.5.0.2 from git trunk (and tried other builds)
My NHaml configuration is:
<nhaml autoRecompile="true" templateCompiler="CSharp3" encodeHtml="false" useTabs="false" indentSize="2">
It looks like you have an assembly reference problem.
You are probably referencing the MVC 1.0 assemblies, instead of 2.0 assemblies?
The problem is the view class contains a non-generic HtmlHelper. Or some new extension methods requires the ViewData.Model's type.
To correct this problem, change the property and instantiation in NHaml.Web.Mvc/NHamlMvcView.cs.
//public HtmlHelper Html { get; protected set; } // line 42
public HtmlHelper<TModel> Html { get; protected set; }
//Html = new HtmlHelper( viewContext, this ); // line 37
Html = new HtmlHelper<TModel>( viewContext, this );
Rebuild and use :)
As far as I can see the new MVC helpers are not supported, actually only a limited amount of HtmlHelpers are namely LinkExtensions. As a wild guess, you can possibly try to adding the LabelExtensions to the setup of the NHaml viewengine in the NHaml.Web.Mvc/NHamlMvcViewEngine.cs file (since you do have the source) and check if that works.
private void InitializeTemplateEngine()
{
// snip
_templateEngine.Options.AddReference( typeof( LabelExtensions ).Assembly.Location ); // Line 50
}