Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"microsoft.visualbasic.fileio does not exist" trying to use TextFieldParser

I've seen the above question asked many times on many sites, but I haven't seen an answer that fixed the problem.

The scenario is this... I am on .NET Framework 4.0, building a C# web application in VisualStudio 2012 Express with the Razor view engine.

I'm trying to use Microsoft.VisualBasic.FileIO.TextFieldParser in my code. From what I've read it is appropriate to do so by adding a project reference to Microsoft.VisualBasic, which I've done, and coding @using Microsoft.VisualBasic; in my view. However when I code...

Microsoft.VisualBasic.FileIO.TextFieldParser parser = new Microsoft.VisualBasic.FileIO.TextFieldParser(new StringReader(xxxxxxxx));

...in the view and rebuild the solution it returns errors: The type or namespace name 'FileIO' does not exist in the namespace 'Microsoft.VisualBasic' (are you missing an assembly reference?)

I know the reference is in the correct project because when I add and remove it I see it come and go from the references folder. I know the code I'm trying to reference exists because I can see it in Object Browser. I've even tried adding the reference using Object Browser instead of through the menus and although it gets added, the results are the same.

The solution it's in is a bit complicated so I tried just creating a test stand alone C# project and I get the same results. I also tried creating a test stand alone Visual Basic project, and sure enough, it works there as advertised. I'm by no means an expert on Visual Studio so I'm guessing that it's just something I'm missing in the configuration, but I'm at a loss to figure it out.

I've spent days on this, so any help anyone could offer would be greatly appreciated.

like image 323
user2203007 Avatar asked Mar 23 '13 19:03

user2203007


1 Answers

  1. Right-click on your project and select Add Reference...

  2. In the Reference Manager, expand Assemblies and select Framework. Then check the box for Microsoft.VisualBasic and click OK.

reference  picture

Credit goes to: https://stackoverflow.com/a/17146200/2530360

I just had the same problem and your question title was more verbose so I figured it should have the answer inside.

like image 163
Evan Morrison Avatar answered Oct 09 '22 14:10

Evan Morrison