Skip to content

Commit 6a0ca32

Browse files
author
KB Bot
committed
Added new kb article dpl-resolve-ambiguous-references
1 parent 45a52c2 commit 6a0ca32

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
title: Resolving Ambiguous references
3+
description: This article describes how to resolve ambiguous references due to cross-platform project references.
4+
type: how-to
5+
page_title: How to Resolve Ambiguous References
6+
slug: dpl-resolve
7+
tags: radspreadprocessing, document processing, wpf, ambiguous reference, extern alias
8+
res_type: kb
9+
ticketid: 1684241
10+
---
11+
12+
## Environment
13+
14+
| Version | Product | Author |
15+
| ---- | ---- | ---- |
16+
| 2025.1.205| Telerik Document Processing|[Desislava Yordanova](https://www.telerik.com/blogs/author/desislava-yordanova)|
17+
18+
## Description
19+
20+
When developing a WPF application that utilizes RadSpreadProcessing for Document Processing to set a font in a spreadsheet, and the solution includes a cross-platform project referencing `Telerik.Documents.Core`, an ambiguous reference error may occur. The issue arises due to identical namespaces in both assemblies when both platform-specific projects and cross-platform projects are part of the solution. This knowledge base article also answers the following questions:
21+
- How to resolve ambiguous reference errors in a WPF project using RadSpreadProcessing?
22+
- How to use RadSpreadProcessing in a WPF application with cross-platform project references?
23+
- How to set a spreadsheet font in WPF using RadSpreadProcessing without ambiguous references?
24+
25+
## Solution
26+
27+
To resolve the ambiguous reference error in a WPF application using RadSpreadProcessing alongside a cross-platform project, use the `extern alias` directive. This approach allows differentiating between assemblies that have the same namespace but are intended for different platforms. Follow the steps below to apply this solution:
28+
29+
1. **Assign an alias to the conflicting assembly in the WPF project**. Right-click on the referenced assembly (`Telerik.Documents.Core` in the cross-platform project) in the Solution Explorer and select `Properties`. In the `Aliases` field, enter a unique alias (e.g., `NetFramework`).
30+
31+
2. **Use the `extern alias` directive in your WPF project code**. At the top of your C# file where you are facing the ambiguous reference, declare the alias defined in step 1. This explicitly specifies which assembly to use for the conflicting types.
32+
33+
```csharp
34+
extern alias NetFramework;
35+
using NetFramework::Telerik.Documents.Common.Model;
36+
```
37+
38+
3. **Reference the `ThemableFontFamily` using the alias**. After specifying the extern alias, use it to qualify the namespace of the `ThemableFontFamily` class or any other ambiguous type. This disambiguates the reference and allows your code to compile successfully.
39+
40+
```csharp
41+
namespace YourNamespace
42+
{
43+
public class YourClass
44+
{
45+
public void YourMethod()
46+
{
47+
// Use the ThemableFontFamily from the aliased assembly
48+
ThemableFontFamily fontFamily = new ThemableFontFamily("Courier New");
49+
}
50+
}
51+
}
52+
```
53+
54+
By following these steps, you can successfully resolve the ambiguous reference error and set the spreadsheet font in a WPF application using RadSpreadProcessing, even when your solution includes cross-platform projects.
55+
56+
## See Also
57+
58+
- [Telerik Document Processing Introduction](https://docs.telerik.com/devtools/document-processing/introduction)
59+
- [What Versions of Document Processing Libraries are Distributed with the Telerik Products](https://docs.telerik.com/devtools/document-processing/knowledge-base/distribute-telerik-document-processing-libraries-net-versions)
60+
- [Resolve Compile-Time Error Between RadPdfProcessing and Telerik Reporting](https://docs.telerik.com/devtools/document-processing/knowledge-base/resolve-compile-time-error-radpdfprocessing-telerik-reporting)
61+
- [C# Extern Alias - Microsoft Documentation](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/extern-alias)

0 commit comments

Comments
 (0)