将从 nuget 下载的组件添加到工具箱的推荐方法是什么? [英] What is the recommended way of adding components downloaded from nuget to toolbox?

查看:48
本文介绍了将从 nuget 下载的组件添加到工具箱的推荐方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 C# Windows 窗体项目,我在其中使用通过 nuget 获得的组件.现在我想知道在设计器中将此组件添加到工具箱的正确方法是什么.我应该在我的硬盘上制作一个单独的组件副本并从那里添加它,还是应该从项目的包文件夹中添加它,或者可能做一些完全不同的事情?

I have a C# Windows Forms project in which I use a component that I obtained through nuget. Now I was wondering what is the correct way of adding this component to the toolbox in the designer. Should I make a separate copy of the component on my hdd and add it from there or should I just add it from the project's packages folder or maybe do something different entirely?

我想知道是否:

  • 如果我在另一个项目中使用更新版本的组件,拥有一个单独的组件副本不会导致问题吗?
  • 使用包文件夹中的副本,然后删除、移动项目,这不会导致工具箱出现问题吗?

推荐答案

根据我在评论中与 Hans Passant 的对话(因为他没有将其作为答案发布):

Based on the conversation I had with Hans Passant in the comments (since he didn't post it as an answer):

通常,当您从 nuget 获取 Windows 窗体组件时,它会自动添加到设计器工具箱中.唯一不应该发生的情况是自动填充工具箱"设置为 false(工具 > 选项 > Windows 窗体设计器 > 常规).

Normally, when you get a windows forms component from nuget, it will automatically get added to the designers toolbox. The only time when it should not happen is when "Automatically Populate Toolbox" is set to false (Tools > Options > Windows Forms Designer > General).

在我的特殊情况下,这不会发生.它可能与在设计时找不到的重要依赖项"有关.但我并不完全同意这一点,因为我记得根本无法在设计器中使用这样的组件,但是让我提出这个问题的组件可以在那里很好地使用.然而,这可能是针对不同问题的材料(并且可能在不同的网站上).

In my particular case this does not happen. It might be related to "non-trivial dependencies that cannot be found at design time". But I'm not entirely sold on that, because I remember not being able to use such components in the designer at all, however the component that lead me to asking this question can be used there just fine. However this is likely material for a different question (and possibly on a different site).

这篇关于将从 nuget 下载的组件添加到工具箱的推荐方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