bypass error messages on my installed app
bypass error messages on my installed app
bypass error messages on my installed app
bypass error messages on my installed app
bypass error messages on my installed app
bypass error messages on my installed app bypass error messages on my installed app bypass error messages on my installed app bypass error messages on my installed app bypass error messages on my installed app bypass error messages on my installed app bypass error messages on my installed app bypass error messages on my installed app
bypass error messages on my installed app bypass error messages on my installed app
bypass error messages on my installed app
Go Back  Xtreme Visual Basic Talk > > > bypass error messages on my installed app


Reply
 
Thread Tools Display Modes
  #1  
Old 12-28-2010, 06:35 AM
pampam686 pampam686 is offline
Freshman
 
Join Date: Nov 2010
Posts: 33
Default bypass error messages on my installed app


I tried installing my app in another computer and found out that a lot of error messages keep popping up. What can i do to bypass these error messages? something about jit debugger or sumthing. Can i compile the app in such a way that these errors wont pop up?
Reply With Quote
  #2  
Old 12-28-2010, 12:58 PM
Qua's Avatar
Quabypass error messages on my installed app Qua is offline
Impetuous & volatile

* Expert *
 
Join Date: Apr 2005
Posts: 2,177
Default

Fix the errors in your application?

You will need to tell us the specific errors if you won't more specific help.
__________________
Reading is the foundation for all knowledge - Unknown.
Reply With Quote
  #3  
Old 12-28-2010, 02:23 PM
webbone's Avatar
webbone webbone is offline
Hydrogen Powered

Administrator
* Expert *
 
Join Date: Jul 2003
Location: Sacramento, CA
Posts: 6,090
Default

Also - did you built an installer for your app or just copy the exe to another computer? If you don't have a proper installer then any dependencies which are not already installed on the target machine will be throwing errors.
__________________
"With the appearance of the AddressOf operator, an entire industry has developed among authors illustrating how to do previously impossible tasks using Visual Basic. Another industry is rapidly developing among consultants helping users who have gotten into trouble attempting these tasks." -Dan Appleman
Reply With Quote
  #4  
Old 12-29-2010, 08:19 AM
pampam686 pampam686 is offline
Freshman
 
Join Date: Nov 2010
Posts: 33
Default

i just want the popups gone. it says 'collection was modified; enumeration operation may not execute'. the error allows me, however, to ignore it. What can i do so that the error message wont pop up?
Reply With Quote
  #5  
Old 12-29-2010, 08:27 AM
pampam686 pampam686 is offline
Freshman
 
Join Date: Nov 2010
Posts: 33
Default

it runs perfectly fine in debugger mode. Why do these errors only show up when i publish them?
Reply With Quote
  #6  
Old 12-29-2010, 08:30 AM
PlausiblyDamp's Avatar
PlausiblyDampbypass error messages on my installed app PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,058
Default

I would go with Qua's suggestion - fix the error rather than ignoring it.

The error basically means that somewhere you are doing a For Each loop and modifying the collection you are looping over - this isn't allowed so you are getting the error. Continuing at this point means you probably haven't processed every item in a particular For Each loop and therefore your application is now in an unknown state - continuing is probably not a good idea.
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
  #7  
Old 12-29-2010, 09:53 AM
AtmaWeapon's Avatar
AtmaWeaponbypass error messages on my installed app AtmaWeapon is offline
Fabulous Florist

Forum Leader
* Guru *
 
Join Date: Feb 2004
Location: Austin, TX
Posts: 9,500
Default

The only thing you could do to suppress the popup is to modify your code so it ignores the error, recompile, and deploy the modified application. If you're going to go to that much effort, it's worth understanding why the error happens (PlausiblyDamp explained this) and fix the problem that causes the error.

Otherwise it's like you've got a leaky pipe behind a wall and instead of fixing it you tear out the drywall, put a bucket under it, then replace the drywall. You do all of the effort required to fix it but instead do something else. It's silly.

