.NET Core Winform 打开窗体设计器报错


错误描述

使用.NET Core - winform 或 .NET5-Winform 开发过程中,打开winform窗体设计器,报错,提示:

Object reference not set to an instance of an object. Object reference not set to an instance of an object.    
Instances of this error (1)  
1.   Hide Call Stack  
at Microsoft.DotNet.DesignTools.Protocol.Endpoints.Sessions.InitializeRootComponentHandler.HandleRequest(InitializeRootComponentRequest request)
at Microsoft.DotNet.DesignTools.Protocol.Endpoints.RequestHandler`2.Microsoft.DotNet.DesignTools.Protocol.Endpoints.IRequestHandler.HandleRequest(Request request)  

 

错误信息如图所示: 

错误信息

 

解决办法

在 YESWin 开发框架中,出现这个错误的原因是 在窗体的构造函数中使用了 是否设计器的判断

具体代码在,YESWin.UI.Dev.LibForm.frmBaseData 中

 

YESWin.UI.Dev.LibForm.frmBaseData 构造函数

CheckDesingModel 类代码为

 public class CheckDesingModel
    {
        public static bool IsDesingMode()
        {
            bool returnFlag = false;
#if DEBUG      
            if (LicenseManager.UsageMode == LicenseUsageMode.Designtime)
            {
                returnFlag = true;
            }
            else if (System.Diagnostics.Process.GetCurrentProcess().ProcessName == "devenv")
            {
                returnFlag = true;
            }
#endif
            return returnFlag;
        }
    }

反编译 LicenseManager.UsageMode  (.NET 5和 .net Core)

反编译 UsageMode

发现,就是他抛出的异常,

 

在 .net framework 中 ( 可正常使用 ),代码如下,

反编译 UsageMode

 

解决办法:https://www.yesdotnet.com/archive/post/1627641098.html

 

 

版权声明:本文为YES开发框架网发布内容,转载请附上原文出处连接
YES开发框架
上一篇:文件加密技术研究
下一篇:.NETCore-winform 判断是否设计模式
评论列表

发表评论

评论内容
昵称:
关联文章

.NET Core Winform 打开设计
.net core winform继承后设计异常,看不到控件,并且页无法添加控件
.NETCore-winform 判断是否设计模式
权限
wifnorm处于设计模式校验 (.NET6)
状态
YESWin Winform开发框架 Form继承关系
GridView布局自定义
自定义权限操作按钮
.NET Core中使用编码GB2312‘GB2312‘ is not a supported encoding name 解决方案
winform MDI子窗口打开会闪动问题
AP.NET Core获得注入管理
C# winform无边框移动的四种方法
.net Core Swagger the same schemaid is already used for type swagger
.Net启动程序:It was not possible to find any compatible framework version
编辑中关联赋值操作
Winform设置组件可用状态
C#使用默认浏览器打开URL
VS .NET使用EF添加实体数据模型向导添加连接
WCF中常见的:The content type text

联系我们
联系电话:15090125178(微信同号)
电子邮箱:garson_zhang@163.com
站长微信二维码
微信二维码