如何添加对Microsoft.VisualBasic.dll的引用?

时间:2014-01-19 01:36:33

标签: c# inputbox

using Microsoft.VisualBasic;

Microsoft.VisualBasic.Interaction.InputBox("Favourite RPG?", "Game", "Cool!");

所以这样做基本上是问用户他们最喜欢的RPG。然后它显示默认值。我知道这是一个小例子,但我的程序不会运行,因为我收到了这个错误:

The type or namespace name 'Interaction' does not exist in the namespace 'Microsoft.VisualBasic' (are you missing an assembly reference?)

最初我发现了这个here

3 个答案:

答案 0 :(得分:20)

除了using Microsoft.VisualBasic;之外,还添加了引用。这是一个直观的答案:

enter image description here

然后

enter image description here

答案 1 :(得分:14)

您需要添加对Microsoft.VisualBasic.dll

的引用

您拥有的使用声明不是参考。它只是一个快捷方式,因此您每次要访问其中的成员时都不必键入完整的命名空间。

答案 2 :(得分:6)

右键点击References点击Solution Explorer中的Add Reference,然后搜索Microsoft.VisualBasic并将其添加到参考文献中。

有关详细信息,请参阅此文档:How to: Add or Remove References By Using the Add Reference Dialog Box