简体   繁体   English

为什么我不能在 VB.NET 中使用 Shell 方法?

[英]Why I can't use Shell method in VB.NET?

I see everyone is using the Shell command without any problem, but it doesn't work for me, it says it's not declared like it doesn't exist.我看到每个人都在使用 Shell 命令没有任何问题,但它对我不起作用,它说它没有声明它不存在。 I'm working in Visual Studio using VB.NET.我正在使用 VB.NET 在 Visual Studio 中工作。

图 1

图 2

Interaction.Shell is in the Microsoft.VisualBasic namespace, which should automatically be imported for Visual Basic projects. Interaction.Shell位于Microsoft.VisualBasic命名空间中,为 Visual Basic 项目自动导入该命名空间。

If it isn't in yours, you can fix that in the project properties (Tab "References") or manually add Imports Microsoft.VisualBasic at the top of the code file.如果它不在你的,你可以在项目属性(选项卡“参考”)中修复它,或者在代码文件的顶部手动添加Imports Microsoft.VisualBasic

Another possible reason is that Interaction.Shell is not included in .NET Core versions prior to 5. In that case, use a "classic" .NET Framework project or .NET 5 or higher instead. Another possible reason is that Interaction.Shell is not included in .NET Core versions prior to 5. In that case, use a "classic" .NET Framework project or .NET 5 or higher instead. (Credit to Hans Passant in the comments.) (感谢评论中的汉斯·帕桑特。)

I have recreated the app, without change anything and now it works... In any case, thank you to everybody for the support.我已经重新创建了该应用程序,没有进行任何更改,现在它可以工作了……无论如何,感谢大家的支持。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM