I can't get a basic C# .NET project WITH WINDOWS FORMS to work

I can't get a basic C# .NET project WITH WINDOWS FORMS to work

ivanstarr3
Contributor Contributor
627 Views
3 Replies
Message 1 of 4

I can't get a basic C# .NET project WITH WINDOWS FORMS to work

ivanstarr3
Contributor
Contributor

I'm trying to create  a basic C# .NET project WITH WINDOWS FORMS to work, but nothing works.  For some reason, when you follow the the directions in https://help.autodesk.com/view/OARX/2025/ENU/?guid=GUID-43564EB9-F843-4771-823C-573495EE23E0 which supposedly how to create a new project in .NET, there is no option int the project explorer to add a new form.

 

This is something basic that should be covered.  .NET without forms is ridiculous.

0 Likes
Accepted solutions (1)
628 Views
3 Replies
Replies (3)
Message 3 of 4

norman.yuan
Mentor
Mentor

It is not AutoCAD programming issue, strictly speaking. It is how to do .NET Core (since .NET 5) with Visual Studio.

If you followed mentioned link to create a class library project, by default the project does not include references to UI libraries for Win Form and WPF UI. So, in the project if you right-click the project and select "Add New Item...", the new item dialog box would not show UI related items, nor the right-clicked context menu shows those. In order to use WinForm/WPF UI items in the class library, you need to edit the project file (*.csproj) by right click the project and select "Edit Project File". You need to add following <ItemGroup>:

<ItemGroup>
<FrameworkReference Include="Microsoft.WindowsDesktop.App.WindowsForms" />
<FrameworkReference Include="Microsoft.WindowsDesktop.App.WPF" />
</ItemGroup>

 

Also, in the <PropertyGroup>, add

 

<PropertyGroup>

   ...

   <UseWindowsForms>true</UseWindowsForms>

   <UseWPF>true<.UseWPF.

</PropertyGroup>

Note, these add both Windows Form and WPF references. you can choose only add one of them, if you wish.

HTH

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 4 of 4

18348401357
Enthusiast
Enthusiast

open your csproj file of your project ,add options like this to use windowsforms or wpf
QQ20241225-153857.png

0 Likes