none
Windows 10 updated to 10.0.16299 Build 16299, and now I can't use Public variables declared in modules in Vb.Net RRS feed

  • Question

  • I upgraded my laptop to Win 10 10.0.16299 Build 16299 today, and now I can't reference any public variables which I'm declaring in modules in VB.net with VS2015.

    Was working fine before the update, but now when I try to assign a value to the variable, it throws a "An unhandled exception of type 'System.TypeInitializationException' occurred in <nyapp.exe>"

    Additional information: The type initializer for '<Module Name>' threw an exception.

    Anyone have any ideas?  It's rendered my project unusable! :(

    Monday, February 12, 2018 2:40 PM

All replies

  • Hi

    Please post the code that shows this.


    Regards Les, Livingston, Scotland

    Monday, February 12, 2018 2:51 PM
  • Just declare a variable as Public in a module, then try and set it from a form or elsewhere.

    Was working fine before the Windows update, and now throws the same exception every time.
    • Edited by Slopey Monday, February 12, 2018 2:56 PM
    Monday, February 12, 2018 2:55 PM
  • Just declare a variable as Public in a module, then try and set it from a form or elsewhere.

    Was working fine before the Windows update, and now throws the same exception every time.


    Success Cor

    Monday, February 12, 2018 3:04 PM
  • Good for you, but that doesn't help my project which is now unusable.

    If I create a new project, I don't have the same issue - but what has changed between before/after the update which means my project is now useless?

    I've tried with VS2017 also, same result.

    Monday, February 12, 2018 3:23 PM
  • Good for you, but that doesn't help my project which is now unusable.

    If I create a new project, I don't have the same issue - but what has changed between before/after the update which means my project is now useless?

    I've tried with VS2017 also, same result.

    No without want to give information it "seems" you used something illegal which is currently solved. You're not the first one. But then it is only your problem.

    Success Cor


    Monday, February 12, 2018 3:44 PM
  • I've rolled back to 15063, and grabbed it again from source control, but the problem persists on this machine.

    There's not much point posting code - it affects any code in any module (of which I have dozens in this legacy project) - and affects variables, functions - everything.  Same error every time - "An unhandled exception of type 'System.TypeInitializationException' occurred in xxxxx"

    A simple public integer doesn't work, neither does something as simple as:

    Public Function returnFoo as integer
       return 5
    End Function

    And back on the calling form:

    Dim a as integer = returnFoo()

    Throws the same error.

    If I move the variable or function to the calling form itself, there's no error, but that would be a massive refactoring task which I don't want to (or have the time/budget to) undertake just because Win10 decided to update itself. 

    It affects this entire project since I updated this machine.  But only on this machine.  Thankfully I have another which is still working, which doesn't have the Fall Creators update - although who knows when I'll get it forced upon me - I've tried ShutUp10, so hopefully that'll keep it at bay.


    • Edited by Slopey Monday, February 12, 2018 3:57 PM
    Monday, February 12, 2018 3:55 PM
  • Good for you, but that doesn't help my project which is now unusable.

    If I create a new project, I don't have the same issue - but what has changed between before/after the update which means my project is now useless?

    I've tried with VS2017 also, same result.

    Hi

    OP: I have a car. It is not working. Please fix it.

    Answer: please give more details

    OP: There's not much point in providing more details because it happens every time I try to use the car!

    Answer: OK then - let us know when you fix it.


    Regards Les, Livingston, Scotland

    Monday, February 12, 2018 4:01 PM
  • See example above - that does not work (returnFoo) if I add it to a module in my project.

    I've posted the error - it's 100% repeatable.  There's nothing to be gained by posting any more code than the above, I'm not about to upload the entire project, and it happens with calls in any of the modules, of which there are 30+.

    I've given a specific example, but thanks for the help anyway.  The code is perfectly fine, I've got this application out to 5000 users so far, but as soon as I've updated to Win10 Fall Creators edition, the application no longer compiles throwing the same error every single time it accesses anything in a module.

    Obviously if it's not happening for you, that's great, but it's not going to help in my case.  I need someone who either knows why this is happening or has experienced the same and has been able to resolve it.

    Meantime, I'll go back to my other machine where the exact same code compiles without issue - it's on 15063, the only difference is the windows version and it only started happening after the update today.


    • Edited by Slopey Monday, February 12, 2018 4:19 PM
    Monday, February 12, 2018 4:15 PM
  • I tested it for you on Windows 10 16299 and you saw the result. 

    You wrote "I've rolled back to 15063, and grabbed it again from source control, but the problem persists on this machine."

    So it should really be something on that machine. Nothing to do for us, just do what Les told and bring that machine to the garage and tell that there are problems which others with the same OS don't have. 

    Telling like in this case it is not your fault, but it is done by Microsoft programmers is base slander. 


    Success Cor

    Monday, February 12, 2018 5:31 PM
  • I would suggest reporting this as a bug, this is done by clicking the link in the top right hand corner of the IDE with the little man icon.

    In the mean time here are a few things to try, first make sure you have a backup or it's in TFS.

    Close the solution, from windows explorer traverse to the project folder, delete the bin and obj folder. Fire up VS, try build/run. If that fails, move to the next thing to try.

    Create a class project in the solution, create (or copy the current one but let's not), recreate the code module. In your project remove the code module in question. Add a reference to this project to the new class project. Do a build, if that works now place a Import statement into where the variables need access, build/run, did this work? If so this is a "work-around", not a fix.

    If you would like I can move your question to the VS forum as this is more (as I see it) not a code issue but a IDE issue or a corrupt project file.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Monday, February 12, 2018 8:01 PM
    Moderator
  • It should require that function "returnWho" has a parameter.

    Public Function returnWho(ByVal myName As String) As Integer

    .....

    End Function


    Ashidacchi

    Monday, February 12, 2018 11:05 PM