SQL Server error full-text filter daemon

We recently migrated from SQL server 2005 to SQL Server 2008 Web edition on our hosted servers, amongst several issues that were faced was the full text search error

SQL Server encountered error 0x80070218 while communicating with full-text filter daemon host (FDHost) process. Make sure that the FDHost process is running. To re-start the FDHost process, run the sp_fulltext_service ‘restart_all_fdhosts’ command or restart the SQL Server instance.

So when you execute the recomended SP

you receive this error

Msg 30046, Level 16, State 1, Procedure sp_fulltext_service, Line 163
SQL Server encountered error 0x80070218 while communicating with full-text filter daemon host (FDHost) process. Make sure that the FDHost process is running. To re-start the FDHost process, run the sp_fulltext_service ‘restart_all_fdhosts’ command or restart the SQL Server instance.

what you need to do is add the log on user the full text search service is running under, to the full text search security group on the box in question, it will look something ike this

SQLServerFDHostUser$lce-1$MSSQLSERVER

For me all i needed to do was add the “local service” account to the group – restart the sql service and re run the execute command

Problem solved

LINQ to Entities does not recognize the method ‘System.String ToString()’ method

If you use the entity framework from microsoft, latest version at the date of this post is framework 4.0
You might run into this little angel when you try to envoke the string value of an object

LINQ to Entities does not recognize the method ‘System.String ToString()’ method

This happens when applying a filter to an integer field and you want to use the

method of a string. So my code looked ike this

From the master query

etc…

The only way i Could get round this was to onvert the UID field into a string in the master select query like so

notice the cure was to force linq to convert the resulting field into a string, allowing the filter to look like this

Microsoft have a list os supported methods here

Diagnostics.PerformanceCounter Input string was not in a correct format

when you try to get performance information you receive the following error at the initialiser

Dim Ram As New Diagnostics.PerformanceCounter(“Memory”, “Available MBytes”)

Input string was not in a correct format

Starting “perfmon” from your run box to open the performance monitor presents you with a message box

—————————
Performance Monitor Control
—————————
Unable to add these counters:

\Memory\Available MBytes
\Memory\% Committed Bytes In Use
\Memory\Cache Faults/sec
\Memory\Cache Faults/sec
\PhysicalDisk(*)\% Idle Time
\PhysicalDisk(*)\Avg. Disk Queue Length
\Network Interface(*)\Bytes Total/sec
—————————
OK
—————————

Easy fix, you need to rebuild your performance counters. I copied c:\windows\system32\PerfStringBackup.ini from a machine whos counters were working, replaced the one on the broken machine. Open a command prompt, navigate to the same location and run the following

lodctr /R:PerfStringBackup.INI

This will reload your counters

If that fails try what microsoft suggest Here

Access to the registry key ‘Global’ is denied

If you use performance counters in web based apps you may end up running into this problem,

[UnauthorizedAccessException: Access to the registry key ‘Global’ is denied.]

UPDATE For IIS7 on windows server 2008 (see the end of this post)

The solution is pretty simple, originally posted here

How to Read Performance Counters Without Administrator Privileges [Ryan Byington]
If you have ever tried to read performance counter data on a Windows 2003 machine as a non admin user you will have likely seen an exception like the following:

System.UnauthorizedAccessException: Access to the registry key ‘Global’ is denied.
at Microsoft.Win32.RegistryKey.Win32Error(Int32 errorCode, String str)
at Microsoft.Win32.RegistryKey.InternalGetValue(String name, Object defaultValue, Boolean doNotExpand, Boolean checkSecurity)
at Microsoft.Win32.RegistryKey.GetValue(String name)
at System.Diagnostics.PerformanceMonitor.GetData(String item)
at System.Diagnostics.PerformanceCounterLib.GetPerformanceData(String item)

Windows 2003, Windows XP x64 Edition, and Vista require that the user be part of the Performance Monitor Users group to read performance counter data. Simply adding your non admin user to this group will fix this problem.

Accessing counters remotely is another story though. On Windows 2003, Windows XP x64 Edition, and Vista you still must be part of the Performance Monitor Users group on the remote machine but there is a problem with the PerformanceCounter class where it tries to read some registry keys on the remote machine that a non admin users do not have access to. To give your user read access to these keys without having to be an admin on the remote machine complete the following steps on the remote machine:

Open the Registry Editor by going to the Start Menu and selecting Run…, then type “regedit”, and click the OK button.
Navigate to the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurePipeServers\winreg registry key.
Right click on the “winreg” key and select Permissions. Add users or groups to which you want to grant Read access.
Exit Registry Editor and restart Windows.
For more explanation on this process see here

