0

I have a VB.Net WPF application with Option Explicit and Option Strict compile options set to OFF!

However, whenever I change build configuration from Release to Debug, or vice versa, my error list fills with hundreds of errors related to Option Explicit/Strict being 'ON'.

I have to go back into project properties/compile and change the options (which still display as 'OFF' mind you), back to OFF again... (i.e. I click the drop-down and re-click the OFF option).

Why? I have to do this so many times a day! It is not exclusive to just a single app, but with all the apps I write.

Do note:... this does not happen every single time, but it does happen at least 75% of the time.

FYI.. in-case this is of any relevance: My solution is on a Network Drive/Share, and I use Windows 7.

Joel Coehoorn
  • 380,066
  • 110
  • 546
  • 781
ProjEngr
  • 3
  • 1
  • 2
    Those options exist only for backwards compatibility with older code. Turning them off is **EXTREMELY POOR PRACTICE!** Let Visual Studio turn them on, and then go fix the compiler errors. Your code will be _faster_, and you'll have many fewer run-time bugs for your effort. – Joel Coehoorn Jan 31 '20 at 15:37
  • 1
    [This](https://stackoverflow.com/a/2890023/832052) is the only reason to turn `Option Strict Off` (and *it* is a legitimate reason). Other than that, you should probably have it On. I challenge anyone to offer a legitimate reason to leave `Option Explicit Off` – djv Jan 31 '20 at 16:11
  • Because I use implicit conversion. I dont have to type .ToString 1,000,000 times for example. I also use Late Binding in some instances. – ProjEngr Jan 31 '20 at 16:40
  • *"Because I use implicit conversion"*. Then don't. It's that simple. *"I dont have to type .ToString 1,000,000 times for example"*. Oh, poor you. Why is it such a challenge for you but not the rest of us? *"I also use Late Binding in some instances"*. If you don't need to use late-binding, don't. Don't use it because you're too lazy to do the right thing. In cases where you really do need to use it, turn `Option Strict On` at the project level and then `Off` at the file level in just those files that require it. Use partial classes keep the code in those files to the absolute minimum. – jmcilhinney Feb 01 '20 at 01:24
  • Option Explicit determines whether or not you have to declare a variable explicitly before using it. Option Strict determines whether or not implicit type conversions and late-binding are allowed. – Julie Xu-MSFT Feb 04 '20 at 06:37

0 Answers0