It's never a good idea to completely ignore errors, especially if you don't understand what they mean and why they're caused.
__________________
.NET Resources
My FAQ threads | Tutor's Corner | Code Library
I would bet money 2/3 of .NET questions are already answered in one of these three places.
Reply With Quote
  #8  
Old 12-29-2010, 12:48 PM
pampam686 pampam686 is offline
Freshman
 
Join Date: Nov 2010
Posts: 33
Default

this is the cause of the error

for i=0 to collection.count-1

do stuff

next

i tried putting collection.count - 1 in a variable and it now looks like this

x=collection.count - 1
for i=0 to x

do stuff
next

...but the error wont go away
Reply With Quote
  #9  
Old 12-29-2010, 01:09 PM
AtmaWeapon's Avatar
AtmaWeaponbypass error messages on my installed app AtmaWeapon is offline
Fabulous Florist

Forum Leader
* Guru *
 
Join Date: Feb 2004
Location: Austin, TX
Posts: 9,500
Default

You haven't really given enough information.

For the exception to be thrown, you must be trying to enumerate over a collection *while* you modify it. This is almost always the result of trying to add or remove items to a list while you iterate over it in a For Each loop.

Nothing in the code you have posted is a For Each loop, nor does any of it perform an enumeration. How did you decide that this was the cause of the error? I don't think this is the right place.
__________________
.NET Resources
My FAQ threads | Tutor's Corner | Code Library
I would bet money 2/3 of .NET questions are already answered in one of these three places.
Reply With Quote
  #10  
Old 12-29-2010, 08:54 PM
pampam686 pampam686 is offline
Freshman
 
Join Date: Nov 2010
Posts: 33
Default

example of fixing a for each loop req'd
Reply With Quote
  #11  
Old 12-30-2010, 08:27 AM
PlausiblyDamp's Avatar
PlausiblyDampbypass error messages on my installed app PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,058
Default

Example of a broken For Each loop req'd.
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
  #12  
Old 12-30-2010, 10:19 AM
AtmaWeapon's Avatar
AtmaWeaponbypass error messages on my installed app AtmaWeapon is offline
Fabulous Florist

Forum Leader
* Guru *
 
Join Date: Feb 2004
Location: Austin, TX
Posts: 9,500
Default

I suppose it's possible you don't know where the error is in your code. Does the error message on the other computer display a stack trace, file name, or line number? That would be helpful and tell you exactly where it is. You might consider deploying a Debug build of the application along with its .pdb file; that might get you more detail.

If that's out of the question, then you're going to have to check every For Each loop in your program. The exception is thrown if you try to modify the collection while enumerating over it. One common scenario that causes this is attempting to remove some items from a collection. Let's set up a scenario.

Suppose you have a list of the numbers from 1 to 100:
Code:
Dim numbers As new List(Of Integer)()
For i As Integer = 1 To 100
    numbers.Add(i)
Next
Now suppose at some point you want to remove all multiples of 10 from the list. Here's a For Each loop that would fail:
Code:
For Each number As Integer In numbers
    If number Mod 10 = 0 Then
        numbers.Remove(number) ' Throws an exception
    End If
Next
This fails because you remove an item from the numbers collection while you're enumerating over it in a For Each loop. The reason it fails is because For Each is syntax sugar for using an enumerator; the real code that executes looks like this:
Code:
Dim e As IEnumerator(Of Integer) = numbers.GetEnumerator(Of Integer)()
While e.MoveNext()
    Dim number = e.Current
    If number Mod 10 = 0 Then
        numbers.Remove(number)
    End If
End While
An IEnumerator is a special object that knows how to visit each item in a collection. They can rely on special information about the collection that is invalidated if items are added or removed. Because of this, the contract for IEnumerator requires it to detect these changes and throw an exception if the collection changes while it is enumerating.

To fix the problem, you have a few choices.

You could opt to use a For loop, since it doesn't use an IEnumerator:
Code:
For i As Integer = numbers.Length - 1 To 0 Step -1
    Dim number As Integer = numbers(i)