UPDATE For IIS7 on windows server 2008 (16/11/2011)

This I can’t believe but none the less this is the way it is for IIS7. when you have performed the above steps and you are still receiving the error

Access to the registry key ‘Global’ is denied.

What you need to do is add the App Pool that your web app is running in to the “Performance Monitor Users” group as well. One immediate point is that you cannot find the group within the advanced search when adding objects to the group. You will have to manually type the name of the App Pool following this format

IIS APPPool\DefaultAppPool

Seems ridiculous I know and I haven’t fully got to the bottom of why but I suspect it is most likely something to do with the structure of IIS7 from an NT authentication perspective.

This also now puts an additional rule that one must not rename the App Pool and one must also be vigilant in as much as if you add another web app, creating a new app pool you might need to add this app pool to the group as well.

This updated solution came from here

Datatable to XML CSV TAB HTML Json

I have a common functions class (cfc) project i tend to fill with all functions i believe can be applied to anything and will likely be reused.
I was making some adjustments to a few handy functions and I thought it might be useful to publish the following functions which will help convert datatables to various output formats.

Visual Studio references the following libraries within my cfc project, im not entirely sure which ones are required for these functions so i will list them all.
System
System.Core
System.Data
System.DirectoryServices
System.Drawing
System.Runtime.Serialization
System.ServiceModel.Web
System.Web
System.Web.Extensions
System.Xml

We have 6 functions here
1. ConvertDtToXML
2. ConvertDtToTDF
3. ConvertDtToCSV
4. ConvertDtToJSON
5. ConvertDtToHTML
6. RenderControl

Lets talk about each one briefly.
1. ConvertDtToXML
This function is making use of .NETs Dataset object built in method GetXml, the one simple rule here is that the table must be named in order for the xml to be generated. So we simply declare a dataset, check for a table name, if none then give a standard name, add the table to the dataset and output using GetXml.

2. ConvertDtToTDF
3 things are going on here, the first for loop we get the column headings. Second we begin a for loop on all of the rows, and third we for loop against each column getting the data this time. Each loop builds up the TAB delimited string we end up with.

3. ConvertDtToCSV
A very similar approach to the tab delimited has been taken here with the CSV, its the text used to build the sting that differs.

4. ConvertDtToJSON
We make use of .NETs Json serializer to convert our datatable to a json string

5. ConvertDtToHTML and 6. RenderControl
This final converter function ConvertDtToHTML needs to use last function RenderControl.
Load the datatable into a gridview, bind it, then extract the rendered HTML from it.

Vista Boot – Element not Found

I recently had an enquiry from a user, they wanted to reclaim a partition on their machine that was allocated to emergency recovery. Seeing as the OS was different to that of the recovery I agreed.
My mistake was not to reconfigure the active primary partition. This caused the error msg Cannot find operating system.
So using the vista CD i booted in to restore mode and attempted to reconfigure the boot record, only to be presente with the message “element not found”. A quick google search yielded the solution. thanks goes to tturrisi for his accurate step by step recovery.

Excellent solution originally found here

Repair Vista Boot Loader
——————————————————————————–
If dual booting Windows & Linux, and also use GRUB, if you remove the Linux partition(s) you probably can no longer boot Windows. While this is very easy to fix if the Windows operating system is XP or earlier, it is a bit more complicated (but still easy to do) in Windows Vista.

More often than not, when removing Linux partitions in a dual boot Vista-Linux environment, or when using GPARTED to resize partitions, Vista can no longer boot.

Windows Vista uses a different boot loader than earlier versions of Windows. Fortunately the Vista bootable DVD contains a utility for repairing the MBR and boot sections of the hard drive. To repair the Vista bootloader: http://support.microsoft.com/kb/927392

However, the utility mail fail on any action and give an error message of “Element not Found”. This is because resizing the Vista partition(s) or Linux partition(s) changes the disk’s file allocation table and the Vista partition may get marked as “inactive”. The same holds true when removing or resizing Linux partitions. A boot partition MUST be marked as “active” to be bootable.

The remedy for “Element not Found” is this:

1.Put the Windows Vista installation disc in the disc drive, and then start the computer.
2.Press a key when you are prompted.
3.Select a language, a time, a currency, a keyboard or an input method, and then click Next.
4.Click Repair your computer.
5.Click the operating system that you want to repair, and then click Next. (if no Vista operating system is listed, click Next anyway)
6.In the System Recovery Options dialog box, click Command Prompt.

Next:

