Solving development problems  |  About this blog

ReportQueue folder too big – is it safe to delete?

We have noticed extremely large folder on our server. It happens that Error logs are kept there.

Folder is here:
c:\users\%username%\appdata\local\Microsoft\Windows\WER\ReportQueue

We have deleted its content completely and we also disabled Error logging. In order to do this you need to change group policy (as administrator):

  1. Start gpedit.msc to open the group policy editor
  2. Browse to computer settings/administrative templates/windows components/windows error reporting.
  3. On the right hand side there will be a “Disable windows error reporting” setting that you can flip on to disable things altogether

If you want to take a look at one of the erorr dumps the easiest way to do this is through the windows debuggers:

  1. Install the windows debuggers from http://www.microsoft.com/whdc/devtools/debugging/default.mspx
  2. Make sure the debugger machine has internet access, and copy one of the .hdmps across to it.
  3. Run windbg.exe -z foo.hdmp to open up the dump in the gui debugger
  4. From the command window that comes up type:
    • symfix c:\cache   – this fixes up the symbol paths so we can resolve stacks
    • reload -f ntdll.dll  – this loads symbols for one of the core os dlls and validates that we can do basic analysis
    • analyze -v     – this analyzes the dump and should give root cause analysis including the stack back trace from the crash etc.

Simply what is JSON?

JSON is a way to store data like XML but in different form.

Simple rules:

{ and } define class
[ and ] define array
values are written as key:value pairs and separated with comma (,)

Example:

{
  "id" : 123,
  "topic" : "meal",
  "today" : "kiwi",
  "fruits" : [ "apple", "banana", "cherry" ],
  "orange" : { "color" : "orange", "shape" : "round" }
}

Parsing JSON in Java (Android)

String json = /* string from example */
JSONObject obj = new JSONObject(json);

int id = obj.getInt("id"); //123
String topic = obj.getString("topic"); //meal
String today = obj.getString("today"); //kiwi

JSONArray fruits = obj.getJSONArray("fruits");
for (int i = 0; i < fruits.length(); i++)
{
  String fruit = fruits.getString(i); //apple, banana or cherry
}

JSONObject orange = obj.getJSONObject("orange");
String color = orange.getString("color"); //orange
String shape = orange.getString("shape"); //round

Building JSON in Java (Android)

JSONObject obj = new JSONObject();
obj.put("id", 123);
obj.put("topic", "meal");
obj.put("today", "kiwi");

JSONArray fruits = new JSONArray();
fruits.put("apple");
fruits.put("banana");
fruits.put("cherry");
obj.put("fruits", fruits);

JSONObject orange = new JSONObject();
orange.put("color", "orange");
orange.put("shape", "round");
obj.put("orange", orange);

String json = obj.toString();

DNS Recursive Queries problem

Great online tool http://www.intodns.com/ can check DNS records for your domain.

After checking we got some error that was written like this:
I could use the nameservers listed below to performe recursive queries. It may be that I am wrong but the chances of that are low. You should not have nameservers that allow recursive queries as this will allow almost anyone to use your nameservers and can cause problems. Problem record(s) are:
xxx.xxx.xxx.xxx

Because we have primary, secondary and ternary DNS servers we needed to disable recursive queries on Windows servers.

To do this you will need to do this manual work:

  1. Open Regedit
  2. Find the key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\DNS\Parameters
  3. Add new value: NoRecursion and set it to DWORD type and set value to 1
  4. Restart DNS service on your Windows server

After that warning error disappeared.

How to trigger change event on HTML hidden field?

HTML hidden field change event does not fire when the value is programmatically changed.

You can trigger this value manually after setting the new value for your hidden field, like this:

$("#yourHiddenFieldId").val("some value").change();

How to restore administrator access to a SQL server

We have found very good article that helped us a lot so we are spreading it…

We got the CLOUD hosting that had SQL Server 2008 installed.

Unfortunately, we got this error:
CREATE DATABASE permission denied in database ‘master’

Despite being an administrator on the box, AND having launched Management Studio in Administrator mode (on Windows 2008R2).

Attempts to grant myself permissions, or to make any changes to SQL server resulted in:
User does not have permission to perform this action( Microsoft SQL Server, Error:15247)

This all happened because we were not the SQL Server administrators despite being an administrator on the machine itself.  This is a new situation in SQL Server 2008. In SQL Server 2005, the local Administrators group was part of the SQL Server administrators. It turns out that only the person who installed SQL Server is a SQL Server administrator. Since that person was not available, we were faced with either uninstalling and reinstalling, or getting into an argument with SQL Server.

Being stubborn, we chose to argue. We knew as an Administrator that we could do anything we wanted, it was just a matter of finding the right registry keys/files/whatever to add ourself to the group. The trick is to put SQL server into single-user maintenance mode so that it ignores authentication.

NOTE: In all of the examples below, you may have to change parameters or command-lines based on your server name and instance name.

Force SQL server to support mixed-mode authentication

  1. Run REGEDIT
  2. Go to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQLServer
    NOTE: This key wiil vary slightly based on the installed version and instance name.
  3. Set “LoginMode” to 2. (Source: http://support.microsoft.com/kb/285097)
  4. Restart SQL Server.

Force SQL server to let you in temporarily

  1. Go to services.
  2. Stop SQL Server.
  3. Grab the SQL server command-line (right click the service – properties). Our is:
    “c:\Program Files (x86)\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER2008\MSSQL\Binn\sqlservr.exe” -sMSSQLSERVER2008
  4. Open an administrative command prompt.
  5. Run the command-line from step 3, but add -m -c for single-user maintenance mode command-line so the final command looks like
    “c:\Program Files (x86)\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER2008\MSSQL\Binn\sqlservr.exe” -sMSSQLSERVER2008 -m -c
  6. Open another administrative command prompt.
  7. Run “sqlcmd -S localhost\MSSQLSERVER2008″ from that same directory (replace with your server and instance name)
  8. Now you can do all the stuff everyone told you to do that didn”t work. For example, to create a hero user with administrative access:
    CREATE LOGIN hero WITH PASSWORD=”123″, DEFAULT_DATABASE=[master], DEFAULT_LANGUAGE=[us_english], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF
    EXEC sys.sp_addsrvrolemember @loginame = “hero”, @rolename = “sysadmin”
    GO
  9. QUIT and close the command-prompt
  10. Go to the SQL Server command-line window and hit ctrl+C. It will prompt “Do you wish to shutdown SQL Server (Y/N)?” and enter Y.
  11. Close the command-prompt (Source: http://msdn.microsoft.com/en-us/library/dd207004.aspx)

Finally, login using your hero

  1. Restart the SQL Server service
  2. Login using SQL Server authentication as the user “hero” with password “123″
  3. And *BOOM* now you are in. Enjoy in your data!