Posts Tagged ‘.NET’

Vici Project support has moved to StackExchange

Wednesday, November 18th, 2009

We all love Stack Overflow, so when Joel Spolsky told the world that the platform would be made publicity available we move the Vici Project support to StackExchange.

All questions regarding Vici MVC, Vici CoolStorage, Vici Parser, Vici WinService and all other future Vici projects can be viewed and answered on http://vici.stackexchange.com.

The old http://support.viciproject.com URL will redirect you to the new support location.

GetHashCode() on a 32-bit vs a 64-bit platform

Friday, February 20th, 2009

If you compile your .NET application with the standard “Any CPU” option, it will run as a 32-bit process on a 32-bit OS and as a 64-bit process on a 64-bis process.

When you use GetHashCode() the generated hashes on the 32-bit platform will differ from the hashes on the 64-bit platform…

The solution is either to not use the GetHashCode() the way you do it, or if you can’t change the way your program works you can run it in 32-bit mode by setting the 32-bit flag in the executable’s headers using CorFlags.exe.

Set the 32-bit flag:CorFlags.exe YourApplication.exe /32BIT+

Remove the 32-bit flag:CorFlags.exe YourApplication.exe /32BIT-

More info about CoreFlags.exe on MSDN: http://msdn.microsoft.com/en-us/library/ms164699(VS.80).aspx

GetHashCode() in .NET 1.1 vs .NET 2.0

Thursday, February 19th, 2009

notepadd

When migrating GarageTV from .NET 1.1 to .NET 3.5 I ran in a “strange” problem.

It seems that there is a SearchBarrel table containing the links between keywords and posts (and some other info like keyword weight etc), so when a search is made you simply do a select using this table.

But… the keyword is hashed using String.GetHashCode() and that’s stored in the DB. Not clever it seems, because the GetHashCode() in .NET 2.0+ differs from the .NET 1.1 version.

Quote from MSDN: Prior to the .NET Framework version 2.0, the hash code provider was based on the System.Collections.IHashCodeProvider interface. Starting with version 2.0, the hash code provider is based on the System.Collections.IEqualityComparer interface.”

And for your information I’ve found an implementation of the GetHashCode() of the .NET 1.1 version, so you can use this method in .NET 2.0 projects.


Int32 HashString(String szStr)
{
ulong hash = 5381;

foreach (int ch in szStr)
{
hash = ((hash << 5) + hash) ^ (ulong)ch;
}

return (Int32)hash;
}

So… enjoy.

.NET Podcasts – Polymorphic Podcast

Thursday, October 9th, 2008

Since I’m cycling to work I should start using my MP3 player a little more. I came across Polymorphoc Podcast today and I think I’m gonna give it a try.

The busy jingle-jangle introduction during the first minute-and-a-half or so is annoying and I really dislike the voice of the host, but you can’t get everything like the way you want, eh!

Website: Polymorphoc Podcast
Feed: Podcast Feed