• Uncategorized

    ViewState validation troubles?

    If you work with web sites in a complex/multi server environment you might be familiar with this error and as the error message itself suggest, the first thing to check if the machineKey value which must be the same across all of the involved server. Anyway every now and then it happens that you might get this same error even if you are not in a NBL/Cluter environment (Tess and Tom have blogged about this here, here and here) or if you are absolutely sure you have properly configured the machineKey value. So what else can lease you to this state? If you want some quick  background you have a look at my post here; basically we have the following (very raw) steps: Begin processing the new request Load the “old” state (ViewState and ControlState) received with the posted values Process the posted data (the actual form values) and raise the “change” events to change control state and do the real page work Save the new state (again, ViewState and ControlState) Send the result back to the client It is important to note that if you dynamically add controls at runtime on your page (i.e. you do not only rely…

  • Uncategorized

    “Padding is invalid an cannot be removed” or “WebPartManager is undefined”

    I saw this error twice very recently and searching the Internet remarkably I’ve not been able to find any good explanation for it, so I hope this can be helpful in case you’ll get in trouble. Web Farm? The first occurrence happened with an application hosted on a web farm, and in IE the users were getting the error “WebPartManager is undefined”. If you take a look at the HTTP traffic with Fiddler (or you look into the IIS logs) and you see you are getting error 500 on WebResource.axd, then have a look at the “TextView” tab and other tabs to carefully inspect the request you get from the server. That way, we found the real error message, which was: Padding is invalid and cannot be removed. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Security.Cryptography.CryptographicException: Padding is invalid and cannot be removed. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack…

  • Uncategorized

    WebResource.axd or ScriptResource.axd not working

    Http compression with client-side scripting should be handled with care. The problem can have different symptoms and manifest in different ways, but essentially it has a common root cause and I have already discussed some of the aspects (for example see here and here). This time the customer whom reported the problem was using Forms Authentication in his application so the first time an unauthenticated user browsed it, he was redirected to the login page configured in web.config. So far so good. In this case the problem was a javascript error notified by the standard yellow icon in the bottom left corner of IE; the error was an “Object expected” on “WebForm_AutoFocus()” which is a method generated by ASP.NET as a result of an object.SetFocus() call on the server-side. Some quick theory WebResource.axd and ScriptResource.axd are Http Handlers used by ASP.NET and Ajax to add client-side scripting (usually javascript) to the outgoing web page for example to have client-side input validation, set the focus on a specific control (as in this example) etc… Note that if you search your disk for .axd files, you’ll not find them; they are created on the fly in memory and executed from there. Well,…

  • Uncategorized

    How much garbage to you still have on the managed heap?

    When you’re focused on a specific problem, you’re sunk into it and you’re at a dead end, you have to take a step back to see the whole picture and breath again before being able to continue; often discussing with a colleague whom still has a “fresh mind” and doesn’t know anything about the specific problem and the troubleshooting you’ve already done can give nice suggestions and tips about next steps and a different approach to the problem. This is what happened a couple of days ago with Doug while we were discussing a memory leak issue I’m currently working on. This seems to be a complex and a bit confusing one (I do not want to dig into the details for post, I’ll likely talk again in details when the problem will be resolved 🤓); anyway a question that should always come to mind dealing with memory leaks is: how much of the memory I see still allocated in a dump is really valid and how much is garbage which our friendly Garbage Collector will remove next time it will come into the game? Well… a nice solution is to have a very simple “service” page to trigger a…

  • Uncategorized

    Need a hotfix… then “Fix it!”

    Things keep moving and after some discussion (here and here I already expressed my view on the matter), the first KB article with a “Fix it” button to directly download the relevant hotfix has gone live a couple of days ago, check it out: http://support.microsoft.com/kb/945402/en-us. Carlo Quote of the day: Committee–a group of men who individually can do nothing but as a group decide that nothing can be done. – Fred Allen

  • Uncategorized

    Troubles downloading public symbols?

    Imagine you are debugging your dump, are already looking forward for the output of the command you just typed (say a kpn to get the stack of a thread) and you get this message instead: *** ERROR: Symbol file could not be found.  Defaulted to export symbols for mscorwks.dll WARNING: Frame IP not in any known module. Following frames may be wrong. As you can understand, not having the symbols for mscorwks in a .NET dump can make your analysis harder and above all without matching symbols you cannot really trust what you see in your debugger (despite the title of my blog! ?) and ultimately it can make the dump almost useless. I actually talked with a customer a few days ago whom got this exact situation and he was quite frustrated and upset with Microsoft for not hiving the symbol for the core .NET dll on the public symbol server. Anyway, without losing his temper that developer used the !sym noisy command to have a look at the symbol loading output, here is what he got: SYMSRV:  The operation timed out SYMSRV:  d:\symbols\mscorwks.pdb\62286AFFFC674D5198883B98518936FF2\mscorwks.pdb not found SYMSRV:  http://msdl.microsoft.com/download/symbols/mscorwks.pdb/62286AFFFC674D5198883B98518936FF2/mscorwks.pdb not found The pdb was actually on the server, but for…

  • Uncategorized

    Invalid length for a Base-64 char array

    There are various causes for this error, this is one we had some time ago when paginating through a DataGrid (for this case we’re talking about ASP.NET 1.1); the error appeared systematically under a specific user pattern: Invalid length for a Base-64 char array. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.FormatException: Invalid length for a Base-64 char array. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [FormatException: Invalid length for a Base-64 char array.] System.Convert.FromBase64String(String s) +0 System.Web.UI.LosFormatter.Deserialize(String input) +25 System.Web.UI.Page.LoadPageStateFromPersistenceMedium() +101 [HttpException (0x80004005): Invalid_Viewstate Client IP: 213.199.128.155 Port: 24949 User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506; .NET CLR 1.1.4322; InfoPath.2; MS-RTC LM 8) ViewState: dDw2Mjg2Njc3OTM7dDw7bDxpPDA+Oz47bDx0PDtsPGk8MT47aTwzPjs+O2w8dDxwPHA8bDxUZXh0Oz47bDxcZTs+Pjs+Ozs+O3Q8QDA8cDxwP Gw8V2ViR3JpZF9Tb3J0RXhwcmVzc2lvbjtTaG93Rm9vdGVyO1Zpc2libGU7XyFTQjtQYWdlQ291bnQ7UGFnZVNpemU7V2ViR3JpZF9MYWJlbHM7 V2ViR3JpZF9Dc3NDbGFzc0J1dHRvbnM7Q3NzQ2xhc3M7XyFJdGVtQ291bnQ7XyFEYXRhU291cmNlSXRlbUNvdW50O1dlYkdyaWRfU29ydFR5cGU7 V2ViR3JpZF9Dc3NDbGFzcztEYXRhS2V5czs+O2w8TnVtZXJvO288Zj47bzx0PjtpPDI+O2k8MT47aTwxMD47YjxBQUVBQUFELy8vLy9BUUFBQUFBQ UFBQ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JUSU4gSU4gTE9D QUxJVMOAIFBMRU9ELiBJTVBFR05PIERFTExFIFNPTU1FIE5FQ0VTU0FSSUUgUEVSIExBIFBST0NFRFVSQSBESSBFU1BST1BSSU8uIExJUVVJREFaS…

  • Uncategorized

    How to automate Process Monitor

    The other day I needed to capture a Process Monitor trace on a machine to troubleshoot a problem where the entire OS GUI was “broken” after the resume from screensaver; with “GUI broken” I mean that clicking on any icon on the desktop has no effect, the right click menu does not work etc…, but we are still able to access the Task Manager and run tasks (command line etc…) from the File > New Task (Run…) menu. This suggests the user’s registry is for some reason unloaded during when the screensaver is running, but the point is: if I run Procmon before the screensaver starts and wait for the problem to reproduce (to have a complete trace) then I’m unable to save the trace because I cannot access any running task which a GUI unless I start a new one or reboot the machine. Either way the trace is lost. Coincidentally also my colleague Stefano had a similar problem and we (he, actually) found a couple of command line switches that can be used to control Procmon for such situations, in particular “/BackingFile” and “/Terminate”: /backingfile tells Procmon where to automatically save the trace, while /terminate actually starts a…

  • Uncategorized

    HashTable insert failed. Load factor too high

    I already encountered a few recurrences of this errors and every time it has been a torture to capture a correct set of data (especially memory dumps) to review because this usually happens sporadically and you could have to wait weeks if not months before getting it again. There are a couple of hotfix available for this error message (see http://support.microsoft.com/default.aspx?scid=kb;EN-US;831730 and http://support.microsoft.com/default.aspx?scid=kb;EN-US;893314) but you already have them if you’re on the latest Service Pack for the .NET Framework. Unless you’re using HashTable objects yourself… If that’s the case you might be running into a race condition which leads to the error, so you might want to consider to use the following code to synchronize the HashTable using SyncLock: Dim MyHashTable as new Hashtable() SyncLock MyHashtable.Syncroot MyHashtable.Add (myKey, myValue) End SyncLock As an alternative you can use the Hashtable.Synchronized() method to return a synchronized (thread-safe) wrapper for the HashTable object.   Carlo Quote of the day: Everyone is a genius at least once a year. The real geniuses simply have their bright ideas closer together. – Georg Christoph Lichtenberg

  • Uncategorized

    /bin is not for native assemblies

    After 4 years as a Support Engineer for ASP.NET, when I get a new case I usually can make a decently reliable idea pretty soon (often from the problem description the customer gives us, if it has enough details) about the problem complexity, how long it will take to resolve etc…, but every now and then (luckily not too often) there are occasions, as the one I’m going to talk about, where a fairly common problem as a “File not found” issue turns into something able to leave you completely puzzled and after you have considered almost every possibility you are left without any clue or idea about how to continue with troubleshooting. And again most of the times in those situations the solution comes from a fresh pair of eyes (and a new, well skilled brain) which looking at the problem from a different perspective can spot that small clue which makes the rest appear as obvious as the easiest of the problems… ? The problem This time the problem description was well written: the customer developed a custom authentication mechanism for web applications, defined an authentication interface which can be implemented by other developers etc… The product exposes…