Collection was modified; enumeration operation may not execute Error

Getting this error in my App…

http://stackoverflow.com/questions/604831/collection-was-modified-enumeration-operation-may-not-execute 

This link suggests that i change:

foreach(Subscriber s in subscribers)

To

foreach(Subscriber s in subscribers.ToList())

.toList() will return a new list. But note that this is a list of subscribers, which is a ref type and so the new list ref will also point to the old objects only…

But this error will not come as now when the old list of subscribers has an object added or removed, the subscribers.ToList() list will not change and hence this exception will not be thrown….

Clearly this is not something that I want, as I need to make sure the list being iterated is not being modified at the same time..this is a design issue with my app….so thought .toList will avoid this error, it will still not solve the problem at all….

how to read stack trace

When a function is called, a copy of it is put on the Stack to execute. When a
function exits, it is pulled from the Stack. If it calls other functions,
these are stacked on top of it, and each one is pulled off the Stack when it
exits.
The Stack Trace shows the “topmost” (latest) functions called. It helps
identify the chain of execution that led up to the current situation
(usually an exception). It identifies each function on the Stack in the
order (reversed) in which they appear, with the last one executed at the
top.

 

Card1 (the first card on the discard pile) calls 2
which calls 3. You cannot finish working with card 1 until you have played
card 2 and card 3 (and so on). This would be like function Card1() calling
function Card2(), which calls function Card3. If you break inside the
Card3() function, you have a stack like so:

Card3
Card2
Card1

Now, let’s say Card3 returns an answer that Card2 processes, and Card2 has
an error. The stack now looks like so:

Card2
Card1

In the stack trace, you will see Card2 with a line number and Card1 with a
line number, if you have the IDE set to break on all errors, or if you let
the error remain when deployed and do not have a Try … Catch to handle the
error.

Sometimes what you do in your code does not throw an exception until it hits
the .NET Framework components. In these cases, you often have to look down
the stack until you hit your own functions to determine what actually caused
the error.

IIS Connection Limit

Issue: After a certain no. of open http connections to the service, the clients are not able to connect and the app pool recycles. 

Interesting IIS Properties to look at:

  1.  Max Concurrent Connections (maxConnections)
  2. Connection Time-Out (connectionTimeout)
  3. maxBandwidth

 Use this link as reference: http://www.iis.net/configreference/system.applicationhost/sites/site/limits

Also, Dynamic IP Restrictions Module is used to limit connections from the same machine. The limit can be changed in the module’s details page in IIS Manager.

BIND the indexing by Splunk of your CUSTOM Logs

In order to BIND the indexing by Splunk of your CUSTOM Logs, a new “stanza” must be added by editing the props.conf file.

 

Once a non-system log is associated it with a sourcetype and is “recognized” in this file, Splunk will index and display.

 

~~

 

Edit the props.conf file over at   $SPLUNK_HOME/etc/system/local/ or in your own custom application directory in $SPLUNK_HOME/etc/apps/.

 

The admin must only modify at one of these two locations.

 

Optionally, you can add this stanza from the Advanced Mode tab in data preview from the UI.

 

Functional Programming SessionOverIdhttp://www.youtube.com/watch?v=b0EF0VTs9DcFuState

Notes

  1. Nullable Type
    1. Lync brought in the need for Nullable Types as it uses DB Connection..hence this type was introduced as int etc, cannot be null
    2. Now to store sting with null, u need to store the length of the string as u cannot say string s = “null”;
  2. Overload + For Nullable Type
    1. Nullable Int (NI) : NI Operator+ (NI, NI) , NI Operator+ (NI, int) and so on…like extension methods
  3. Functional Rationals
    1. Generics: Same behavior, Different Type
    2. Pass Fn to Fn: Change behavior of Fn
    3. Return Fn from Fn: To Compose Fns eg: x->y and y->z can become x->z
  4. Identity Property
  5. Impure functions
    1. Functions that go beyond the lexical scope of function. Eg. Function using console.writeline
    2. Functions that don’t give same o/p for the same i/p Eg. Random Fn
    3. I/O is not stateless, hence Fns doing I/O are not pure
  6. Memoisation in functional programming
    1. State Management using Closures for pure functional languages like Haskell, as it’s stateless and state management needs state maintainance. This goes against functional principals, but is a real world requirement
    2. This shows pure functional prog has it’s limitations when applied to real world problems

To Do:

  1. See inplementation of Nullable Class. Note how its generic, so that any type T can be Nullable
  2. Write extension method on T
  3. Monad videos 
    1. http://www.youtube.com/watch?v=b0EF0VTs9Dc
    2. http://www.youtube.com/watch?v=dkZFtimgAcM
    3. http://www.youtube.com/watch?v=ww2Z1URx-G0
  4. 101 LINQ Samples: http://code.msdn.microsoft.com/101-LINQ-Samples-3fb9811b 

 

static HttpClient client = new HttpClient(new HttpClientHandler() { UseDefaultCredentials = true });St HttpResponseMessage response = await client.GetAsync(“http://ddwas534.msad.ms.com:11910/unsmsglogger/api/Logging/ServerStatsdsfrefI tr”

 

Set the credentials:

  1. static HttpClient client = new HttpClient(new HttpClientHandler()
           {
               UseDefaultCredentials = true
           });
  1. Set the SPN
    1. ref: https://wcf.codeplex.com/discussions/263546 
      1. I tried this using both WebRequest and HTTP Client and set the SPN but it didn’t work:
        AuthenticationManager.CustomTargetNameDictionary["http://a.b.c.com"] = "HTTP/a.b.c.com@b.c.COM";
  2. Get the response
    1. HttpResponseMessage response = await client.GetAsync("http://ddwas534.msad.ms.com:11910/unsmsglogger/api/Logging/ServerStats");
  3. Read it
    1. dynamic res = response.Content.ReadAsStringAsync();
  4. sd

 

Ref:

  1. what is SPN: http://msdn.microsoft.com/en-us/library/ms677949(v=vs.85).aspx, http://technet.microsoft.com/en-us/library/cc961723.aspx 
  2. http://msdn.microsoft.com/en-us/library/ms995329.aspx