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

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

问题描述

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

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?

我想知道是否:

  • 如果在另一个项目中使用组件的较新版本,则拥有单独的组件副本不会导致问题吗?
  • 使用从packages文件夹中复制"然后删除,移动项目,这是否会导致工具箱出现问题?

推荐答案

基于我在评论中与汉斯·帕森特(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 Forms Designer">常规").

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天全站免登陆