Custom referenced assembly not recognized in mvc core.

Stimulsoft Reports.NET discussion
Post Reply
alireza_s_84
Posts: 18
Joined: Fri Jan 27, 2017 4:43 am

Custom referenced assembly not recognized in mvc core.

Post by alireza_s_84 »

Hi
I add current assembly to report ReferencedAssemblies as below:

Code: Select all

var list = report.ReferencedAssemblies.ToList();
list.Add("StimulTest.dll");
report.ReferencedAssemblies = list.ToArray();
Then use in report like this:

Code: Select all

{StimulTest.DateHelper.ToPersian(Today)}
But this not work.
Are Mvc core support custom ReferencedAssemblies?
Attachments
StimulTest.rar
(902.45 KiB) Downloaded 173 times
Lech Kulikowski
Posts: 6245
Joined: Tue Mar 20, 2018 5:34 am

Re: Custom referenced assembly not recognized in mvc core.

Post by Lech Kulikowski »

Hello,

Unfortunately, it is not supported. In the NET Core is available only Interpretation mode.

Thank you.
alireza_s_84
Posts: 18
Joined: Fri Jan 27, 2017 4:43 am

Re: Custom referenced assembly not recognized in mvc core.

Post by alireza_s_84 »

Lech Kulikowski wrote: Fri Feb 01, 2019 9:51 pm Hello,

Unfortunately, it is not supported. In the NET Core is available only Interpretation mode.

Thank you.
Thanks for reply, I want to use a custom function for convert date there is any way for that?
Lech Kulikowski
Posts: 6245
Joined: Tue Mar 20, 2018 5:34 am

Re: Custom referenced assembly not recognized in mvc core.

Post by Lech Kulikowski »

Hello,

You can add necessary functions in the Dictionary of the designer.

Thank you.
alireza_s_84
Posts: 18
Joined: Fri Jan 27, 2017 4:43 am

Re: Custom referenced assembly not recognized in mvc core.

Post by alireza_s_84 »

Lech Kulikowski wrote: Sat Feb 02, 2019 9:16 am Hello,

You can add necessary functions in the Dictionary of the designer.

Thank you.
I add functions as below:

Code: Select all

namespace DoctorCode.AspNetCore.Reports
{
    public static class Test
    {
        public static string Print()
        {
            return "Alireza";
        }
    }

    public static class PersianDateTimeHelper
    {
        public static void RegisterFanctions()
        {
            var types = new[]
            {
                new
                {
                    Type = typeof(PersianDateTime),
                    Category = "PersianCulture",
                    GroupFunctionName = "DateTime"
                },

                new
                {
                    Type = typeof(Test),
                    Category = "Test",
                    GroupFunctionName = ""
                },
            };

            foreach (var item in types)
            {
                item.Type.RegisterFanctions(item.Category, item.GroupFunctionName);
            }
        }

        private static void RegisterFanctions(this Type type, string category, string groupFunctionName)
        {
            var methods = type.GetMethods(BindingFlags.Static | BindingFlags.Public);
            foreach (var method in methods)
            {
                StiFunctions.AddFunction(
                    category: category,
                    groupFunctionName: groupFunctionName,
                    functionName: method.Name,
                    description: "",
                    typeOfFunction: type,
                    returnType: method.ReturnType,
                    returnDescription: "",
                    argumentTypes: method.GetParameters().Select(p => p.ParameterType).ToArray(),
                    argumentNames: method.GetParameters().Select(p => p.Name).ToArray(),
                    argumentDescriptions: new string[0]);
            }
        }
    }
}
All functions are registered and display in Dictionary but functions from external assembly (typeof(PersianDateTime)) not work but typeof(Test) work.
It is necessary to define the type in the current assembly???
alireza_s_84
Posts: 18
Joined: Fri Jan 27, 2017 4:43 am

Re: Custom referenced assembly not recognized in mvc core.

Post by alireza_s_84 »

alireza_s_84 wrote: Sat Feb 02, 2019 4:52 pm
Lech Kulikowski wrote: Sat Feb 02, 2019 9:16 am Hello,

You can add necessary functions in the Dictionary of the designer.

Thank you.
I add functions as below:
All functions are registered and display in Dictionary but functions from external assembly (typeof(PersianDateTime)) not work but typeof(Test) work.
It is necessary to define the type in the current assembly???

Code: Select all

using System;

namespace DoctorCode.Globalization
{
    public static class PersianDateTime
    {
        public static string Now()
        {
            return Now("G");
        }

        public static string Now(string format)
        {
            if (string.IsNullOrEmpty(format))
            {
                throw new ArgumentException(nameof(format));
            }

            using (CultureHelper.NewPersian())
            {
                return DateTime.Now.ToString(format);
            }
        }

        public static string Today()
        {
            using (CultureHelper.NewPersian())
            {
                return DateTime.Now.ToString("yyyy/MM/dd");
            }
        }

        public static string Today(string format)
        {
            if (string.IsNullOrEmpty(format))
            {
                throw new ArgumentException(nameof(format));
            }

            using (CultureHelper.NewPersian())
            {
                return DateTime.Now.ToString(format);
            }
        }

        public static string ToShortDateString(DateTime date)
        {
            using (CultureHelper.NewPersian())
            {
                return date.ToShortDateString();
            }
        }

        public static string ToLongDateString(DateTime date)
        {
            using (CultureHelper.NewPersian())
            {
                return date.ToLongDateString();
            }
        }

        public static string ToShortTimeString(DateTime date)
        {
            using (CultureHelper.NewPersian())
            {
                return date.ToShortTimeString();
            }
        }

        public static string ToLongTimeString(DateTime date)
        {
            using (CultureHelper.NewPersian())
            {
                return date.ToLongTimeString();
            }
        }

        public static string Format(DateTime date, string format)
        {
            using (CultureHelper.NewPersian())
            {
                return date.ToString(format);
            }
        }

    }
}
If we have methods with same name and different parameters and call this method not work.
Lech Kulikowski
Posts: 6245
Joined: Tue Mar 20, 2018 5:34 am

Re: Custom referenced assembly not recognized in mvc core.

Post by Lech Kulikowski »

Hello,

Please send us a sample project which reproduces the issue for analysis on support@stimulsoft.com

Thank you.
duc.buingoc89
Posts: 1
Joined: Tue Nov 26, 2019 1:13 am

Re: Custom referenced assembly not recognized in mvc core.

Post by duc.buingoc89 »

Hello,

I have same proplem

Please see my attached file and help me solve this problem

Thank you.
Attachments
StimulReportTest.zip
(909.52 KiB) Downloaded 166 times
Lech Kulikowski
Posts: 6245
Joined: Tue Mar 20, 2018 5:34 am

Re: Custom referenced assembly not recognized in mvc core.

Post by Lech Kulikowski »

Hello,

We need some additional time to investigate the issue, we will let you know about the result.

Thank you.
Post Reply