469,631 Members | 1,134 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,631 developers. It's quick & easy.

ArgumentNullException

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
Attached Images
File Type: jpg er1.jpg (16.3 KB, 384 views)
File Type: jpg er2.jpg (17.2 KB, 298 views)
Aug 15 '09 #1
6 3103
tlhintoq
3,525 Expert 2GB
The tiny thumbnails are unreadable.

Please include the pertinent code causing the problem. (copy/paste)
Please be sure to use the [code] tags.
Aug 15 '09 #2
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?
Aug 15 '09 #3
tlhintoq
3,525 Expert 2GB
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.
Aug 15 '09 #4
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.

Expand|Select|Wrap|Line Numbers
  1. Public Class SH
  2.     Dim Card(52) As Integer
  3.  
  4.     Private Sub cmdExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdExit.Click
  5.         Debug(0)
  6.         End
  7.     End Sub
  8.     Private Sub Debug(ByRef index As Integer)
  9.         Dim output As String = "Bugger all"
  10.         Dim ProgramStart As Boolean = False
  11.         If index = 0 And ProgramStart = False Then
  12.             output = "Code 0 - Program initialised"
  13.             ProgramStart = True
  14.         End If
  15.         txtDebug.Text = output
  16.         DebugLog(output)
  17.     End Sub
  18.     Private Sub DebugLog(ByRef input As String)
  19.         txtDebug.Text = input
  20.  
  21.         Dim BaseDir As String
  22.         BaseDir = CurDir()
  23.         MsgBox(BaseDir)
  24.         Do Until RSet(BaseDir, 6) = "SH\SH\"
  25.             MsgBox(BaseDir)
  26.             BaseDir = ReturnDir(BaseDir, 1)
  27.         Loop
  28.         BaseDir = ReturnDir(CurDir, 1)
  29.         MsgBox(BaseDir)
  30.  
  31.         'FileOpen(1, basedir & "SH\Logs\Debug.txt", OpenMode.Append)
  32.         'Write(1, input)
  33.         'FileClose(1)
  34.     End Sub
  35.     Private Function ReturnDir(ByRef Directory As String, ByRef amount As Integer)
  36.         Dim counter As Integer = 0
  37.         Dim DirOut As String
  38.  
  39.         Do Until counter = amount
  40.             'If Directory.Last = "\" Then 
  41.             Directory = LSet(Directory, Directory.Length - 1)
  42.             Do Until Directory.Last = "\"
  43.                 Directory = LSet(Directory, Directory.Length - 1)
  44.             Loop
  45.             counter = counter + 1
  46.         Loop
  47.         DirOut = Directory
  48.         Return DirOut
  49.     End Function
  50.     Private Function ExtractRight(ByRef input As String, ByRef amount As Integer)
  51.         Dim counter1 As Integer = 1
  52.         Dim counter2 As Integer = 1
  53.         Dim counter3 As Integer = 0
  54.         Dim index As Integer
  55.         Dim output As String
  56.         Dim temp(256) As String
  57.         index = amount
  58.         output = "Bugger All"
  59.         Do Until counter1 = amount
  60.             temp(index) = input.Last
  61.             input = input.Length - 1
  62.             counter1 = counter1 + 1
  63.             index = index - 1
  64.         Loop
  65.         Do Until temp(counter2) = ""
  66.             output = output + temp(counter2)
  67.             counter2 = counter2 + 1
  68.         Loop
  69.         Do Until temp(counter3) = ""
  70.             temp(counter3) = ""
  71.             counter2 = counter2 + 1
  72.         Loop
  73.  
  74.         Return output
  75.     End Function
  76.     Private Sub testReturnDir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles testReturnDir.Click
  77.         MsgBox(ReturnDir(CurDir, 3))
  78.     End Sub
  79.     Private Sub testCurrentDir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles testCurrentDir.Click
  80.         MsgBox(CurDir)
  81.     End Sub
  82.     Private Sub testExtractRight_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles testExtractRight.Click
  83.         Dim input As String
  84.         Dim number As Integer
  85.         input = InputBox("Enter a string or leave blank of the current directory", "Enter String", "")
  86.         number = InputBox("Enter the lenght of the string to be extracted", "Enter Number", "1")
  87.  
  88.         If input = "" Or input = " " Then input = CurDir()
  89.  
  90.         MsgBox(ExtractRight(input, number))
  91.     End Sub
  92.  
  93. End Class
  94.  
Aug 15 '09 #5
tlhintoq
3,525 Expert 2GB
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?
Aug 15 '09 #6
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.
Aug 15 '09 #7

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by davesNotHere | last post: by
2 posts views Thread by Tom C | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.