...
(Note that if you're removing from an array while looping over it, it's easiest to start from the end and work backwards.)

You could create a secondary list of items to remove and remove them after enumerating:
Code:
Dim itemsToRemove As New List(Of Integer)()
For Each number As Integer in numbers
    If number Mod 10 = 0 Then
        itemsToRemove.Add(number)
    End If
Next

For Each multiple As Integer In itemsToRemove
    numbers.Remove(multiple)
Next
Note that the second For Each loop is valid because I'm not modifying the collection that is being enumerated.

You could even use LINQ to filter the collection:
Code:
Dim noMultiples = From n As Integer in numbers
                  Where n Mod 10 <> 0
                  Select n
There's probably a few other techniques I'm missing, but you get the idea.
__________________
.NET Resources
My FAQ threads | Tutor's Corner | Code Library
I would bet money 2/3 of .NET questions are already answered in one of these three places.
Reply With Quote
  #13  
Old 01-01-2011, 09:37 AM
pampam686 pampam686 is offline
Freshman
 
Join Date: Nov 2010
Posts: 33
Default

is this error exclusive to for each statements only?
Reply With Quote
  #14  
Old 01-01-2011, 10:22 AM
PlausiblyDamp's Avatar
PlausiblyDampbypass error messages on my installed app PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,058
Default

The error only relates to For Each loops. If you are doing a For Each loop then you are not allowed to modify the collection you are looping over - if you do this is the error you get.
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
  #15  
Old 01-01-2011, 12:55 PM
AtmaWeapon's Avatar
AtmaWeaponbypass error messages on my installed app AtmaWeapon is offline
Fabulous Florist

Forum Leader
* Guru *
 
Join Date: Feb 2004
Location: Austin, TX
Posts: 9,500
Default

Actually I answered that question already and pointed out you can also get it if using enumerators directly.

At this point, if you don't do one of two things I really don't think we can help you. Here's your choices:
  • Post your source code and let someone else try to reproduce the error.
  • Instrument your code so it can tell you where the error is.
Unless your code is less than 100 lines, it will be futile to inspect every For Each loop in the program. The situation I covered above is only one of the most common ways to cause the error; there's many other scenarios and some are very subtle if you aren't very experienced. We know nothing about your source, so we can't tell you what the problem is. Odds are you have one of the more subtle issues, and without revealing more information to us we can't tell you what the problem is.

I've attached an application that demonstrates what I'm talking about. It has a more subtle version of the enumeration modification error, though it's certainly not as subtle as some of the instances I've seen. When you click the "Bad Evens" button, RemoveIfOdd() is called inside of a For Each loop; this causes a modification of the collection, which throws an exception. I've made sure the application doesn't crash without telling me what happened by handling the Application.ThreadException event; this is raised as the application is terminating after an unhandled exception has been thrown. Note that you *will not* see this event work if you have a debugger attached; use "Start without debugging" when testing (the shortcut is usually CTRL+F5.) Note that the application keeps running in this case; I was too lazy to disable that. Keep in mind this is like running a red light in traffic: it might work out, but it probably won't.

When that event handler is called, it gets a reference to the exception that was thrown. My event handler displays a message box explaining that the application will shut down and the error log should be sent to technical support. Then, it writes the following information about the exception to a file:
  • The name of the exception
  • The message associated with the exception
  • The stack trace that led to the exception
Here's a sample error log from my release build:
Code:
Exception type: InvalidOperationException
Message:
Collection was modified; enumeration operation may not execute.

