Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reference problem in WPF environment #20

Closed
JakobFerdinand opened this issue Apr 14, 2021 · 3 comments
Closed

Reference problem in WPF environment #20

JakobFerdinand opened this issue Apr 14, 2021 · 3 comments

Comments

@JakobFerdinand
Copy link

When using the library in a WPF environment it´s not possible to add a reference to the included types.
I found that problem with my own library and was hoping, that you solved it somehow but I can recreate the issue with your project.

I created a sample project to recreate the issue.
The branch nullable shows the problem with your library.

Its a simple console application that also includes a WPF User Control.
image

using System;
using System.Diagnostics.CodeAnalysis;

namespace TheWPFClient
{
    class Program
    {
        [AllowNull] private readonly string OptionalValue;

        static void Main(string[] args)
        {
            Console.WriteLine("Hello beatiful World!");
        }
    }
}

When compiling the code that build error accours:

Program.cs(8,10,8,19): error CS0246: The type or namespace name 'AllowNullAttribute' could not be found (are you missing a using directive or an assembly reference?)
Program.cs(8,10,8,19): error CS0246: The type or namespace name 'AllowNull' could not be found (are you missing a using directive or an assembly reference?)

If you delete the usercontrol the error is gone.

@chucker
Copy link

chucker commented Apr 14, 2021

This may be related to #11

@JakobFerdinand
Copy link
Author

Oh thank you!
Following you discussion to microsoft/CsWin32#7 guided me to the solution.

It´t the same problem with the temp project files during build and I have to add the following property in my project:

<IncludePackageReferencesDuringMarkupCompilation>true</IncludePackageReferencesDuringMarkupCompilation>

@manuelroemer
Copy link
Owner

manuelroemer commented Apr 14, 2021

Glad that this resolved your issue!
I decided to pin #11 so that it is easier to discover in the future.

I also updated the README with a reference to the issue and with the solution for WPF users. Thanks @JakobFerdinand for raising the issue, that reminded me that I should update the README with this info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants