Sunday, February 26, 2012

Error trying to write file

I don't have direct access to the SQL server. I have to write/read through a class I recieved from the IT department. The class also had an example in it but I can't get it to work correctly.

I get an error: Object reference not set to an instance of an object. Line 35


Dim clsWDD As New WebDevDB.WebDevDB
Dim intLeng As Int32
Dim intLock As Int32

Dim strAppl As String = "MyApplication"
Dim strData As String = "This is my text data!"

Dim strFile As String = "MyFile"

intLock = clsWDD.LockTextFile(strAppl, strFile) 'line 35
intLeng = clsWDD.WriteTextFile(strAppl, strFile, strData, WriteAction.Create)
intLock = clsWDD.UnlockTextFile(intLock)

What does the whole exception.tostring say?|||Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 33: Dim strFile As String = "MyFile"
Line 34:
Line 35: intLock = clsWDD.LockTextFile(strAppl, strFile)
Line 36: intLeng = clsWDD.WriteTextFile(strAppl, strFile, strData, WriteAction.Create)
Line 37: intLock = clsWDD.UnlockTextFile(intLock)

Source File: C:\Inetpub\wwwroot\TestSolution\WebForm1.aspx.vb Line: 35

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]
WebDevDB.WebDevDB.GetConnectionString()
WebDevDB.WebDevDB.LockTextFile(String ApplicationName, String FileName, Byte LockSeconds, Byte LockAttempts)
TestSolution.WebForm1.Page_Load(Object sender, EventArgs e) in C:\Inetpub\wwwroot\TestSolution\WebForm1.aspx.vb:35
System.Web.UI.Control.OnLoad(EventArgs e)
System.Web.UI.Control.LoadRecursive()
System.Web.UI.Page.ProcessRequestMain()

No comments:

Post a Comment