Stack trace:
   at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
   at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
   at System.Collections.Generic.List`1.Enumerator.MoveNext()
   at ErrorLogDemo.Form1.DisplayEvensBad() in e:\documents\visual studio 2010\Projects\Demos\ErrorLogDemo\ErrorLogDemo\Form1.vb:line 32
   at ErrorLogDemo.Form1.btnBadEvens_Click(Object sender, EventArgs e) in e:\documents\visual studio 2010\Projects\Demos\ErrorLogDemo\ErrorLogDemo\Form1.vb:line 51
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
So it was an InvalidOperationException that says we modified a collection while enumerating; that's not a surprise. Here's how to read the stack trace.

The first three lines are in the System namespace. That means it's Microsoft's code and we don't need to care about it. *Rarely*, you might discover they have a bug in their code, but it's always best to check your own code first. The fourth line indicates the problem hapened in Form1.DisplayEvensBad(), in Form1.vb, on line 32. Here's the line with context:
Code:
InitializeNumbers()
For Each number As Integer In _numbers
    RemoveIfOdd(number)
It might not be clear why that error is there, so descend into RemoveIfOdd():
Code:
Public Sub RemoveIfOdd(ByVal number As Integer)
    If number Mod 2 <> 0 Then
        _numbers.Remove(number)
Shazam! We're calling Remove() while iterating over _numbers.

Sometimes you may not be able to see the For Each loop around the line that threw the exception. When that happens, keep moving to the next line of the stack trace until you find it. Then try to figure out why that call chain is causing problems.

If you follow that example and you have the error log, you ought to be able to narrow down where the problem is happening. If you still need help, you'll have to post code and the error log so we can explain what's going on.
Attached Files
File Type: zip ErrorLogDemo.zip (11.8 KB, 0 views)
__________________
.NET Resources
My FAQ threads | Tutor's Corner | Code Library
I would bet money 2/3 of .NET questions are already answered in one of these three places.
Reply With Quote
  #16  
Old 01-03-2011, 03:34 AM
pampam686 pampam686 is offline
Freshman
 
Join Date: Nov 2010
Posts: 33
Default

ill try to post the code. the problem is the error doesn't show up in computers with vb installed. In only shows up if i install it in a pc without vb. and i dont have for each statements in my code so its very hard to find were exactly in 4 thousand lines
Reply With Quote
  #17  
Old 01-03-2011, 07:11 AM
AtmaWeapon's Avatar
AtmaWeaponbypass error messages on my installed app AtmaWeapon is offline
Fabulous Florist

Forum Leader
* Guru *
 
Join Date: Feb 2004
Location: Austin, TX
Posts: 9,500
Default

Define "without vb". That's a bit confusing to me, and it'd help me try to diagnose the problem.
__________________
.NET Resources
My FAQ threads | Tutor's Corner | Code Library
I would bet money 2/3 of .NET questions are already answered in one of these three places.
Reply With Quote
  #18  
Old 01-03-2011, 07:35 AM
pampam686 pampam686 is offline
Freshman
 
Join Date: Nov 2010
Posts: 33
Default

visual studio 2010
Reply With Quote
  #19  
Old 01-03-2011, 09:45 AM
PlausiblyDamp's Avatar
PlausiblyDampbypass error messages on my installed app PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,058
Default

Have you tried adding logging like Atma suggested? That at least should narow down where the error is occurring.
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
  #20  
Old 01-03-2011, 11:11 AM
AtmaWeapon's Avatar
AtmaWeaponbypass error messages on my installed app AtmaWeapon is offline
Fabulous Florist

Forum Leader
* Guru *
 
Join Date: Feb 2004
Location: Austin, TX
Posts: 9,500
Default

That's very, very odd. The presence of VS 2010 should not affect enumeration. I'm afraid if you don't want to try logging or show us your code, we can't help you.
__________________
.NET Resources
My FAQ threads | Tutor's Corner | Code Library
I would bet money 2/3 of .NET questions are already answered in one of these three places.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
bypass error messages on my installed app
bypass error messages on my installed app
bypass error messages on my installed app bypass error messages on my installed app
bypass error messages on my installed app
bypass error messages on my installed app
bypass error messages on my installed app bypass error messages on my installed app bypass error messages on my installed app bypass error messages on my installed app bypass error messages on my installed app bypass error messages on my installed app bypass error messages on my installed app
bypass error messages on my installed app
bypass error messages on my installed app
 
bypass error messages on my installed app
bypass error messages on my installed app
 
-->