Base solution for your next web application
Open Closed

Adding Report Viewer into an ASP.NET Core app #5275


User avatar
0
jehadk created

Hello,

I am adding Report Viewer into an ASP.NET Core app. It works perfect!

Now, I try to move the Report Viewer to an existing ASP.NET Core (based on ASPNET Boilerplate framework).

When I run the application, the Report Viewer is actually showing in the Page. However, communication fails with the Report Storage on the server.

Below you can find the error generated and also the code in the Startup.cs class.

ComponentNotFoundException: No component for supporting the service DevExpress.AspNetCore.Reporting.WebDocumentViewer.WebDocumentViewerController was found Castle.MicroKernel.DefaultKernel.Castle.MicroKernel.IKernelInternal.Resolve(Type service, IDictionary arguments, IReleasePolicy policy) <<

The ASPNET Boilerplate uses Castle Windsor as DI. It seems the Controllers for the Report Viewer are not being registered with the DI!

The code for the Startup.cs class is below:

>> public IServiceProvider ConfigureServices(IServiceCollection services) { services.AddDevExpressControls();

// Adds MVC controllers for processing requests with the default routes.
services.AddMvc().AddDefaultReportingControllers();

var identityBuilder = IdentityRegistrar.Register(services);

//Identity server
if (bool.Parse(_appConfiguration["IdentityServer:IsEnabled"]))
{
	IdentityServerRegistrar.Register(services, _appConfiguration);
}

AuthConfigurer.Configure(services, _appConfiguration);

//Swagger - Enable this line and the related lines in Configure method to enable swagger UI
services.AddSwaggerGen(options =>
{
	options.SwaggerDoc("v1", new Info { Title = "BarznWeb API", Version = "v1" });
	options.DocInclusionPredicate((docName, description) => true);
});

//Recaptcha
services.AddRecaptcha(new RecaptchaOptions
{
	SiteKey = _appConfiguration["Recaptcha:SiteKey"],
	SecretKey = _appConfiguration["Recaptcha:SecretKey"]
});

services.AddScoped&lt;IWebResourceManager, WebResourceManager&gt;();

//Configure Abp and Dependency Injection
return services.AddAbp&lt;BarznWebWebMvcModule&gt;(options =>
{
	//Configure Log4Net logging
	options.IocManager.IocContainer.AddFacility&lt;LoggingFacility&gt;(
		f => f.UseAbpLog4Net().WithConfig("log4net.config")
	);

	options.PlugInSources.AddFolder(Path.Combine(_hostingEnvironment.ContentRootPath, "Plugins"));
});

}

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { //Initializes ABP framework. app.UseAbp(options => { options.UseAbpRequestLocalization = false; //used below: UseAbpRequestLocalization });

if (env.IsDevelopment())
{
	app.UseDeveloperExceptionPage();
}
else
{
	app.UseStatusCodePagesWithRedirects("~/Error?statusCode={0}");
	app.UseExceptionHandler("/Error");
}

app.UseAuthentication();

if (bool.Parse(_appConfiguration["Authentication:JwtBearer:IsEnabled"]))
{
	app.UseJwtTokenMiddleware();
}

if (bool.Parse(_appConfiguration["IdentityServer:IsEnabled"]))
{
	app.UseJwtTokenMiddleware("IdentityBearer");
	app.UseIdentityServer();
}

app.UseDevExpressControls();
ReportStorageWebExtension.RegisterExtensionGlobal(new EmbeddedResourcesReportStorageWebExtension(env));

app.UseStaticFiles();

if (DatabaseCheckHelper.Exist(_appConfiguration["ConnectionStrings:Default"]))
{
	app.UseAbpRequestLocalization();
}

app.UseMvc(routes =>
{
	routes.MapRoute(
		name: "defaultWithArea",
		template: "{area}/{controller=Home}/{action=Index}/{id?}");

	routes.MapRoute(
		name: "default",
		template: "{controller=Home}/{action=Index}/{id?}");
});

// Enable middleware to serve generated Swagger as a JSON endpoint
app.UseSwagger();

// Enable middleware to serve swagger-ui assets (HTML, JS, CSS etc.)
app.UseSwaggerUI(options =>
{
	options.SwaggerEndpoint("/swagger/v1/swagger.json", "BarznWeb API V1");
}); //URL: /swagger

}


5 Answer(s)
  • User Avatar
    0
    bilalhaidar created

    Hi Jehad,

    It seems the Castle Windsor is not catching the DevExpress Controllers.

    In the Startup\XXXWebMvcModule.cs, add the following and it should work smooth:

    public override void Initialize()
            {
                IocManager.RegisterAssemblyByConvention(typeof(BarznWebWebMvcModule).GetAssembly());
    
                IocManager.Register(typeof(WebDocumentViewerController), DependencyLifeStyle.Transient);
                IocManager.Register(typeof(QueryBuilderController), DependencyLifeStyle.Transient);
                IocManager.Register(typeof(ReportDesignerController), DependencyLifeStyle.Transient);
            }
    
  • User Avatar
    0
    alper created
    Support Team

    Or just inherit from AbpController

    public class WebDocumentViewerController : AbpController
    {
        public ActionResult Index()
        {
            return View();
        }
    }
    

    <a class="postlink" href="https://aspnetboilerplate.com/Pages/Documents/MVC-Controllers">https://aspnetboilerplate.com/Pages/Doc ... ontrollers</a>

  • User Avatar
    0
    bilalhaidar created

    Hi Alper, Those controllers are part of DLLs offered by DevExpress.

    Regards Bilal

  • User Avatar
    0
    alper created
    Support Team

    Then that's not the accurate solution.

  • User Avatar
    0
    velu created

    https://support.aspnetzero.com/QA/Questions/6219