|
-
Dec 14th, 2005, 12:34 PM
#1
Thread Starter
Fanatic Member
Avoiding Late binding in VB.net
I'm currently still learning VB 6.0 but red a thread about Option Strict On/Off
As I'm currently writing a application to manipulate acad drawings through the acad object library. I'm seriously late binding to avoid version problems.
(i.a.w. it is suppose to run fine with every Autocad version release 14 upward)
As I was reading a disscussion in VB.net where late binding was qualified as bad coding....
I was wondering how do you overcome this version problem in .net without late binding?
 why can't programmers keep and 31 Oct and 25 dec apart. Why Rating is Useful
for every question you ask provide an answer on another thread.
-
Dec 14th, 2005, 01:35 PM
#2
Frenzied Member
Re: Avoiding Late binding in VB.net
This is a tough area. Quoting snippets from "Professional Excel Development" by Bullen, Bovey, & Green (Addison Wesley) (a very good book incidentally!):
To use early binding with objects that are outside the Excel object model you must set a reference to the appropriate object library.
You should use early bound object variables wherever possible. Early bound object variables provide the following advantages over late bound variables:
Improved performance ...
Strict type checking ...
IntelliSense availability ...
As you might expect, in some cases you need to use late binding rather than early binding. The two most common reasons for using late binding rather than early ginding are as follows:
When a newer version of an application's object library has broken compatibility with an earlier version. This is an all too common situation.
When you want to use an application that you cannot be sure will exist on the user's computer and that you cannot install yourself.
Defensive Coding: Write your application in the Earliest Version of Excel that you expect it to Run in.
As I said, these are just snippets ... this immediate section is about 4 pages long. You might try to find a copy to review.
Good Luck and Good Programming!
Blessings in abundance,
All the Best,
& ENJOY!
Art . . . . Carlisle, PA . . USA
-
Dec 15th, 2005, 01:08 AM
#3
Re: Avoiding Late binding in VB.net
Late-binding is one of those things that is not inherently bad but it has been misused, just like the GoTo statement. They both exist for a reason and, used properly, they help the developer achieve certain things that may be much more complex done a different way. The problem is that many developers are just lazy and don't care that there are better ways to do things because it would take a bit more effort on their part to use these methods, and many more aren't even aware that these better ways exist because they have learned from the first group. Visual Basic was developed as a way for the masses to be able to do something that only the elite could before. It is certainly easier to program with Option Strict Off but it is also much easier to make errors. Most times there will not be an issue but even one run time exception that could have easily been avoided is too many. Turning Option Strict On and avoiding late-binding is, or should be, the rule. It seems like you've encountered one of the exceptions to that rule; one of the reasons that late-binding exists in the first place.
-
Dec 15th, 2005, 02:13 AM
#4
Thread Starter
Fanatic Member
Re: Avoiding Late binding in VB.net
Thanks for your remarks,
As I'm used to bind to the most specific as much as possible and using option explicit as well. moving to .net won't be much diffrent on this issue.
 why can't programmers keep and 31 Oct and 25 dec apart. Why Rating is Useful
for every question you ask provide an answer on another thread.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|