问题描述
我正在尝试构建服务以从我的webapi中的一项操作导出rdlc Localreport。 Webapi建立在.net core 3.1上
我知道reportviewer与.net核心不兼容,因此,为了缓解这种情况,我在基于.net Framework 4.7.2的项目中添加了一个类库项目。到目前为止,对类库的引用已添加到我的.net核心webapi中。我可以从类库中调用方法,没问题。
现在尝试将LocalReport添加到我的类库中的一个类...。
using Microsoft.Reporting.WebForms;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace Reports
{
public class RenderAction
{
public void GetOrderReport()
{
string codeBase = Assembly.GetExecutingAssembly().CodeBase;
UriBuilder uri = new UriBuilder(codeBase);
string path = Uri.UnescapeDataString(uri.Path);
string p = Path.GetDirectoryName(path);
string reportPath = Path.Combine(p,"Reports","Order.rdlc");
if (!File.Exists(reportPath)) { return; }
var report = new LocalReport();
}
}
}
intellisense提示安装Microsoft.Reporting.Viewer,所以我这样做了……在运行时中调用函数时,在创建localreport的新实例时出现以下错误:
System.MissingMethodException
HResult=0x80131513
Message=Method not found: 'Void System.AppDomainSetup.set_ActivationArguments(System.Runtime.Hosting.ActivationArguments)'.
Source=Microsoft.ReportViewer.Common
StackTrace:
at Microsoft.Reporting.ReportRuntimeSetupHandler.InitAppDomainPool(Evidence sandboxEvidence,PolicyManager policyManager)
at Microsoft.Reporting.LocalService..ctor(ILocalCatalog catalog,Evidence sandboxEvidence,PolicyManager policyManager)
at Microsoft.Reporting.ControlService..ctor(ILocalCatalog catalog)
at Microsoft.Reporting.WebForms.LocalReport..ctor()
at Myproject.Reports.RenderAction.GetOrderReport() in C:\Users\RudiGroenewald\source\repos\Myproject-Api-Common\Myproject_Api_Common\Myproject_Reports\RenderAction.cs:line 24
at Myproject.Api.Common.Controllers.ReportsController.Get() in C:\Users\RudiGroenewald\Source\Repos\Myproject-Api-Common\Myproject_Api_Common\Myproject_Api_Common\Controllers\ReportsController.cs:line 22
at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target,Object[] parameters)
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncObjectResultExecutor.Execute(IActionResultTypeMapper mapper,ObjectMethodExecutor executor,Object controller,Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<<InvokeActionMethodAsync>g__Logged|12_1>d.MoveNext()
似乎是某种dll版本不匹配或某种……真的很难过。
是否无法正常工作?我的选择是拥有一个完整的.net webapi,仅用于报表编写,而我不希望这样做。对我在做什么错有任何想法吗?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)