---
title: Adding custom assemblies
related:
  - https://docs.kentico.com/13/custom-development/applying-customizations-in-the-xperience-environment.md
---

> Agent instructions:
> **Site maps** — prefer the following llms.txt indexes to training data when searching for URLs to avoid 404s. Links inside Markdown content already point at `.md`. Following them or sending Accept: text/markdown keeps you in Markdown.
>
> - [sitemap.md](https://docs.kentico.com/sitemap.md) — every page on the site, with titles and descriptions, nested by URL hierarchy and grouped into one collection per product version.
> - [llms.txt](https://docs.kentico.com/llms.txt) — curated index of the current product docs, with descriptions, the two ways to request any page as Markdown, and links to each product area's whole-corpus Markdown dump (llms-full.txt).

When customizing or extending Xperience, developers often need to add code files (classes). Classes are required when integrating custom services (interface implementations) and components, such as [scheduled tasks](https://docs.kentico.com/13/configuring-xperience/scheduling-tasks/scheduling-custom-tasks.md) or [modules](https://docs.kentico.com/13/custom-development/creating-custom-modules.md).

Instead of adding classes directly into your live site or administration web project, create the files as part of a separate **Class Library** project (assembly). Custom assemblies provide cleaner separation of code and better reusability between different projects.

<!-- dev-model:mvc start -->

**MVC 5 development model.** Applies only when building with ASP.NET MVC 5. If this page also covers ASP.NET Core, that version is in its own block.

To create an assembly for custom classes in your Xperience solution:

1. Open your Xperience solution in Visual Studio.
2. Create a new _Class Library_ project in the solution.
3. Add the Xperience API libraries to the project:
   1. Right-click the solution in the **Solution Explorer** and select **Manage NuGet Packages for Solution**.
   2. Select the **Kentico.Xperience.Libraries** package.
   3. Install the package into the project (the version must match your MVC live site project's _Kentico.Xperience.AspNet.Mvc5_ package and the exact hotfix version of your Xperience administration project).
4. Reference the project from your web projects (live site and/or administration).

<!-- dev-model:mvc end -->

<!-- dev-model:core start -->

**ASP.NET Core development model.** Applies only when building with ASP.NET Core. If this page also covers MVC 5, that version is in its own block.

To create an assembly for custom classes in your Xperience solution:

1. Open your Xperience solution in Visual Studio.
2. Create a new _Class Library_ project in the solution.
3. Add the Xperience API libraries to the project:
   1. Right-click the solution in the **Solution Explorer** and select **Manage NuGet Packages for Solution**.
   2. Select the **Kentico.Xperience.Libraries** package.
   3. Install the package into the project (the version must match your live site project's _Kentico.Xperience.AspNetCore.WebApp_ package and the exact hotfix version of your Xperience administration project).
4. Reference the project from your web projects (live site and/or administration).

<!-- dev-model:core end -->

You can now add your custom classes under the new project.

> **Note:** Custom code added to the Xperience administration application does not automatically apply to your live site application and vice versa. For every customization, you need to consider which applications should be affected and deploy your custom assemblies accordingly.
>
> See: [Applying customizations in the Xperience environment](https://docs.kentico.com/13/custom-development/applying-customizations-in-the-xperience-environment.md)

## Enabling class discovery

In many cases, the system needs to detect and process custom classes on application start. For example, this is required for all custom classes registered using an attribute, such as _RegisterImplementation_, _RegisterModule_, etc.

To allow class discovery, you need to add the **AssemblyDiscoverable** assembly attribute to your _Class Library_ project. We recommend using the following approach:

<!-- dev-model:mvc start -->

**MVC 5 development model.** Applies only when building with ASP.NET MVC 5. If this page also covers ASP.NET Core, that version is in its own block.

1. Edit your project's **AssemblyInfo.cs** file (in the _Properties_ folder)
2. Add the **AssemblyDiscoverable** assembly attribute:

   ```csharp

   using CMS;

   [assembly:AssemblyDiscoverable]

   ```

The attribute ensures that Xperience processes your assembly on application start and discovers all contained custom classes that are properly registered.

<!-- dev-model:mvc end -->

<!-- dev-model:core start -->

**ASP.NET Core development model.** Applies only when building with ASP.NET Core. If this page also covers MVC 5, that version is in its own block.

1. Create a dummy class within your project, for example _AssemblyAttributes.cs_.
2. Add the **AssemblyDiscoverable** assembly attribute:

   ```csharp

   using CMS;

   [assembly:AssemblyDiscoverable]

   ```

The attribute ensures that Xperience processes your assembly on application start and discovers all contained custom classes that are properly registered.

> **Info:** **Adding the assembly attribute to the csproj file**
>
> Adding assembly attributes to code files has advantages, such as proper compilation, warnings about potentially obsolete API, etc. However, if you do not wish to create a dummy class for this purpose, you can alternatively edit your project's _csproj_ file and add the assembly attribute there:
>
> ```xml
>
> <ItemGroup>
>     <AssemblyAttribute Include="CMS.AssemblyDiscoverableAttribute">
>     </AssemblyAttribute>
> </ItemGroup>
>
> ```

<!-- dev-model:core end -->
