C# Add reference to PresentationFramework

C# Add reference to PresentationFramework

snappyjazz
Collaborator Collaborator
3,852 Views
4 Replies
Message 1 of 5

C# Add reference to PresentationFramework

snappyjazz
Collaborator
Collaborator

Hello,

I started learning programming using vb.net and am now learning C#. I am trying to rewrite my code for AutoCAD commands, but am having this issue. It doesn't have this issue in the VB.NET version I should add. In the code snippet below the issue for all is: The type control is defined in an assembly that is not referenced. You must add a reference to assembly 'PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. How do I add that reference? why does it have this issue in C# and not VB.NET?

 

snappyjazz_2-1709312618418.pngsnappyjazz_3-1709312642435.png

 

0 Likes
Accepted solutions (1)
3,853 Views
4 Replies
Replies (4)
Message 2 of 5

norman.yuan
Mentor
Mentor
Accepted solution

Where do you write your code (seeing all the noisy "// PropertyGroup.....  " thing)? VS Code, or Visual Studio? You should use Visual Studio.

 

Also seeing "<TargetFrameworkAttribute>.net 5.0 - window..." suggests that you target the wrong .NET version. Before Acad2025 release, you can only use .NET Framework 4.x (depending on your version of AutoCAD, if it is not too old version).

 

Since AutoCAD ribbon is built on top of WPF, you do need to add following references "PresentationFramework, WindowBase, System.Xaml, if you want to deal with Ribbon from the AdWindows.dll. In the project explorer, you right click "references" node, click "Add References..." and then in the dialog box, select "Assemblies" on the left pane, then find these references and select/check them.

 

 

Norman Yuan

Drive CAD With Code

EESignature

Message 3 of 5

snappyjazz
Collaborator
Collaborator

@norman.yuan  

Adding those references is what worked. Thank you!

0 Likes
Message 4 of 5

pts_user
Contributor
Contributor

I am facing the exact same issue and I am trying to add the dlls but not being able to. The Project explorer as you mentioned is nowhere to be found. Please can you help me with this.

0 Likes
Message 5 of 5

norman.yuan
Mentor
Mentor

Do not just say "exact same issue" vaguely: in most cases, an issue that looks the same or similar is from an unique condition or combination of conditions. You need to provide more relevant information: which version of AutoCAD (due to Acad2025 's big change to API requirements, knowing it is Acad2025, or pre-Acad2025 version is significant!), which development tool you are using (Visual Studio, or Visual Studio Code, since you claim "Project Explorer... is nowhere to be found");  what kind of AutoCAD .NET API code you are writing (if you want to manipulate AutoCAD's UI, such as Ribbon, as the OP did, and references AcWindows/AdWindows.dll, you would need to have "PresentationFramework/PresentationFrameworkCore/WindowBase/System.Xaml.dll" also referenced.

 

Please provide more details, so meaningful helps/suggestions could be offered.

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes