dotnet / dotnet/wpf

namespace collision in clr-namespace

Open
#7,173 8 comments 1 reaction 0 assignees View on GitHub
:construction: work in progress Investigate
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

* .NET Core Version: 7.0-rc1
* Windows version: 11
* Does the bug reproduce also in WPF for .NET Framework 4.8?: Don't know, not tested

**Problem description:**
`MainWindow.xaml(28, 27): [CS0234] The type or namespace name 'Wpf' does not exist in the namespace 'Comlink.CefSharp' (are you missing an assembly reference?)`

This is the error I get, the error itself is "correct". that namespace does not contain Wpf. However, .NET shouldn't even be looking in that namespace in the first place, since I have defined an assembly in my xaml file.

to give some more details:
`/src/View/MainWindow.xaml`
```c#

```

`/src/View/MainWindow.xaml`
```c#
using System.Windows;
using Comlink.Core;
using Comlink.CefSharp;

namespace Comlink.Example.View
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}

private void Initialize()
{
Kaas kaas = new Kaas();
Proxy proxied = Core.Comlink.Proxy(kaas);

CefSharpBrowser.Expose(kaas);
dynamic remote2 = Core.Comlink.Wrap(CefSharpBrowser.ToEndpoint());
remote2.SomeMethod("a string value");
}
}

public class Kaas
{

}

public class ClientSchema
{

}
}
```

`csproj file`
```xml


WinExe
net7.0-windows
true
true
$(NoWarn);1591
Comlink.Example.View.App
enable

$(NETCoreSdkRuntimeIdentifier)
false
x64








MSBuild:Compile
Wpf
Designer



MSBuild:Compile
Wpf
Designer

```

It seems to me that the generated g code in the obj folder is what is causing the naming collision between my referenced project and the package. I don't really understand why though because I did add the `assembly` attribute in the xaml file.

If you want to take a deeper look at the source files of this project you can find it in https://github.com/chris-kruining/comlink-sharp/tree/main/Comlink.Example

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.