MissingFieldException when assigning to a function pointer field
- Dominant language
- F#
- Stars
- 4.3k
- Forks
- 876
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 131
Description
Trying to use a field with function pointer type throws a MissingFieldException in runtime.
**Repro steps**
Provide the steps required to reproduce the problem:
1. Create a new F# console app
2. Add [TerraFx.Interop.Windows](https://github.com/terrafx/terrafx.interop.windows) package
```xml
```
2. Use the following code:
```fsharp
open TerraFX.Interop.Windows
let mutable windowClassDescriptor = WNDCLASSEXW()
windowClassDescriptor.lpfnWndProc <- 0n // lpfnWndProc is of type delegate* unmanaged in C#
printfn "Successfully Finished"
```
Zip with repro:
[MissingFieldExceptionRepro.zip](https://github.com/dotnet/fsharp/files/7786336/MissingFieldExceptionRepro.zip)
**Expected behavior**
Program finishes and prints "Successfully Finished"
**Actual behavior**
Throws exception
```
Unhandled exception. System.MissingFieldException: Field not found: 'TerraFX.Int
erop.Windows.WNDCLASSEXW.lpfnWndProc'.
at .$Program.main@()
```
**Known workarounds**
No workarounds known to me
**Related information**
Provide any related information (optional):
* Operating system: Win11
* .NET Runtime kind (.NET Core, .NET Framework, Mono): .NET 6, SDK 6.0.100
* Editing Tools (e.g. Visual Studio Version, Visual Studio): Rider (and command line)
[Here is the definition of the field in the TerraFX repo](https://github.com/terrafx/terrafx.interop.windows/blob/main/sources/Interop/Windows/Windows/um/WinUser/WNDCLASSEXW.cs#L19). Commenting out the assignment fixes the problem, but the field is required.
Contributor guide
Assessment
This issue has not been assessed yet.