.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

3 REPLIES 3
Reply
Message 1 of 4
ivanstarr3
211 Views, 3 Replies

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

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.

Labels (1)
3 REPLIES 3
Message 3 of 4
norman.yuan
in reply to: ivanstarr3

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

Message 4 of 4
18348401357
in reply to: ivanstarr3

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report