Using module provider in external DLL.

Richard Coady asked on August 21, 2019 12:08

Hi,

I have built a scheduled task to synch some data. I have implemented this as an external dll.

I am using a Kentico module to save the configuration settings, but when I copy the provider code to my external dll I get an error because now there are two versions of the provider code one in Kentico and one in my dll. Is there a way I can reference the module provider in my external dll?

[A]SensorPro.ConfigurationInfo cannot be cast to [B]SensorPro.ConfigurationInfo. Type A originates from 'App_Code.r2cqedid, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' in the context 'Default' at location 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\kentico11\d58782dc\690f4b74\App_Code.r2cqedid.dll'. Type B originates from 'NT.Interface.Kentico11, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' in the context 'Default' at location 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\kentico11\d58782dc\690f4b74\assembly\dl3\d3e9585c\229fbedc_0158d501\NT.Interface.Kentico11.dll'.

Thanks for the advice Regards Richard

Correct Answer

Dmitry Bastron answered on August 21, 2019 12:14

Hi Richard,

It is considered to be a best practice if you move all you generated code (classes and providers) into a separate project (assembly, dll). So that you can reference it in CMS and in your task project without duplicating the code.

1 votesVote for this answer Unmark Correct answer

Recent Answers


Ketan Hirapara answered on August 21, 2019 12:29

As said by the Dmitry you can created new class library project in which you have to create new public class with you logic for that task.

This all are lies in the CMSApp solution not in MVC solution.

And then in Admin panel(CMS) follow below steps.
1 - Create new task in "Scheduled tasks" application.
2 - In task provider give your generated class library project name.
3 - Select the logic class file from that project below this text box.
4 - Set your schedule in period from (second,minute,hour,weekly etc).
5 - Also can schedule by the days and time.

Hope it will gives you brief idea about how to set the task.

1 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.