Writing to windows event log and fixing “the description for event id cannot be found”

When developing a .Net application and trying to write to the eventlog, the actual message in the event log might contain:

The description for event id 0 cannot be found

This is usually due to the registry key HKLM\SYSTEM\CurrentControlSet\services\eventlog\[myLog]\[mySource]\EventMessageFile not being correctly set or not set at all.

In my case, the application was running with insufficient permissions to write that value.  Changing the key permissions to my username fixed that issue.  Running the application with administrative privileges should also do the job.  This is on a development computer, if that happens on production/user computers, this key should probably be created at installation.

Sample code to write to the event log

string sSource="Debugging";
string message="Test";

if (!System.Diagnostics.EventLog.SourceExists(sSource)) 
 System.Diagnostics.EventLog.CreateEventSource(sSource, "MyLog");

System.Diagnostics.EventLog.WriteEntry(sSource, message, System.Diagnostics.EventLogEntryType.Warning);

Access a VMFS drive under windows

Here is a procedure how to access a hard drive formatted in VMWare’s VMFS file system from Windows. This could be handy if an ESXi host crashes, if a hard drive fails or for digital forensics.

1- Download VMFS driver : http://code.google.com/p/vmfs/
2- Unzip it to a path-friendly location (C:\vmfs)
3- Make sure java.exe is in your PATH environment variable, if not, add it.
4- Test-run fvmfs.jar by typing in administrator command prompt:
cd \vmfs
java -jar fvmfs.jar

5- Connect the external drive to your computer and check its disk number in Windows Disk Management. Disk 1 will be named \\.\PhysicalDrive1 in vmfs

6- Check if we can access the disk

java -jar fvmfs.jar  \\.\PhysicalDrive1 info

7- Share using webdav

java -jar fvmfs.jar \\.\PhysicalDrive1 webdav

8- Make sure the webclient service is running

9- Mount the drive

net use * http://localhost:50080/vmfs

10- Your drive should now be mounted as a standard windows drive.

This driver gives you read-only access to the file system.

Plesk users passwords

If you need to get your Plesk users’s password, the information is stored in a database named psa and in a table named accounts.  The passwords are not hashed, they are only stored as BLOBs in Plesk 10 or later (previous versions were clear text) so a simple CONVERT can list them.

Start mysql and prompt for password.  Then select database to use.

mysql -p
mysql> use psa

Run the query (Plesk 10)

SELECT
a.id,
CONCAT(m.mail_name,"@", d.name) AS email_address,
CONVERT(a.password USING utf8) AS password
FROM mail m
LEFT OUTER JOIN domains d on d.id=m.dom_id
LEFT OUTER JOIN accounts a ON a.id=m.account_id

Optionally, you can add the following search criteria

WHERE d.name IN ('domain1.com','domain2.com')

References:

OpenVZ / Proxmox – How to share folders between VMs or between Host and VM

Notes:

  • This must be run on hardware node (host)
  • Replace 102 with your container ID (Id of virtual machine)
  • Create /common-stuff folder in VM before restarting
 vi /etc/vz/conf/102.mount

paste:

#!/bin/bash
source /etc/vz/vz.conf
source ${VE_CONFFILE}
mount -n --bind /common-stuff ${VE_ROOT}/common-stuff
 chmod +x /etc/vz/conf/102.mount

Restart VM

Sources:

BizTalk and OAGIS xsd – building Component_Schemas

I tried following this procedure to use OAGI schema in BizTalk and got a few problems so here are the solutions.

Problem #1
On build of project Component_Schemas:

Error: Node “<Schema>” – This schema file has a TypeName that collides with the RootNode TypeName of one of its root nodes.

Solution #1
For all errors, select the “<Schema>” node and change the RootNode TypeName property to something unique.  What I did was to add the folder name to the current TypeName.

Problem #2
On build of project Component_Schemas:

Error: The type or namespace name ‘SerializableAttribute’ does not exist in the namespace ‘ProjectName.System’.
Error: The type or namespace name ‘NonSerializedAttribute’ does not exist in the namespace ‘ProjectName.System’.

Solution #2
According to this article on Microsoft’s website, the problem happens because some xsd files are stored is a folder named “System”. Sadly for us, OAGIS uses a folder structure with a folder named system.

  1. In Solution Explorer, expand “System” folder.
  2. Click each file in the System folder and in any subfolders, and then change the namespace entry in the Properties window so that any occurrence of System becomes _System. For example, change the MyProject.System.SubFolder namespace to the MyProject._System.Subfolder namespace.

 

Remote Desktop Session automatic logoff on Windows 2008 R2

This is another annoying setting in Windows 2008 R2, especially when a virtual machine is used for development.  To deactivate the automatic logoff of a disconnected session in Windows Server 2008 R2…

  1. Go to Administrative Tools > Remote Desktop Services > Remote Desktop Session Host Configuration
  2. Select top left node (RD Session Host Configuration)
  3. In the middle window, right-click on RDP-Tcp and click Properties
  4. On the Sessions tab, change the End a disconnected session to the wanted value.

SharePoint 2010 – fix changing computer name

If you have a SharePoint installation and for some reason you changed the name of the machine on which the SQLServer instance is running, SharePoint won’t be able to connect to the database server anymore. The reason is because SharePoint stores the computer name (netbios name) in many places in its configuration database.  In order to fix this issue, you must reconfigure SharePoint to let it know the new SQL Server location.

On my developer machine (Windows 7), I installed SharePoint as suggested by Microsoft for developer computers so this creates a separate instance for SharePoint on the local SQL Server.  It is not required to enter the instance name when you configure the server, only the computer name will be enough.

The following steps are based on Pinal Dave’s procedure he posted on his blog: http://www.sqlauthority.com. Great blog by the way, go take a look!

1- Start SharePoint 2010 Management Shell (Run as administrator)

2- Run the following command:

stsadm -o setconfigdb -databaseserver myComputer -farmuser myDomain\myUser -farmpassword myPassword

NOTE: This might take several minutes to complete.

3- Go into Internet Information Services Manager

4- Remove the SharePoint Central Administration v4 site. It will be re-created automatically later.

5- Run the SharePoint 2010 Products Configuration Wizard

6- Click Next > on the Welcome Screen.  NOTE: You might need to run the SharePoint Configuration Wizard twice if the removed administration site is not created the first time.

7- You’re done, you should now be able to connect to your SharePoint Central Administration website.

Next time you configure your SharePoint server, do it with database aliases instead of server names.

SSRS report execution time

This query will list the 100 reports that took the longest time to run today.

You must be connected to the SSRS engine, not the database engine.

use [ReportServer]
select top 100 
datediff(s,EL.TimeStart,EL.TimeEnd) as 'Runtime(secs)',
C.Name, EL.Status, EL.Username, EL.TimeStart, EL.TimeEnd, 
EL.TimeDataRetrieval/1000 as TimeDataRetrieval, --Time it took to get the data from the datasource
EL.TimeProcessing/1000 as TimeProcessing, --Time it took to group, filter, aggregate and subreport
EL.TimeRendering/1000 as TimeRendering, --Time it took to render, page, expression evaluation
(EL.TimeDataRetrieval + EL.TimeProcessing + EL.TimeRendering)/1000 as TotalRunTime,
C.Path, EL.Parameters
from dbo.ExecutionLog EL
Inner Join dbo.Catalog C on EL.ReportID=C.ItemID AND C.type=2 --Type=Report
where EL.TimeStart >= DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE())) --Today
order by 'Runtime(secs)' desc