External Config Files (configSource) Dropped From Memory (MVC, C#, ASP.net) - c#

We are having an intermittent issue where config files, or more specifically subset of values within that data are getting lost into the ether. Truth be told I am at a loss as to how to approach it because I am unsure if it's a code, config, machine or IIS issue. To give you an idea of what's happening....
What we are doing
We have a config file that contains "price" drop down values :
<searchForm>
<priceLowerBoundValues>
<priceLowerBoundValue>2500</priceLowerBoundValue>
<priceLowerBoundValue>5000</priceLowerBoundValue>
....
</priceLowerBoundValues>
....
</searchForm>
These are contained within a file named searchForm.config. In web.config they are referenced as an external file like so.
<searchForm configSource="Config\searchForm.config" />
We have a custom configuration handler that inherits from IConfigurationSectionHandler. The gist of being this code here that gets the values.
var priceLowerBoundValueXPath = "/searchForm/priceLowerBoundValues/priceLowerBoundValue/text()";
searchFormLookups.PriceLowerBoundValues = section.SelectNodes(priceLowerBoundValueXPath).Cast<XmlNode>().Select(x => int.Parse(x.Value));
Then the ONLY place we reference it, is when building a select list for the viewmodel. It looks a little like this :
SearchFormConfiguration.PriceLowerBoundValues.ToSelectList((parameters.PriceLowerBound != null) ? parameters.PriceLowerBound.Value : 0)
There is no modifications done to the list ever, and using resharper "Find Usages" only brings up this single call. No other point in the program touches these values.
The Issue
What will happen intermittently is that the drop down boxes on our webpage suddenly have only one value (e.g. 2500 in the price box). Do note it is not completely empty, but usually most values are gone. We have had similar issues of external configs dropping (almost completely) and it causes null reference errors across the place. e.g. it's still looking for a config that's supposed to be there, but it has been wiped from the face of the earth.
Stopping the website, stopping the app pool, and then bringing everything up again fixes the issue. Which made me initially think it could be something with memory usage, and external configurations being the first thing it drops, but I'm really unsure at this point.
Another thing to note. We have an app pool restart in the early hours of the morning everyday.
Any help with this is much appreciated, even if it's just a nudge into the right direction. As I say, I can't find any info on where to start, be it IIS settings or code. :)

I have an idea of what might me wrong.
Line
x.PriceLowerBoundValues = section.SelectNodes(...).Cast<XmlNode>().Select(...);
Basically a lazy enumerator over the XmlNodeList.
From MSDN docs:
The XmlNodeList object returned by this method will be valid while the
underlying document remains unchanged. If the underlying document
changes, unexpected results may be returned (no exception will be
thrown).
Is there any chance that the underlying document changes?
Will there still be problem if you put values to, say, array? Like ..Select().ToArray();

Related

ExchangeService FindAppointments returns 'This property was requested, but it wasn't returned by the server' error

I'm using Microsoft.Exchange.WebServices.dll version 15.0.847.30 to interact with functions in Outlook. I am using this call:
EWSData = CurrentEmail.FindAppointments(WellKnownFolderName.Calendar, new CalendarView(t, t.AddDays(1)));
(where t is today +/- however many days the user has clicked from today) which passes the WellKnownFolderName and the CalendarView directly through to a call to ExchangeService.FindAppointments.
I have a couple clients who each have a single user who is getting the 'This property was requested, but it wasn't returned by the server' error on some days and not others. Sometimes it pulls in the first few appointments for a day and leaves off the rest. My email, creating appointments, and add/remove contacts functions are all working for them.
I've traced through the ews-managed-api code from github and found the error is thrown when a property is requested but is null. I'm assuming the code on github is much newer than the version I'm using, but if the error is still caused by that code is in my version, I do not know how to find out what properties are causing the issue.
Since I'm not requesting anything specific but using the generic call with the folder name and a date, I'm quite confused as to what properties would be null and why.
What can I do, without re-compiling my application, to track down the problem properties?
Just a thought: do you have a way of tracing the XML flow between your app and Exchange, e.g. Fiddler? On the error response, you may be able to plow into the XML and see the name of the property causing the issue. Not 100% sure on this, but about the only tactic you can try without rebuilding you app with more diagnostic code in there.

No Outgoing, Key or Incoming references tab in DotMemory

I'm completely new to DotMemory. The only memory profiler I've used in the past was Valgrind, so I'm probably overlooking something trivial.
I'm working on trying to find memory leaks in an application we're working on, using the following tutorial: https://www.jetbrains.com/help/dotmemory/How_to_Find_a_Memory_Leak.html
While analyzing the comparison of snapshots, the tutorial shows the following screenshot:
While, on my screen, there is no "Outgoing", "Key" or "Incoming" references tab at all:
Am I overlooking something, or is there a difference between versions? How do I get a list of references and retention paths?
Any help is welcome.
There are several objects of type "Settings_Part" in your snapshot, so you see an "Object set" view, which allows analyzing a set of objects. To see an "Object" view from the help article you need to scope to one object. To do this, use "Instances" view to see all objects instances in the set and choose one to analyze. Or if you not sure that all of these objects retained in the same way, you can use "Similar retention" view first to split these objects into clusters by different retention path, scope to one of them and then, use "Instances" view as described above.

