.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.
5,205 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,764 questions
{count} votes

Accepted answer
  1. Minxin Yu 12,091 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.


1 additional answer

Sort by: Most helpful
  1. Ahmet Haluk UZUNER 20 Reputation points
    2024-05-27T16:10:38.4833333+00:00

    Somehow I got it worked.


    Sample code is at the link below. c++ .net8.0 and WindowsForms work together.

    https://github.com/halukuzuner/RevitAddinCppNet8.0

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.