C# microsoft.visualbasic.fileio 不存在
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12830017/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
microsoft.visualbasic.fileio does not exist
提问by Rob Cole
I am on .NET Framework 4.0, building a C# web application in VisualStudio 2012. I have Microsoft.VisualBasic added as a reference to the project. I am having trouble with the following line of code:
我使用 .NET Framework 4.0,在 VisualStudio 2012 中构建 C# Web 应用程序。我添加了 Microsoft.VisualBasic 作为对项目的引用。我在使用以下代码行时遇到问题:
using Microsoft.VisualBasic.FileIO;
使用 Microsoft.VisualBasic.FileIO;
Building the solution returns the error: The type or namespace name 'FileIO' does not exist in the namespace 'Microsoft.VisualBasic' (are you missing an assembly reference?)
构建解决方案返回错误:命名空间“Microsoft.VisualBasic”中不存在类型或命名空间名称“FileIO”(您是否缺少程序集引用?)
I have removed and re-added the reference to the assembly Microsoft.VisualBasic, but still get the error. Microsoft.VisualBasic is in the GAC, as well as Microsoft.VisualBasic.Compatibility, Microsoft.VisualBasic.Compatibility, Microsoft.VisualBasic.PowerPacks.Vs, and Microsoft.VisualBasic.Vsa.
我已经删除并重新添加了对程序集 Microsoft.VisualBasic 的引用,但仍然出现错误。Microsoft.VisualBasic 以及 Microsoft.VisualBasic.Compatibility、Microsoft.VisualBasic.Compatibility、Microsoft.VisualBasic.PowerPacks.Vs 和 Microsoft.VisualBasic.Vsa 位于 GAC 中。
Please let me know how to get VS2012 to recognize the FileIO namespace.
请让我知道如何让 VS2012 识别 FileIO 命名空间。
采纳答案by Chris Schiffhauer
Right-click on your project and select Add Reference...
In the Reference Manager, expand Assemblies and select Framework. Then check the box for Microsoft.VisualBasic and click OK.
右键单击您的项目并选择添加引用...
在参考管理器中,展开程序集并选择框架。然后选中 Microsoft.VisualBasic 框并单击确定。
回答by Azam Aminuddin
I had similar issue, fixed by change TargetFramework (in .csproj) from netstandard2.0to netcoreapp3.0.
我有类似的问题,通过将 TargetFramework(在 .csproj 中)从netstandard2.0更改为netcoreapp3.0来解决。
回答by llessurt
Application references are not available to uncompiled files in your application (aspx, ashx). There are two solutions to this issue as follows:
应用程序引用不可用于应用程序中的未编译文件(aspx、ashx)。这个问题有以下两种解决方案:
1) Move your code to a compiled part of the application (cs/vb file)
1) 将您的代码移动到应用程序的编译部分(cs/vb 文件)
or
或者
2) Add the reference to the web config
2) 添加对 web 配置的引用
My reference was in an ashx file. I simply copied the code from the ashx file to the clipboard, deleted the file from the project, added a new Generic Handler (right click in Visual Studio > Add > Generic Handler), entered the same name as before, and pasted the code from the clipboard into the cs file editor that Visual Studio opened. I now have a cs file that will compile with the project and use the project reference. The file name is the same, so there is no need to update anything else -- just rebuild and deploy.
我的参考在 ashx 文件中。我只是将 ashx 文件中的代码复制到剪贴板,从项目中删除该文件,添加一个新的 Generic Handler(在 Visual Studio > Add > Generic Handler 中右键单击),输入与之前相同的名称,然后粘贴来自将剪贴板放入 Visual Studio 打开的 cs 文件编辑器。我现在有一个将与项目一起编译并使用项目引用的 cs 文件。文件名相同,因此无需更新任何其他内容——只需重建和部署即可。

