.net8 windows form design view problem.

Ahmet Haluk UZUNER 20 Reputation points
2024-05-04T19:10:34.6166667+00:00

I am developing Revit addin in Vidual Studio in c++/cli as class library.

Before moving to .net platform everyhing was working fine. But in .net Windows form design views doesnt work. Though when I add form element by code. It compiles and works.

The error is:

The designer could not be shown for this file because none of the classes within it can be designed. The designer inspected the following classes in the file: ModelessForm --- The base class 'System.Windows.Forms.Form' could not be loaded. Ensure the assembly has been referenced and that all projects have been built.

Regarding to Windows forms I aded lines below to .vcxproj file

<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>

<TargetFramework>net8.0-windows</TargetFramework>

<ItemGroup>

<FrameworkReference Include="Microsoft.WindowsDesktop.App" />

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

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

Instances of this error (1)

  1. Hide Call Stack

at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.EnsureDocument(IDesignerSerializationManager manager)

at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager manager)

at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager)

at System.ComponentModel.Design.Serialization.BasicDesignerLoader.BeginLoad(IDesignerLoaderHost host)

This is form design view window.2024-05-04 21 56 39

2024-05-04 21 58 12 The Visual Studio project file is at link below.

https://sendgb.com/U9ePtjK7T5x

Does snybody have any idea how i can resolve that problem?

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,698 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,562 questions
{count} votes

Accepted answer
  1. Minxin Yu 10,361 Reputation points Microsoft Vendor
    2024-05-09T02:47:06.7166667+00:00

    Hi,

    In Configuration Manager: add new configuration. Such as named design , used to design Winform but not compile it.

    User's image Then
    User's image

    Click OK. Then CTRL+S to save the project file.

    Add the condition to vcxproj file reference include and framework reference

    enter image description here

    itemgroup.txt

    In Design:

    User's image

    Since out of process does not support C++CLI. You still need to add controls' code manually, but the controls can be displayed in the designer.

    Before building the project, switch to Debug or Release.

    Best regards,

    Minxin Yu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful