2007-10-27

Media center automatically starts the computer from standby

I've had a problem that I have finally found time to solve. I have a windows media center machine at home connected to my tv set. At night I put the machine in standby and every morning it start by itself at around 7. This is rather annoying since I don't have any scheduled jobs or recordings at that time.

I checked the event log and one of the first logs after startup in the application log was an 'Event Info: Guide Successfully Downloaded'.
Perhaps it's the EPG download that forces the machine to start? Can this be configured to another time in the day?

I checked the settings in mce but no entry states when to download the epg. So after some googling I found a post in one of the The Green Button forums that took up the issue.

To cut it short, the user Cowboy found out that there are two registry keys controlling this behavior

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Media Center\Service\EPG\dlLastTime

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Media Center\Service\EPG\dlRegTime


These keys contain the date when the guide was downloaded the last time and when it is registered to run the next time. The data format is stored in NT Time Epoch format but backwards. (see Cowboys forum post for detailed information)

To fix this you can set these values to another time and date by updating these registry values and restart the computer. For ease of use riesm had posted an application that provides a nice GUI for setting the download time. After using this and restarting the computer is not autostarted every morning at 7.

Thanks to Cowboy and riesm for providing the great community support.

2007-09-19

Running multiple versions of ASP.NET on the same IIS

When configuring a website to run multiple applications with different versions of ASP.NET there are some issues that needs to be resolved before the applications are running smoothly. The guide below describes the setup for a windows 2003 server.

1. Install the different dotnet framework versions on the server.
When installed you can check the c:\windows\microsoft.net\framework folder and each installed version contains an own folder named vx.x.xxxx. On my server, running
dir c:\WINDOWS\Microsoft.NET\Framework\v*
gives the following output
2007-09-12  08:15    <dir>          v1.1.4322
2007-09-12 08:44 <dir> v2.0.50727
2. Make sure the needed framework is installed in the IIS
Each framework version installs a tool named aspnet_regiis.exe. This tool is used to manipulate the IIS metabase for asp.net registrations and mappings. Depending on which version of the framework the tool is shipped with, there exists different switches that can be used. Run the exe in a command window to see which are supported for your version.
To see which frameworks is installed in the IIS metabase, run the tool with the -lv flags. (Example below)
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>aspnet_regiis.exe -lv
2.0.50727.0 Valid (Root) C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll
If your needed framework isn't listed, go to the version folder and run the aspnet_regiis.exe with the -ir flag. (the -i flag will also install the framework but will also update the scriptmaps, which we don't want to do (not yet anyway))
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322>aspnet_regiis.exe -ir
Start installing ASP.NET (1.1.4322.0) without registering the scriptmap.
Finished installing ASP.NET (1.1.4322.0) without registering the scriptmap.
Running the -lv again we'll se that we now have two frameworks registered in the IIS metabase.
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322>aspnet_regiis.exe -lv
1.1.4322.0 Valid C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll
2.0.50727.0 Valid (Root) C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll
3. Install the scriptmaps on the web application
In addition to installing the framework in the IIS metabase we need to configure the web application to use the specific framework version.
To see which mappings that are in effect use the -lk flag
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322>aspnet_regiis.exe -lk
W3SVC/ 2.0.50727.832
W3SVC/1/ROOT/ 2.0.50727.832
W3SVC/1/ROOT/Reports/ 2.0.50727.832
W3SVC/1/ROOT/ReportServer/ 2.0.50727.832
W3SVC/3/Root/ 2.0.50727.832
To set the scriptsmaps for a specific application use the -s flag. (here my application is running on the path W3SVC/258083574/root/MyApplication)
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322>aspnet_regiis.exe -s W3SVC/258083574/root/MyApplication
Start registering ASP.NET scriptmap (1.1.4322.0) recursively at W3SVC/258083574/root/MyApplication.
Finished registering ASP.NET scriptmap (1.1.4322.0) recursively at W3SVC/258083574/root/MyApplication.
When installation is successful use the -lk to see the updated mapping
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322>aspnet_regiis.exe -lk
W3SVC/ 2.0.50727.832
W3SVC/1/ROOT/ 2.0.50727.832
W3SVC/1/ROOT/Reports/ 2.0.50727.832
W3SVC/1/ROOT/ReportServer/ 2.0.50727.832
W3SVC/258083574/root/MyApplication/ 1.1.4322.0
W3SVC/3/Root/ 2.0.50727.832
4. Make sure each version uses separate Application pools
A common mistake is to use the same application pool for multiple applications running different versions of the framework. This is not recommended and will most certainly break in time.
So... don't.
Changing application pool settings and creating new ones is done in the mmc tool (Internet Information Services). You don't have to configure the pools, just don't mix applications running on different framework versions.

5. Make sure that WebService extensions allows webpages of the specific version
If you now test your new application and tries to view an aspx page but the server only returns a 404 error, then you need to fix the WebService extension settings.
Locate the Web Service Extensions folder in the mmc tool and Allow the ASP.NET version to execute.

Good luck!

2007-09-10

Sandcastle crashes... code and pre tags

Almost done with the current project release. Continuous server(CCNET) is running,
building - OK,
unit tests - OK,
analyzing - OK,
compiling xml documentation -- Err

Computer says:
Info: BuildAssembler: Building topic T:Sdo.Agent.TypeInstance`1

Unhandled Exception: System.Xml.XmlException: Unexpected end tag. Line 2, position 57.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
at System.Xml.XmlTextReaderImpl.Throw(Int32 pos, String res)
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlLoader.ParsePartialContent(XmlNode parentNode, String innerxmltext, XmlNodeType nt)
at System.Xml.XmlElement.set_InnerXml(String value)
at SandcastleBuilder.Components.CodeBlockComponent.Apply(XmlDocument document, String key)
at Microsoft.Ddue.Tools.BuildAssembler.Apply(IEnumerable`1 manifest)
at Microsoft.Ddue.Tools.BuildAssembler.Apply(String manifestFile)
at Microsoft.Ddue.Tools.BuildAssemblerConsole.Main(String[] args)
Last step completed in 01:09:26.3530


Ok, so I checked the xml documentation for the class for mismatching tags, but couldn't find any.
After a bit of searching I found the following post on the Sandcastle forums.
http://www.codeplex.com/SHFB/Thread/View.aspx?ThreadId=12084

A <pre> tag had snuck into the <code> xml documentation and thats not supported.

Well you always learn something. =)

2007-07-04

AccessViolationException using Oracle and MTS

I have been annoyed by a really irritating bug in my test environment for quite some time. I use oracle and enlists the connection in the MTS and when I try to open the connection I get different errors (and sometimes there isn't any errors).
  • Oracle.DataAccess.Client.OracleException Data provider internal error(-3000)
  • Oracle.DataAccess.Client.OracleException : ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
It has also crashed my nunit application and the nunit-console processes that our continuous integration server launches has also crashed.
Searching for these errors have given several pointers where none was appropriate.

Today I finally found the source of the error. I used adplus to get a crash dump of the nunit process.
adplus -crash -pn nunit.exe

The adplus generated some dumps, log and a report. When I read the log I found a new error source. An AccessViolationError was thrown when oracle tried to enlist in the transaction.

Wed Jul 4 08:18:48.229 2007 (GMT+2): (c2c.9ec): Access violation - code c0000005 (first chance)
---
--- 1st chance AccessViolation exception ----
---------------------------------------------------------------

Occurrence happened at:
Debug session time: Wed Jul 4 08:18:48.229 2007 (GMT+2)
System Uptime: 0 days 16:37:08.859
Process Uptime: 0 days 0:01:37.803
Kernel time: 0 days 0:00:02.281
User time: 0 days 0:00:05.093

Faulting stack below ---
*** ERROR: Symbol file could not be found. Defaulted to export symbols for C:\WINDOWS\system32\msvcrt.dll -
# ChildEBP RetAddr Args to Child
WARNING: Stack unwind information not available. Following frames may be wrong.
00 04cbdcdc 77bbcfdb 003f0000 00000000 000000e0 ntdll!RtlRestoreLastWin32Error+0x235
01 04cbdcf0 77bba995 000000e0 00000000 0592a2f0 msvcrt!free+0x1a8
02 04cbdd04 04d46612 000000e0 00000000 06e0b228 msvcrt!operator new+0x24
03 04cbdd38 04ccc344 059468a0 0595e340 05918db0 ORAMTS10!kpntenlistctxget+0xe6
04 00000000 00000000 00000000 00000000 00000000 OraOps10w!OpsConEnlist+0x3b4
Here we can see that the ORAMTS10.dll is the source of the error. When I then googled on access violation ORAMTS10 I found the solution in the Microsoft forum where Sahra Parra already had debugged the same issue from another source.

The conclusion of the AccessViolation exception is that the ORAMTS10 contains a method that enlists the connection in the MTS. This method takes a parameter that contains the datasource name and when we pass a datasource longer than 40 characters, this results in that data in the heap is overwritten and resulted in a heap corruption.

Heap corruptions are hard to debug since the error don't show up when the data is written. The error surfaces when the corrupted data is read which explains that the error messages differs (or not surfaces at all).
In this case I got lucky and got an error in the ORAMTS10.dll that gave me a hint to the solution. To actually debug this issue and get error messages that occurs when the data is written, you have to use pageheap/gflag to let the error surface when the data is written.


To work around the bug in ORAMTS10 I only needed to change the Data Souce from the full (more than 40 characters) source name
Data Source=(DESCRIPTION=(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=TCP)(HOST=oracle.internal.com)(PORT=1521)))
(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)))

