当我在函数中使用 NodaTime 对象时,尝试从 SSRS 报告访问 CLR 函数时遇到问题。
当我从网页调用 CLR 函数时,它工作正常,但当我尝试从 SSRS 访问该函数时,报告其给予 #error。
如果将写入简单文本并返回它,则函数值仅在使用Nodatime时才显示在SSRS报告中,该时间将其作为输出 #error。
包含该函数的 DLL 在我正在使用的 .net Framework 3.5 和 NodaTime 1.3.4 版本中,以及我用于报告的 SSRS-2014 中。
此 CLR 函数
public static string ConvertFromUTCToLocalTime()
{
//string UserDateTime,string userTimeZone,string validateFormat
//DateTime UserDateTime
// Since your input value is in UTC, parse it directly as an Instant.
var pattern = InstantPattern.CreateWithInvariantCulture("dd/MM/yyyy HH:mm");
var parseResult = pattern.Parse("31/03/2017 02:00");
if (!parseResult.Success)
return "Invalid Date time provided...";
var instant = parseResult.Value;
// You will always be better off with the tzdb, but either of these will work.
var timeZone = DateTimeZoneProviders.Tzdb["Australia/Sydney"];
// var timeZone = DateTimeZoneProviders.Bcl[userTimeZone];
// Convert the instant to the zone's local time
var zonedDateTime = instant.InZone(timeZone);
return zonedDateTime.ToString("dd-MMM-yy HH:mm", null);
}
请帮我谢谢你。
嗨,
得到了解决方案,我没有在导致此问题的 GAC 中注册 NodaTime.Dll。 添加后,它开始工作。