At the command prompt, type diskpart.
This will get you to the DiskPart prompt, which allows you to use a variety of hard disk partitioning and formatting tools similar to FDISK in older versions of Windows.

At the DiskPart prompt, type select disk # where the # sign is the number of the hard disk drive with Vista installed on it. If your Vista drive is the only hard drive in your computer, it is Disk 0.

Select the partition by typing select partition # where the # sign is the partition that has Vista installed on it.

Type active and press ENTER. The Vista partition is now active. Finally, type ‘exit’ to close DiskPart. Reboot the computer using the Vista dvd and follow steps 1-6 above. You can now repair the Vista boot:

Fix the Master Boot Record: (commands)

bootrec /fixmbr
bootrec /rebuildbcd
bootrec /fixboot

Symantec Antivirus DWHxxxx.tmp Bogus Trojan Horse

Recently one of my users had thousdands and thousands of files in the quarantine
All of them aparently trojan horse risks
All the files began with DWH ending with .tmp
This is infact symantec live update wizard DWHWIZRD.EXE trying to download updates available for the symantec application group rather than obtain the latest virus update list.

In doing so the real time scanner Rtvscan.exe identifies the temp file as a trojan, so depending on the rules in the risk settings will depend on what should happen when risks are found, it either deletes the file or quarantines it, and low and behold the update wizard starts to download the file again.

To resolve the issue (this time), login as an administrator of sorts be it domain or local. Locate the symantec liveupdate folder typically %system%\progam files\symantec\liveupdate and run the LUALL.exe
This will kick off the live update manually, follow the wizard steps until its complete then reboot.

This will likely happen again in the future until symantec either come up with a solution in one of the updates.

Note: this only appears to happen to users that are not part of the “local admin” group of the pc in question.

ASP.NET Custom Table and Object Caching How To

Preface
We have a very complex website, it involves recording everything that is ever rendered and some complex randomising of what we render. Our website is basically a pay per click revenue stream.

The Problem
Ok so the problem is, we rely on caching of a select number of data tables, this may sound silly to do but we are careful and we dont exceed the hardware capacity of the machine, and alas there is no other suitable method for us. The setup we have is IIS running in State Server mode using the ASP.NET state server Windows Service. Some of you will already know this is based on an XML filesystem structure to hold everything that gets placed into the cache.
Now for some reason state server started to break down and cause table and row corruption, we never managed to nail down why this was occuring since ASP.NET Datatables can be serialised and deserialised seemlessly from and to XML we concluded it was to do with asynchronous access to the objects in the cache breaking down. We needed to resolve the problem and we needed to do it now, I decided to write our own caching class that would sit in the Application Object.

The Solution
So a few basic rules here
1. The Class lives in the application object ergo when the website restarts the class disintigrates and re instantiates
2. The Class must be able to handle asynchronous access
3. The Class must offer similar features as ASP.NET cache, ie specifying lifetime of objects
4. The Class must also run maintenance on itself as a result of requirement 3
5. The Class must support Add, Get, Remove of datatables and objects

Ok so now we have some ground rules, it took me about a day to write, and the finished product should be attached to this post.

In your App_Code folder drop these three files (obviously rename them to .vb first).
ApplicationCache
itimer
SiteStart

Now heres how to use it.
1. Instantiate the class in the Global.asax file Application_Start routine (brings everything to life)
2. Attach a new timer to the maintenance event of the class _RunMaintenance (tells itself to cleanup)
3. Start the timer in a new thread .RunAsNewThread (opens the timer in a thread seperate from the application object, we like this seperation)
4. Add the class to the application object (so you can access it from anywhere in the app)

So starting in your global asax

Heres the code snippet you can use as an example of starting the class up, this can been seen inside SiteStart

OK so now the class is active how do i call it i hear you ask, well you have a choice.
If you have a base page then add this to it

If you dont then in your code behind file do this

Once you have done one of the above you can make the calls like so

Or

The reason we start a timer in a seperate thread is because we want to call the maintenance routine periodically and the only way to keep a timer allive from the application_start is to create a seperate thread, forget trying to place it in the application object or cache because it wont stay runtime, it will be deserialised into a static xml structure describing how to rebuild it.

Thats about it. You could attached a sub rountine that writes an information event to the windows event log when it runs, so you can make sure it works. You could also create a page that pulls out the current state of the class, ie how many tables its holding, what the names are etc etc.

Information Technology, Life, Interesting Stumbles, Servers, Configuration, Topology, Security, Best Practices, Developing, Fire Fighting, Problem solving, Visual Studio 2005 – 2015 .NET 1.1 – 4.5, jQuery, JSON & much much more