2007-11-26
Task failed because "sgen.exe" was not found
C:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets(1993,9):
error MSB3091:
Task failed because "sgen.exe" was not found, or the correct Microsoft Windows SDK is not installed. The task is looking for "sgen.exe" in the "bin" subdirectory beneath the location specified in the InstallationFolder value of the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v6.0A. You may be able to solve the problem by doing one of the following:
1) Install the Microsoft Windows SDK for Windows Server 2008 and .NET Framework 3.5.
2) Install Visual Studio 2008.
3) Manually set the above registry key to the correct location.
4) Pass the correct location into the "ToolPath" parameter of the task.
I thought that the SDK was to be installed with VisualStudio 2008, but when looking into the SDKs folder (C:\Program Files\Microsoft Visual Studio 9.0\SDK) it contains almost nothing, only a few files in the v3.5 folder.
When I searched for the SDK for framework 3.5 it seems that is included in the windows server 2008 platform sdk and that is only avaliable for beta2 so far...
Regarding the registry settings, I have the SDK for v2.0 installed and since I build vs the 2.0 framework, shouldn't it look in the KEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v2.0 key?
How do I set the ToolPath?
Anyway, I came around the issue by setting the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v6.0A InstallationFolder key to the same path as the 2.0 Sdk path and compilation was successful...
Is the VisualStudio 2008 release not final since it seems to miss the SDK or have I been sloppy installing the product?
Signing a ClickOnce manifest file using a spc/pvk certificate
To sign a ClickOnce manifest file/assembly you need a pfx file without chaining information.
First we need to convert the spc/pvk file to a pfx file. As Stuart found out you use the pvk2pfx tool to accomplish this.
If we try to use this certificate and it contains chaining information we will get an error stating
Then we need to make sure that the pfx don't include the chaining information as described in the case @ commodo (importing and exporting the pfx).
When these steps has been completed, you can build and sign your application.
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
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
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.43222. Make sure the needed framework is installed in the IIS
2007-09-12 08:44 <dir> v2.0.50727
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 applicationIn 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 mappingC:\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 poolsA 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
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
- 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
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.
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.
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
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 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.
Suggested solutions:
- 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) - Uninstall Adobe acrobat reader and use another software (like Foxit)
- 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
P.S. I went for solution 2, since I already had foxit installed. D.S.
2007-06-12
Animals and Baboons explained
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();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.
//assign down the inheritance chain
Exception ex = ax;
//cast up the inheritance chain
ax = ex as AccessViolationException;
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;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?
List<Baboon> myBaboonList;
myAnimalList = myBaboonList; //gives a compiler error
Baboon[] myBaboons = null;How is this possible? Baboon[] does not inherit Animal[]. All arrays inherits System.Array.
Animal[] myAnimals;
myAnimals = myBaboons; //this works!?
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.
2007-06-08
Why I ever left Unix (swedish only, sorry)
Lyssna på denna för att få svar på frågan...
Download
2007-06-07
Are Baboons Animals (in a generic sense)
Say that you declare an Animal class
public class Animal {
public Animal(string division, string className,
string order, string family, string genus){}
}
And then we declare the Baboon...
public class Baboon : Animal {
public Baboon() :
base("Chordata","Mammalia","Primates",
"Cercopithecidae","Papio") {}
}
All is well, a standard object inheritance (even one with an anchor in the real world (oh yeah!), and a scientific twist (bring it on!))
Now we would like a generic collection for the animals that only can take animals.
public class BaseAnimalCollection<T> : List<T>
where T : Animal{}
Cool, now this type of collection can contain all sorts of animals and we could add methods common to all animal life, like... like... well, Clone and Exterminate are the first that comes to mind... (think I should read something more than scientific magazines to broaden my horizon?)
Anyway...
We start using the collection
BaseAnimalCollection<Animal> myAnimalCollection =
new BaseAnimalCollection<Animal>();
Here we can put som animals in...
We can also specify a collection that only can contains Baboons (if we want to use the common animal functionality that is provided with the collection (Clone and Exterminate ;)
BaseAnimalCollection<Baboon> myBaboonCollection =
new BaseAnimalCollection<Baboon>();
The strength with generics is that we can, with little effort (code), create a typed collection that behaves as a collection should and we don't need to fear any runtime nuisances since the type checking is done in compilation time.
So when I would like to create my best of animal collections (everyone has these nowadays) I just create a typed collection and add on...
BaseAnimalCollection<Animal> myBestAnimalCollection =
new BaseAnimalCollection<Animal>();
//add some animals
myBestAnimalCollection.Add(new Animal(
"Arthropoda", "Arachnida", "Acarina.Parasitiformes",
"Ixodoidea", "Amblyomma"));
//add a Baboon !!!
myBestAnimalCollection.Add(new Baboon());
//even add my own list of animals to the list.
myBestAnimalCollection.AddRange(myAnimalCollection);
So far all is good. Now I want to add my baboon list to the best of collection. Since Baboons are animals (and I have already added a Baboon to the list) this should be ok . So we add the code below.
myBestAnimalCollection.AddRange(myBaboonCollection);
Now we get two compilation errors...
The best overloaded method match for 'System.Collections.
Generic.List.AddRange(System.Collections.Generic.
IEnumerable)' has some invalid arguments
Argument '1': cannot convert from 'BaseAnimalCollection'
to 'System.Collections.Generic.IEnumerable'
Why is this? Why can't we convert from a collection of Baboons to a enumerable of animals? Aren't Baboons animals when it comes to Generics or what?
Give me your best shot.
Good luck!
/Dan
2007-06-05
Writing a resource manager for System.Transactions
I wrote a simple class that implemented the ISinglePhaseNotification interface and tried it. At first it seemed to work like a charm, but then I got these strange behaviors.
I wrote a little test that enlisted the resource manager in a transaction, and when the transaction was completed, checked the Commited flag (that I set when the IEnlistmentNotification.Commit has been finished).
MyResourceManager rm = new MyResourceManager();
using (TransactionScope s = new TransactionScope()) {
rm.Enlist();
s.Complete();
}
Assert.AreEqual(true, rm.Committed);
The problem is that the test don't always succeed. This seemed like a school example for a resource manager
- create one
- enlist into the transaction
- mark the transaction as complete
- end the transaction
- validate that the resource manager has been committed.
This behavior has to work since after a transaction ends, I need to update/change the data of the objects in the system and they need to be available immediately after the TransactionScope has ended.
I hope this only is configuration issue and that I have missed some central issue regarding Resource managers and Transactions. Please enlighten me...
I post the complete test code below for you to use to reproduce the test. You'll see that the Assert will never work since the Commit will not be set at once but only after a small timeout (2 sec).
If I run the test with the Assert commented i will receive the following output.
TransactionScope BEGIN
IEnlistmentNotification.Prepare
IEnlistmentNotification.Commit BEGIN
TransactionScope END
IEnlistmentNotification.Commit END
And this illustrates the problem. The transaction scope is ended before the commit has been completely done.
Has someone some ideas?
Regards
/Dan
using System;
using System.Threading;
using System.Transactions;
using NUnit.Framework;
namespace OneProcess {
[TestFixture]
public class Test2 {
[Test]
public void OnlyLocalTest() {
MyResourceManager rm = new MyResourceManager();
Console.WriteLine("TransactionScope BEGIN");
using (TransactionScope s = new TransactionScope()) {
rm.Enlist();
s.Complete();
}
Console.WriteLine("TransactionScope END");
Assert.AreEqual(true, rm.Committed);
Thread.Sleep(3000);
}
public class MyResourceManager
: ISinglePhaseNotification {
public bool Committed = false;
public void Enlist() {
if (null != Transaction.Current) {
Transaction.Current.EnlistDurable(
Guid.NewGuid(), this,
EnlistmentOptions.EnlistDuringPrepareRequired);
}
}
void ISinglePhaseNotification.SinglePhaseCommit(
SinglePhaseEnlistment singlePhaseEnlistment) {
Console.WriteLine(
"ISinglePhaseNotification.SinglePhaseCommit");
Committed = true;
singlePhaseEnlistment.Committed();
}
void IEnlistmentNotification.Commit(Enlistment enlistment) {
Console.WriteLine(
"IEnlistmentNotification.Commit BEGIN");
Thread.Sleep(2000);
Committed = true;
enlistment.Done();
Console.WriteLine(
"IEnlistmentNotification.Commit END");
}
void IEnlistmentNotification.InDoubt(Enlistment enlistment) {
Console.WriteLine("IEnlistmentNotification.InDoubt");
enlistment.Done();
}
void IEnlistmentNotification.Prepare(
PreparingEnlistment preparingEnlistment) {
Console.WriteLine("IEnlistmentNotification.Prepare");
preparingEnlistment.Prepared();
}
void IEnlistmentNotification.Rollback(Enlistment enlistment) {
Console.WriteLine("IEnlistmentNotification.Rollback");
Thread.Sleep(2000);
enlistment.Done();
}
}
}
}