ASP.NET mvc 5 - Returning user exception

I am totally new to ASP.NET MVC 5 and I need some help.
Background:
I am building my own web site because I would like to productise it eventually.
It's a form of eating your own dog food.
I have created a default application (you know, the one with all the MS links) and am modifying it for my own needs.
The first thing I did is what you should NEVER do :) i.e. modify the database tables manually to add roles and give my spanking new user the admin role. I did google but either I asked it the wrong question or
missed the link totally. Either way, I modified them manually and it
seemed to "work" (i.e. no db integrity errors were raised in Visual Studio).
I then added a "Products" table and did the scaffolding from the model to the controller, views, etc (thanks Mr Google). I also found how to stop
showing links in the Index view for the data manipulation if you're not an
admin.
Now, as I implied, I had registered a user, so I was curious to see what
would happen when I returned and tried to call (from URL) my brand new toy.
That's when a very useful "Object reference not set..." came up.
I have therefore a few questions:
Did I do anything stupid (likely)?
If I did, what is it?
The stack trace does not mention anything to do with login or
errors in the db, except for the following lines:
Microsoft.Owin.Security.Cookies.CookieAuthenticationProvider.Exception(CookieExceptionContext context) +49
Microsoft.Owin.Security.Cookies.<AuthenticateCoreAsync>d__2.MoveNext() +3698
which are just below the main line detailing the error.
So, if I am correct, it tried to access a cookie it didn't find.
What do you think is the most likely cause of this issue?
Suggestions?
[UPDATE]
Ok, so I have tried digging a bit to see whether I could find something interesting... and eventually I did.
Buried in one of the many files, I found this comment:
Note the authenticationType must match the one defined in
CookieAuthenticationOptions.AuthenticationType
Which seems to match with the stack trace outlined above.
I did check and it seems to me that they are the same(thanks to Google I found where to look).
I am stuck.
Please help!

HVUpdate Exception: Value cannot be null

I am getting a very strange exception and am having quite a bit of trouble tracking it down. I'm not sure how much good posting it here will do, but I figured it would be worth a shot.
On software that is working in the world, one of our clients started getting a continuous stream of exceptions in the Event Log. I have the program set up to store events under the company name in Applications and Services, and set the Source to the actual class that is writing the event when called.
The full error that I am getting is:
HVUpdate Exception: Value cannot be null
Parameter name: source
I have checked my code, and the only place I use a variable named "source" is when writing to the Event Log. However, this should only happen when starting the service. After that, all logs are written to a log file. I confirmed that source was defined in each of the two classes that might write to the Event Log.
The service has been running just fine, and is writing to the log file as expected.
Has anyone seen an HVUpdate error before, and know what might cause it? I do not have a class by that name, nor do I access one. My best guess is that it is a class used by the Event Logging, and it is telling me that my Source is null when trying to write a log. However, if this were the case, there would be a maximum of 3 logs written, not one a second. I've done a Google search on HVUpdate, but wasn't able to find anything there, either.
An odd question, I know. I hope someone has seen something similar before and can point me in the correct direction. If you need additional information, let me know. Thank you.

"The given reader is incompatible with the current materializer. Create a different materializer for this reader."

I'm getting the abovementioned error message, and I'm hoping that someone can translate the thing for me. The only references I've found online in a bit of searching are quotes from code blocks without explanation. They look like they're related, but they don't actually offer any help in figuring out what's going on.
background: I'm trying to maintain a chunk of legacy code in an mvc2/C#/EF/SQL stack, which uses these materializers (and, presumably, readers) as a way to communicate with the database. I have essentially no understanding of how materializers work beyond the "oh, that seems sort of like it does something like this" that you get just from a read-through of the code itself. I had to make some changes to the database on one of the table/object sets that used a materializer. I adjusted the materializer appropriately (as far as I can tell), cheating off of the existing code heavily to add equivalent lines for the columns/properties that were added, and removing lines for those that were removed. I also commented out a function in the c# class called TryParse, because as far as I could tell, nothing used it, and we're attempting to cut down on the cruft a bit. It now appears to fail some, but not all, of the time when the thing is used. I really do not know whether it was failing like this before my changes or not.
I don't need an answer of what exactly is going on - I have a suspicion that that would take way too much commenting of code blocks and whatnot. Mostly, I'm hoping that someone can give me a general pointer or two of the "ah, this error message generally means that" variety, so that I'm not flying completely blind (though if anyone is able to come up with more than that based on the information I've given, that would be great).
Thank you for your time.
The error message is from EFExtensions. The source indicates that this error is thrown when the shape (field count and field names) of a record in a reader doesn't match the shape the materializer expects.
(A materializer is just something that makes object instances out of something else, in this case data read by a reader)
It's not immediately clear to me from the EFExtensions source how this can happen in the 'normal' case, as it looks like the expected shape is inferred from the first record read, and then all subsequent records are checked against that. Obviously for a normal IDataReader, all the records will have the same shape.
However, it sounds like you might have custom materializers at work (possibly inheriting from the EFExtensions ones, hence why you're getting their error messages), in which case the answer might lie in your materializer code.

Categories

Resources