Null Exception on String.Empty???

This is a first. I've never received this error on the String.Empty object. See screenshot
Screenshot.jpg
BlakeMcKennaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

UnifiedISCommented:
When does the exception occur?
It didn't have a problem with line 8 for strSerialNO?
BlakeMcKennaAuthor Commented:
It occurs as soon as I execute the app. However, I commented out that line of code and then hit threw the exception on line 8. I commented that line out and it threw the same exception on line 6.
Fernando SotoRetiredCommented:
Can you click on the "Copy exception detail to the clipboard" in the exception pop up window and then paste here.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Exploring SQL Server 2016: Fundamentals

Learn the fundamentals of Microsoft SQL Server, a relational database management system that stores and retrieves data when requested by other software applications.

David Johnson, CD, MVPOwnerCommented:
Private variablename as String  in Visual Studio 2013 returns an error
Dim variablename as String is suggested replacement

You might want to change it from
Private variablename as String = String.Empty
to
Private variablename as String = ""

or to fix the error
Dim Variablename as String = String.Empty
BlakeMcKennaAuthor Commented:
System.NullReferenceException was unhandled by user code
  HResult=-2147467261
  Message=Object reference not set to an instance of an object.
  Source=SENSITCalibration
  StackTrace:
       at SENSITCalibration.frmMain.InitializeComponent() in C:\Users\blake\Source\Workspaces\SENSIT Calibration\Main\Source\SENSIT Calibration\frmMain.Designer.vb:line 412
       at SENSITCalibration.frmMain..ctor() in C:\Users\blake\Source\Workspaces\SENSIT Calibration\Main\Source\SENSIT Calibration\frmMain.vb:line 11
  InnerException:
BlakeMcKennaAuthor Commented:
Here is a new screenshot that should have went along with last post by Fernando.
BlakeMcKennaAuthor Commented:
I also tried assigning "" to the initialization of the variable and got the same results...
David Johnson, CD, MVPOwnerCommented:
Did you change the Private to Dim ?
Fernando SotoRetiredCommented:
Also can you try the following.

1. Build -> Clean Solution. then rebuild and compile and try again.

If that did not work then

2. Close down Visual Studio and then reopen it and see if that correct the issue
Fernando SotoRetiredCommented:
@ David I have Visual Studio 2013 and It works as expected did not get exception.
BlakeMcKennaAuthor Commented:
I figured it out. It had to do with a variable: "timeOut". Not sure what the correlation is but I just moved my whole project and sub-projects into TFS. This caused some issues, why I'm not sure other than mapping. That's all I can think of.

The "timeOut" was a custom control used to track application idleness. It referenced a custom DLL and not a MS DLL. I'm going to post a new thread on how to create an application timeout.
BlakeMcKennaAuthor Commented:
Fernando,

I've tried all of your suggestions, even before I posted this issue and none of them helped. My previous post explains what was causing the problem but I don't know why it would cause the issue.
Fernando SotoRetiredCommented:
@BlakeMcKenna, just glad you got through the issue.  ;=)
David Johnson, CD, MVPOwnerCommented:
Error1'Private' is not valid on a local variable declaration.d:\documents\visual studio 2013\Projects\ConsoleApplication47\ConsoleApplication47\Module1.vb79ConsoleApplication47
BlakeMcKennaAuthor Commented:
Thanks Fernando...
BlakeMcKennaAuthor Commented:
Fernando,

I will say that your idea of "Copy exception detail to the clipboard" helped. It pointed to a line of code in the Forms Designer.vb code.

Thank You!
Fernando SotoRetiredCommented:
@David, you are getting the exception because Private variables are NOT allowed within a method only at class level as shown below. The one at class level is OK the one in a method is an error.

Code Listing
Fernando SotoRetiredCommented:
Not a problem BlakeMcKenna, always glad to help.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.