问题
I want to use TextFieldParser
in my project. For that I need using Microsoft.VisualBasic.FileIO
.
However Visual Studio accepts using Microsoft.VisualBasic
without the FileIO
. but it does not recognize the TextFieldParser class.
On other forums, I read I should add Microsoft.VisualBasic reference. I am not able to work out how to do this, since the window of Reference Manager is completely blank, so I do not have any option to chose from.
Any help ?
回答1:
The "Add Reference" dialog that you have read about adds .NET Framework references, but you are targeting .NET Core. In .NET Core, either what you need is built in to the framework or you reference a Nuget package or class library to get the extra features you need. Adding a reference to another 'part' of the framework - like Microsoft.VisualBasic
- isn't a thing in .NET Core.
With regards to TextFieldParser
, the bad news is that it is not available in .NET Core 2.1, as is made clear in the documentation.
However, we can see from the documentation and the .NET API Catalog that the class is available in .NET Core 3.0. Therefore you have 2 choices:
Upgrade to .NET Core 3.0, or
Make do without this class and use a different approach
来源:https://stackoverflow.com/questions/58698869/microsoft-visualbasic-fileio-reference