To the short version (requires a registration in tnsnames.ora)
Data Source=oracle

When changed, the crashes went away and I'm so happy ;)

2007-06-28

Documentator Macros version 2.5.1.0 released

For you who are using Visual Studio 2005, the DocumentatorMacros is released in version 2.5.1.
For more information about the macros, see
http://www.codeproject.com/csharp/documentatormacros.asp

The major reason for a new release is the support for restoring shortcuts after Resharper 3.0 has been installed. Apart from that, the new release only contains minor bugfixes and changes. See the included documentation for more information.

Since I just posted the update to codeproject, the latest version is not available there yet.
So in the meantime you can download it from here.

2007-06-20

AdobeUpdater.exe hangs and cannot be killed

Today I have been experiencing a problem with adobes AdobeUpdater.exe. It takes 100% cpu usage and cannot be killed. The only way to get rid of it is to reboot and even that don't always work. Sometimes a hard reset (a.k.a. da button) is the only effective solution.

Searched a bit and found several others to have the same problem.

Suggested solutions:
  1. Rename
    c:\program files\Adobe\Updater5\AdobeUpdater.exe
    to (for example)
    c:\program files\Adobe\Updater5\AdobeUpdater.exe.old
    This will prevent the AdobeUpdater.exe from running.
    ( tip from Nish Vamadevans blog)

  2. Uninstall Adobe acrobat reader and use another software (like Foxit)

  3. Create an own Adobe installation package using the Adobe customization wizard 8 where you don't include the AdobeUpdater. See Aaron Parker's stealthpuppy.com
Hopefully Adobe will release a patch for this, but so far (version 8.1) the issue has not been fixed.

P.S. I went for solution 2, since I already had foxit installed. D.S.

2007-06-12

Animals and Baboons explained

I have been doing some research on the Animal/Baboon generic issue.
First I posted a feedback on the Microsoft connect site and got some answers. This issue is referred as covariance.
Covariance, in a mathematical definition, refers to how much two random variables varies together.
Covariance, in this aspect, refers to on how you can assign two variables/types to each other. Normally (without covariance) we can only assign objects to variables that are part of their inheritance chain or cast up the inheritance chain.
For instance
AccessViolationException ax = new AccessViolationException();
//assign down the inheritance chain
Exception ex = ax;
//cast up the inheritance chain
ax = ex as AccessViolationException;
We can also cast/assign to other types, but then it is up to the object to handle the cast/assignment by implementing the explicit or implicit operators for each type that it should support.

When it comes to covariance, this is already implemented in the CLR and C# (like Java) uses covariance for its support on Arrays.
To illustrate this we can use our Animal/Baboon/List<T> example.
List<Animal> myAnimalList;
List<Baboon> myBaboonList;
myAnimalList = myBaboonList; //gives a compiler error
The code above gererated a compiler error since we cannot convert the Baboon List to an Animal List. Baboon inherits Animal but List<Baboon> does not inherit List<Animal> and thus cannot be assigned to each others. But what happens if we do the same with arrays?
Baboon[] myBaboons = null;
Animal[] myAnimals;
myAnimals = myBaboons; //this works!?
How is this possible? Baboon[] does not inherit Animal[]. All arrays inherits System.Array.
This is because System.Array uses Covariance in the CLR to allow such a structure. Observe that the opposite is not possible
myBaboons = myAnimals; //gives a compiler error

This is called Contravariant and is not used by Arrays.

For now there is no other object or class that uses co/contra-variance in C# but since the feature is included in the CLI, you could build an own C# compiler that supports it.
Microsoft will not include the support in C# v3 but according to Mads Torgersen they are "actively looking at supporting it in the next version of the language after that".
If you would like more reading on the subject, I can recommend the following sources that have given me much input.