Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions getting-started/Installation/nuget-packages.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,4 @@ The following list represents the available NuGet packages for the Document Proc

* [Restoring NuGet Packages in Your CI Workflow]({%slug using-nuget-keys%})
* [How to Obtain Telerik Document Processing Libraries for .NET Framework, .NET Standard, .NET Core, .NET 6/.NET 8/.NET 9]({%slug distribute-telerik-document-processing-libraries-net-versions%})
* [Resolving Namespace Conflicts in Telerik Document Processing Libraries]({%slug radspreadprocessing-resolving-namespace-conflicts%})
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added knowledge-base/images/frameworkhelper-alias.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added knowledge-base/images/installed-packages.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added knowledge-base/images/standardhelper-alias.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
73 changes: 73 additions & 0 deletions knowledge-base/resolving-namespace-conflicts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
---
title: Resolving Namespace Conflicts in Telerik Document Processing Libraries
description: This article demonstrates how to resolve namespace conflicts when using Telerik Document Processing in a .NET Core project with both .NET Standard and .NET Framework packages/assemblies referenced.
type: how-to
page_title: How to Fix Namespace Conflicts in RadSpreadProcessing for Document Processing
slug: radspreadprocessing-resolving-namespace-conflicts
tags: spreadprocessing, document, processing, namespace, extern, alias, net, core, standard
res_type: kb
ticketid: 1673450
---

## Environment

| Version | Product | Author |
| --- | --- | ---- |
| 2024.4.1106| Telerik Document Processing |[Desislava Yordanova](https://www.telerik.com/blogs/author/desislava-yordanova)|

## Description

When working on a .NET Core project that utilizes both, the .NET Standard and .NET Framework version of a specific Document Processing library, e.g. `Telerik.Documents.Spreadsheet` and `Telerik.Windows.Documents.Spreadsheet` packages, a namespace conflict arises due to the `Workbook` class existing in both packages. This conflict results in a compiler error, preventing successful compilation.

![Installed Packages](images/installed-packages.png)

>note It is not recommended to install the .NET Standard and .NET Framework version of the Document Processing libraries simultaneously in the same project. Install the NuGet package which is compatible with the application's Target framework and Target OS.

![Conflicting Assemblies Error](images/conflicting-assemblies-error.png)

This knowledge base article also answers the following questions:
- How can I resolve type conflicts in .NET Core projects using Telerik Document Processing libraries?
- What is the correct way to handle namespace conflicts when using Telerik Document Processing in mixed .NET environments?
- How do I use the C# extern alias feature to differentiate between similar types in different assemblies?

## Solution

Depending on the target framework of your project (NET Framework, .NET Standard .NET Core, .NET 6, etc.), you should install the library version accordingly. However, if you need to install both versions for any reason, to resolve the compile-time error caused by the conflicting `Workbook` type in both assemblies, utilize the C# [extern alias](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/extern-alias) feature. This approach allows you to differentiate between assemblies and use types from both without conflict. Follow the steps below:

1. **Assign Alias to NuGet Packages**
- For the `Telerik.Documents.Spreadsheet` NuGet package, set its alias to `StandardHelper` (or any preferred alias).
- For the `Telerik.Windows.Documents.Spreadsheet` NuGet package, set its alias to `FrameworkHelper` (or any preferred alias).

![StandardHelper Alias](images/standardhelper-alias.png)

![FrameworkHelper Alias](images/frameworkhelper-alias.png)

2. **Use Extern Alias in Your Code**
- At the top of your source file where you intend to use the conflicting types, add the `extern alias` directive for each alias you assigned. This directive differentiates the assemblies, allowing you to reference each type explicitly.

```csharp
extern alias StandardHelper;
//extern alias FrameworkHelper;

using StandardHelper::Telerik.Windows.Documents.Spreadsheet.Model;
//using FrameworkHelper::Telerik.Windows.Documents.Spreadsheet.Model;

namespace YourNamespace
{
internal class Program
{
static void Main(string[] args)
{
Workbook workbook;
}
}
}
```

By following these steps, you can successfully resolve the namespace conflict and use the `Workbook` class from the desired NuGet package in your .NET Core project.

## See Also

- [Installation: NuGet Packages for Document Processing]({%slug installation-deploying-telerik-document-processing%})
- [C# Language Reference: extern alias](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/extern-alias)
- [What Versions of Document Processing Libraries are Distributed with the Telerik Products]({%slug distribute-telerik-document-processing-libraries-net-versions%})
6 changes: 5 additions & 1 deletion troubleshooting/telerik-nuget.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,8 @@ Another common problem is that your machine (PC, GitHub Actions runner or Azure

* https://nuget.telerik.com/nuget/Search()?$filter=IsAbsoluteLatestVersion&searchTerm=%27WPF%27&includePrerelease=true&$skip=0&$top=100&semVerLevel=2.0.0.

After you enter your telerik.com username and password, you should see an XML search result containing a list of all the Telerik.UI.for.WPF packages available with your license.
After you enter your telerik.com username and password, you should see an XML search result containing a list of all the Telerik.UI.for.WPF packages available with your license.

## See Also

* [Resolving Namespace Conflicts in Telerik Document Processing Libraries]({%slug radspreadprocessing-resolving-namespace-conflicts%})