I have an application that uses webbrower control to navigate to some vendor sites and scrap reporting. Because there are several accounts with a vendor, I have to end the session with a browser and clear any set cookies. I am using wininet.dll for both API calls and getting the desired results. However, intermittently, I find an obstacle on InternetSetOption for INTERNET_OPTION_END_BROWSER_SESSION.
This is a very linear code and Internet application is called from one location to the same place. Is it difficult to find out that while walking in the debug, I am only able to reproduce the problem very rarely. As soon as I am VS Run out and run, it will be soon afterwards. I separated it by separating it and by pumping the messages for consolation.
Sometimes I have been able to capture the problem during debugging, it only shows InternetSetOption as the next statement and there is no exception or error, nothing in the output window. InternetSetOption should return the boolean, but the program will not go ahead and I will never get any returns from the API call. I have thrown the last error message, but in this case it does not help because it does not cause any errors.
Does anyone have any input that I can forward to debug it? Declared as:
[DllImport ("wininet.dll", SetLastError = true, Charset = CharSet.Auto)] Private static extern bool InternetSetOption (IntPtr hInternet , Int DwOption, IntPtr lpBuffer, int lpdwBufferLength); and is called by:
Internet-based (IntPtr.Zero, 42, IntPtr.Zero, 0);
For anyone else coming across this, by chance, there is only one problem - To clean MSDN's site cache and cookies I found that a function may cause problems.
There were several problems in the ClearCache () function, which is between x86 and x64 and refers to removing cache files for them -
In the current function, call this DeleteUrlCacheEntry does this way:
DeleteUrlCacheEntry (internetCacheEntry.lpszSourceUrlName); However, should be in x64
DeleteUrlCacheEntry (internetCacheEntry.lpszLocalFileName); You have to toggle between them on the basis of the forum, a single reference does not work on both x64 and x86, controversial point for me, though this function often breaks access violation exceptions , And whenever it is caught and handled, I believe this is the root of InternetSetOption which seemed to be a stalemate. Again, due to the strange nature of the deadlock, it was not able to shoot it completely, for me it was not correct due to the change of sequence of two function calls using both the clean () function and the Internet esotope.
I removed the WebBrowserHelper class and I reverted to clear cache and cookies by executing the RunLL 32 and waiting for that process to exit.
P> Hope that helps anyone!
Comments
Post a Comment