Option Strict issue RRS feed

  • Question

  • User1935984934 posted

    Since last week's update of my Visual Studio all my projects are coming up with errors such as "Option Strict On requires that all method parameters have an 'As' clause" despite the project having the Option Strict "Off". It's happening on all my projects now. The only way around I found is to go in Compile change the "Option Strict" to On, save the project, and change the "Option Strict" to Off and save the project. This appears to solve the issue. 

    But anyway I am wondering if I should always be working with the "Option Strict" to On. What are your thoughts ? 

    Tuesday, December 12, 2017 2:46 PM

All replies

  • User753101303 posted


    Yes, it's likely best to be strict. For example here it seems you are working often with the "object" type when a more accurate type could perhaps be used. See https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/statements/option-strict-statement for a reference.

    You can enable/disable this on a file by file basis (by adding the statement at the top) which could allow to move progressively from Option Strict Off to Option Strict On and maybe keep that if really needed ("late binding" which is unlikely needed in most apps).

    Tuesday, December 12, 2017 3:00 PM
  • User991499041 posted

    Hi Corobori,

    When you use the Option Strict statement, the statement must appear before any other code. In Visual Basic .NET, you can typically convert any data type to any other data type implicitly. Data loss can occur when the value of one data type is converted to a data type with less precision or with a smaller capacity. However, you receive a run-time error message if data will be lost in such a conversion. Option Strict notifies you of these types of conversions at compile time so that you can avoid them.



    Wednesday, December 13, 2017 6:46 AM
  • User347430248 posted

    Hi corobori,

    its looks like new update have some changes caused this issue.

    so you need to modify in your project to meet with new update configuration.

    for a detailed information regarding Option Strict. you can refer link below.

    Option Strict Statement



    Wednesday, December 13, 2017 9:04 AM