microsoft / microsoft/CsWin32

.net framework style project support broken?

Open
#1,625 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C#
Stars
2.5k
Forks
124
Avg merge
1d 3h
Merged PRs (30d)
9

Description

Actual behavior

In .net framework style project, PInvoke functions are generated correctly, however the project cannot compile. I have uploaded a repro below.
Error info:

error CS0246: The type or namespace name 'Windows' could not be found (are you missing a using directive or an assembly reference?)

Expected behavior

Project should compile successfully.

Repro steps

Just create a WPF (.net framework) project In latest VS2022 and add some PInvoke functions.

  1. NativeMethods.txt content:
SetProcessWorkingSetSize (can be anything)
  1. NativeMethods.json content (if present):
  1. Any of your own code that should be shared?
    WpfApp1.zip
Context
  • CsWin32 version: v0.3.269
  • Win32Metadata version (if explicitly set by project): not set
  • Target Framework: .net framework 4.8
  • LangVersion (if explicitly set by project): latest

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open the attached WpfApp1.zip repro in Visual Studio 2022 and inspect the generated P/Invoke output and CS0246 build error for the .NET Framework 4.8 project. Start with the NativeMethods.txt input and compare behavior against a supported project type. Done means the generated functions remain available and the WPF project compiles successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.