ArgumentNullException | Newbie | | Join Date: Aug 2009
Posts: 4
| | |
Hi,
I've been writing a program in VB 2008. Ater testing a section and it all working fine, I added the next function and i got the {"Value cannot be null.\r\nParameter name: activationContext"} error. After not being able to fix it, I removed the function i just inserted with no effect and so I'm entirely stuck on what to do. I've attached a few images of my error screen shot, since copying it is impossible. I don't make use of anything that the error is referring to but the error message seems to point to "mscorlib.dll". I'm not sure what it does or where it gets used in my program but thats what seems to be the problem. I tried reinstalling VB to no effect.
Thanks for any help you can give
|  | Moderator | | Join Date: Mar 2008 Location: Arizona, USA
Posts: 1,743
| | | re: ArgumentNullException
The tiny thumbnails are unreadable.
Please include the pertinent code causing the problem. (copy/paste) Please be sure to use the [code] tags. | | Newbie | | Join Date: Aug 2009
Posts: 4
| | | re: ArgumentNullException
The problem is the error doesn't refer to any section of code. And I dont use any of the files that are causing the problem directly. You want to see all of the code?
|  | Moderator | | Join Date: Mar 2008 Location: Arizona, USA
Posts: 1,743
| | | re: ArgumentNullException
When you run it inside Visual Studio and you get the null ref exception the program breaks on the line of code where the exception happened, right?
Also, you know that the problem is that "activationContext" is null when you try to use it. So it stands to reason that you are not initializing this value.
| | Newbie | | Join Date: Aug 2009
Posts: 4
| | | re: ArgumentNullException
No, it doesn't break at a line. Normally, the line is highlighted in yellow but with this error, there is no yellow highlighting.
Also, the second comment would make sense to my code if i had, at any point, i tried to use activationContext but i haven't. I'm going to include my code for the program, just to see if you can find the program. Its in early stages so some functions might not be working. -
Public Class SH
-
Dim Card(52) As Integer
-
-
Private Sub cmdExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdExit.Click
-
Debug(0)
-
End
-
End Sub
-
Private Sub Debug(ByRef index As Integer)
-
Dim output As String = "Bugger all"
-
Dim ProgramStart As Boolean = False
-
If index = 0 And ProgramStart = False Then
-
output = "Code 0 - Program initialised"
-
ProgramStart = True
-
End If
-
txtDebug.Text = output
-
DebugLog(output)
-
End Sub
-
Private Sub DebugLog(ByRef input As String)
-
txtDebug.Text = input
-
-
Dim BaseDir As String
-
BaseDir = CurDir()
-
MsgBox(BaseDir)
-
Do Until RSet(BaseDir, 6) = "SH\SH\"
-
MsgBox(BaseDir)
-
BaseDir = ReturnDir(BaseDir, 1)
-
Loop
-
BaseDir = ReturnDir(CurDir, 1)
-
MsgBox(BaseDir)
-
-
'FileOpen(1, basedir & "SH\Logs\Debug.txt", OpenMode.Append)
-
'Write(1, input)
-
'FileClose(1)
-
End Sub
-
Private Function ReturnDir(ByRef Directory As String, ByRef amount As Integer)
-
Dim counter As Integer = 0
-
Dim DirOut As String
-
-
Do Until counter = amount
-
'If Directory.Last = "\" Then
-
Directory = LSet(Directory, Directory.Length - 1)
-
Do Until Directory.Last = "\"
-
Directory = LSet(Directory, Directory.Length - 1)
-
Loop
-
counter = counter + 1
-
Loop
-
DirOut = Directory
-
Return DirOut
-
End Function
-
Private Function ExtractRight(ByRef input As String, ByRef amount As Integer)
-
Dim counter1 As Integer = 1
-
Dim counter2 As Integer = 1
-
Dim counter3 As Integer = 0
-
Dim index As Integer
-
Dim output As String
-
Dim temp(256) As String
-
index = amount
-
output = "Bugger All"
-
Do Until counter1 = amount
-
temp(index) = input.Last
-
input = input.Length - 1
-
counter1 = counter1 + 1
-
index = index - 1
-
Loop
-
Do Until temp(counter2) = ""
-
output = output + temp(counter2)
-
counter2 = counter2 + 1
-
Loop
-
Do Until temp(counter3) = ""
-
temp(counter3) = ""
-
counter2 = counter2 + 1
-
Loop
-
-
Return output
-
End Function
-
Private Sub testReturnDir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles testReturnDir.Click
-
MsgBox(ReturnDir(CurDir, 3))
-
End Sub
-
Private Sub testCurrentDir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles testCurrentDir.Click
-
MsgBox(CurDir)
-
End Sub
-
Private Sub testExtractRight_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles testExtractRight.Click
-
Dim input As String
-
Dim number As Integer
-
input = InputBox("Enter a string or leave blank of the current directory", "Enter String", "")
-
number = InputBox("Enter the lenght of the string to be extracted", "Enter Number", "1")
-
-
If input = "" Or input = " " Then input = CurDir()
-
-
MsgBox(ExtractRight(input, number))
-
End Sub
-
-
End Class
-
|  | Moderator | | Join Date: Mar 2008 Location: Arizona, USA
Posts: 1,743
| | | re: ArgumentNullException
You said it ran before adding "a function" - fails with that function in - and returns to working when that function is removed.
So what part of this is the code for the function that causes the failure?
| | Newbie | | Join Date: Aug 2009
Posts: 4
| | | re: ArgumentNullException
No, it still was showing the error even when the function was removed. 2 functions were added after the last successful running version; ExtractRight and testExtractRight.
|  | Similar Visual Basic .NET bytes | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,223 network members.
|