Late binding is not allowed when Option Strict
is on. If you need to perform late binding, the only options are either to use reflection or to shut off Option Strict
. The one saving grace, however, is that you don't have to shut off Option Strict
for the whole project. You can leave it on for the project and then just add the line Option Strict Off
at the top of any code files where you need to perform late binding. It's not a great solution, but it's better than affecting the whole project.
Also, since the Option Strict
placed at the top of a file applies just to that file, it doesn't even have to apply to an entire class. If you split your class into multiple Partial Class
files, then you could have Option Strict
set differently for each of those files. For instance, if you put most of your class in a file with Options Strict On
, and then just put one method in a Partial Class
in a separate file with Option Strict Off
, then only that one method would be compiled loosely. The rest of the class would be compiled using the strict rules.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…