Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • David Amri 214 posts 740 karma points
    Dec 13, 2018 @ 12:21
    David Amri
    0

    access ApplicationEventHandler in class library

    Hi,

    I have a examine controller (ExamineJsonIndexer.cs) that indexes json data. The controller is located in a class library project within the Umbraco solution. In order to run the controller code I need to have access to the Umbraco.Core.

    Upon build the class library project returns a customClassLibrary.dll file which is then referenced in the Umbraco project. All seems to work fine locally but when publishing the customClassLibrary.dll file to the server the site breaks?

    I'm guessing the customClassLibrary.dll file not only includes the code of the ExamineJsonIndexer.cs file but also the dependent Umbraco.Core. So when referencing the customClassLibrary.dll file within the Umbraco project there are two dll files with duplicate code.

    • umbracoSite.dll (has Umbraco.Core among other things)
    • customClassLibrary.dll (has Umbraco.Core)

    If I would like to separate my custom classes with a class library project in order to generate a separate dll file for me to publish to the server how would I do this? The reason I would like to build a separate dll file for the custom classes is that I don't publish the site from VS. I'm basically using FTP to move files from VS to the server and Courier to move data.

    Best regards /David

  • Marcio Goularte 374 posts 1346 karma points
    Dec 13, 2018 @ 13:25
    Marcio Goularte
    100

    Hi David,

    I do this by creating a class library and added via nuget the Umbraco but only the Core.

    Install-Package UmbracoCms.Core
    

    or

    Install-Package UmbracoCms.Core -Version x.xx.x
    

    So I create everything separately. Normally the front-end project is only for Views (templates) and App plugins. The controllers and Application event handlers do everything separately.

    When you reference the class library in the web project that you publish, when compiling the dll will be in the bin folder

  • David Amri 214 posts 740 karma points
    Dec 13, 2018 @ 13:28
    David Amri
    0

    I just discovered that the class code was dirty and now its working :D.

    As you said, I did install the Umbraco.Core via nuget to the class library.

    Thanks

Please Sign in or register to post replies

Write your reply to:

Draft