当我在函数中使用NodaTime对象时,尝试从SSRS报告访问CLR函数时,我将面临问题。
当我从网页调用CLR函数时,它正常工作,但是当我试图从SSRS访问该函数时,请报告它给出的#错误。
如果要编写简单文本并返回它,则函数值仅在使用Nodatime时才显示在SSRS报告中,它将#error作为输出。
我的DLL包含这个函数,在我使用的.net Framework3.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);
}请帮我谢谢。
发布于 2017-04-04 06:52:17
Hi得到的解决方案,我没有注册的NodaTime.Dll在GAC,这是造成这个问题。一旦我加上它就开始起作用了。
https://stackoverflow.com/questions/43135629
复制相似问题