tags:

views:

49

answers:

2

I am using LINQ expressions in my code

like this

var obj = Collection.Single(collection => (collection.ShortName.Equals("AAA")));

The problem is that this line works fine for me, no problems.

But when I upload the same executable to some remote machine with same 32 bit Windows XP. The code execution is just stopping at this line of source.

Can anyone help me.

A: 

Same .NET version installed? Also, does the application provide you with any errors? how about the Application Logs?

Meiscooldude
I am not using any try catch, no exception is thrown.And the strange is that I see Application Log just before this line.But the as the code is stopping to execute at this line, I do not see the Log written after this line.
HaMMeR
+3  A: 

You say that the thread is "stopping". If an exception is thrown in a thread it will terminate, is this what you mean by "stopping"? Single() will throw if either none or more than one element is present, and i think that this might be what is going on..

Are you certain that the collection contains exactly one matching element at all times?

Note: Read Eric Lipperts link. If possible, you could run it on a BackgroundWorker, and check the Error property of the eventargs when the thread exits.

http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundworker.aspx

hhravn
Yes I'm sure.I have written a test code for be sure.
HaMMeR
+1, Surely this is the cause.
David B
Ok I agree but where the exception goes?
HaMMeR
Eric Lippert says ... http://blogs.msdn.com/b/ericlippert/archive/2010/02/25/careful-with-that-axe-part-two-what-about-exceptions.aspx
David B