Click here to Skip to main content
6,292,426 members and growing! (10,104 online)
Email Password   helpLost your password?
Languages » VB.NET » General     Advanced

Compile VB.NET code without Microsoft.VisualBasic.dll

By Rafael Mizrahi

Compile VB.NET code without the implicit reference to Microsoft.VisualBasic.dll
VB, Windows, .NET 1.1, .NET 2.0VS.NET2003, VS2005, Dev
Posted:26 Jul 2006
Updated:1 Aug 2006
Views:37,391
Bookmarked:14 times
Unedited contribution
Announcements
Loading...
 
Search    
Advanced Search
printPrint   Broken Article?Report       add Share
  Discuss Discuss   Recommend Article Email
10 votes for this article.
Popularity: 2.65 Rating: 2.65 out of 5
5 votes, 50.0%
1
1 vote, 10.0%
2
1 vote, 10.0%
3
2 votes, 20.0%
4
1 vote, 10.0%
5

Introduction

Let's say you are developing a program using Visual Basic.NET (2003 or 2005), and your wish to make sure that your code is using "pure" .NET and VB6 free.

Background

As you all know, Visual Basic.NET enables you to code using VB6 legacy syntax and keywords. For example CInt, Mid, InStr etc'.
The implementation of that compatibility layer is at the Microsoft.VisualBasic.dll library.

Behind the scene

When compiling your program, using either VisualStudio IDE or the vbc command line compiler, the Microsoft.VisualBasic.dll is added as a reference, and there is no direct approach of removing this reference.
The official (and quite not reasonable) solution to the problem is to add the -sdkpath command line option to the vbc (you cannot set this option at VB Visual Studio project)
Copy the .NET Platform assemblies that required by your project references, into a different directory, and build your program from command line, having the -sdkpath pointing to that directory.


(Aough..)

Behind the whole Theater

There is an undocumented vbc command line option -novbruntimeref, which you can use (at your own risk :), as an alternative to -sdkpath.
Adding -novbruntimeref excludes the implicit addition of Microsoft.VisualBasic.dll reference.
For example, compiling with -novbruntimeref option will fail if you will use Mid instead of Substring.

Now, Your compilation is VB6 free.
and don't get me wrong, VB was a great friend of mine since VB3, and some of my best friends are ...
well, you got the point.

Should I stop using Microsoft.VisualBasic namespace?

Yes and No.
No - Productivity.
If you wish to parse strings using VB6 Mid instead of Substring, it's your call.
After all, this layer was made for enabling you to import VB6 application into .NET, seamlessly, without code changes.

Yes - Compatibility.
For examples, VB6 collections are 0 based for read and -1 based for insertion.
Upgraded applications that use VB Collection through inconsistent implementation of Ilist may experience some nice bugs.

Both points are very important. The choice is all yours.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Rafael Mizrahi


Member
Rafael Mizrahi is a CTO at Feng-GUI

He is also a hacker contributor at the mono project, and a GarageGeeks member.

Rafael Mizrahi personal blog -
http://rafaelmizrahi.blogspot.com
Occupation: Chief Technology Officer
Company: Feng-GUI
Location: United States United States

Other popular VB.NET articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 20 of 20 (Total in Forum: 20) (Refresh)FirstPrevNext
NewsMicrosoft now released this feature in VB9 ORCAS PinmemberRafael Mizrahi1:37 12 Jun '07  
Generalwhat happen when I use DirListBox in c# PinmemberDo.It2:00 11 Apr '07  
GeneralYou people need to calm down [modified] PinmemberLuharVB8:01 25 Jan '07  
AnswerRe: You people need to calm down PinmemberRafael Mizrahi8:26 25 Jan '07  
Newsnovbruntimeref compiler option PinmemberRafael Mizrahi1:10 4 Aug '06  
GeneralWrong reason Pinmemberjwelch25:42 3 Aug '06  
QuestionWhy? Pinmemberjwelch25:10 1 Aug '06  
GeneralRe: Why? PinmemberAnthony Missico10:01 3 Aug '06  
AnswerRe: Why? [modified] PinmemberMichel Posseth23:51 1 Aug '06  
General[Message Deleted] PinmemberRafael Mizrahi0:07 2 Aug '06  
GeneralRe: Why? PinmemberMichel Posseth0:36 2 Aug '06  
GeneralRe: Why? [modified] PinmemberAnthony Missico10:06 3 Aug '06  
GeneralPrevent the reference being added to new projects ... PinmemberDuncan Edwards Jones7:47 28 Jul '06  
GeneralRe: Prevent the reference being added to new projects ... Pinmemberdfinger2:38 1 Aug '06  
GeneralRe: Prevent the reference being added to new projects ... PinmemberDaniel Finger3:28 1 Aug '06  
GeneralRe: Prevent the reference being added to new projects ... Pinmemberlpellerin4:37 6 Sep '06  
GeneralRe: Prevent the reference being added to new projects ... PinmemberRafael Mizrahi22:04 6 Sep '06  
QuestionRe: Prevent the reference being added to new projects ... Pinmembernitkapy2k@gmail.com22:42 12 Mar '08  
GeneralRe: Prevent the reference being added to new projects ... PinmemberRafael Mizrahi23:01 12 Mar '08  
GeneralRe: Prevent the reference being added to new projects ... Pinmembernitkapy2k@gmail.com5:29 13 Mar '08  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 1 Aug 2006
Editor:
Copyright 2006 by Rafael Mizrahi
Everything else Copyright © CodeProject, 1999-2009
Web13 | Advertise on the Code Project