Closed akokouri closed 10 months ago
CsWin32 only generates C# code. There is no way it will work for you in a .vbproj.
@AArnott is there a way to generate the code in a C# project but reference it from a VB Project. An example of this would be very useful.
Sure. You can configure your C# project to generate the APIs, and either use InternalsVisibleToAttribute
in the C# project to expose those APIs to your VB project, or use the NativeMethods.json file to configure the generated code to be public
instead of internal
.
But it's still not supported, because VB doesn't support pointers, and interop often requires pointers. Not always though, so your mileage may vary.
Actual behavior
We are trying to use Microsoft.Windows.CsWin32 in a VbProj WinForms net6 and we have issue with the namespace. The winforms namespace is System.Windows.Forms. In many generated code the code is used like Windows.Forms instead of System.Windows.Forms. This cause the project to fail in build, because is confused with Windows.Win32 (namespace) generated code.
Expected behavior
To have a completed build
Repro steps
Use the Microsoft.Windows.CsWin32 in a vb winforms project that has autogenerated code that uses Windows.Forms instead of System.Windows.Forms
Is there any workaround for this? Could we change the generated namespace in something else?