Is there a .Net 1.1 compatible String.GetHashCode implemented in .Net 2.0 code? - .net-2.0

I have an existing app in which I made the mistake of using String.GetHashCode and persisting it to disk. Now that I'm upgrading the app to .Net 2.0 I find that that decision has come back to bite me in the butt.
I'm interested to know if anyone knows about a .Net 2.0 implementation of a .Net 1.1 compatible string hashing algorithm.
Obviously the best solution would be to buy myself a time machine and go back to 2002 and kick myself in the shin for even considering using the hashcode this way. Since that doesn't appear likely I'm looking for a workaround. I have existing users with this data on their systems so it's not possible for me to make one big conversion of the hashes or anything like that.
With the change to 2.0 I will update the code so it uses MD5 or SHA of course.
I considered extracting the String.GetHashCode source from Mono but since Mono is GPL and my app is commercial that really isn't an option. I don't even know if the Mono implementation is compatible with the MS .Net implementation since the contract for GetHashCode wouldn't require it to be compatible.
Any ideas?

You're not the only one, it seems: Getting .NET 1.1 CLR String Hash Codes In The .NET 2.0 CLR
That links to BackCompatibleStringComparer, which (allegedly, I can't verify) shows the implementation of the old GetHashCode().

Related

Are RecordSet Objects Deprecated In .Net 4.5?

Are RecordSet objects deprecated in the .Net 4.5 Framework? If so, is it possible to include them in a .Net 4.5 Framework project by referencing them?
From my reading, I understand them to be deprecated. I also understand that if your "target" framework is higher than that of the desired reference, the reference cannot be included in your solution (the IDE, e.g. Visual Studio 2013, will not allow the inclusion).
I am looking for a definitive, simple answer as none seem to be available elsewhere (though there are certainly troves of information on the web about RecordSet and DataSet). Again, my question is not how to use RecordSet, but rather whether it is deprecated and - if so - how to include in a .Net 4.5 Framework solution (which I am under the impression is not possible).
If you are able to attach any references, that would be awesome. I am either trying to prove me "wrong" or someone else "wrong".
Here is one of the references I have found that seems to suggest RecordSets aren't really a part of the .Net piece.
There has never been a type named "RecordSet" in the .NET Framework. That name was taken, a COM type that had its hay days in the 1990s. Part of DAO and ADO, COM object models that made it easy to access data. And found its way into plenty of .NET programs, stuck on data providers of the 1990s or injected by code originally written in VB6 or VBA, the most popular programming tools in the 90s.
No, it is alive and well, ADO is not deprecated. DAO got the axe 13 years ago when Jet was removed from the standard distribution. Albeit that it seems to be not quite dead, it is still included with every current Windows version. Microsoft code never dies. COM interop in .NET 4.5, what you use under the covers to consume the ADODB type library, has not changed at all.
There was an ill-fated attempt to make ADO more compatible with 64-bit code, fixing a bug in the type library. Released in Windows 7 SP1, it caused wide-spread dismay and misery so was canceled again. Hopefully you don't have that viral problem.
Otherwise typical of software, it is not like fine wine, it does not age gracefully. Still using Recordset today does not make sense, you'd at least consider uplifting to the System.Data.Oledb namespace. Which is the managed .NET wrapper around ADO.

Generate automatic logs when entering and exiting functions .net 2.0

I am using .net 2.0. I want to generate the logs when the methods are calling (before call and after call) in a particular class. Is it possible in Enterprise Library 2.0 or log4net? or Is there any other way?
The simplest approach would of course be to just add code to each method. I assume that you do not want to do that.
You should be able to accomplish this with the Policy Injection Application Block, introduced in Enterprise Library 3.0 or the Unity Application Block, introduced in Enterprise Library 4.0. I don't think there is anything built into Enterprise Library 2.0 that would be helpful. I have never used log4net, but I doubt that it has any features that would help either.
You could also look into aspect oriented programming tools, like PostSharp.
Here is an article on how to accomplish this with Unity.

An Entity Framework equivalent for .Net Compact Edition?

Since Entity Framework does not run in .Net Compact Edition is there any compatible alternatives I can take a look at?
*I'm especially looking for something I can use on Windows Mobile 6.1.
Depends on what you mean by "compatible". You mean a compatible object model? Nothing that I'm aware of, but then EF is huge and if you found something it would probably perform terrible anyway. If you're simply after an ORM that can be used on multiple platforms, the OpenNETCF ORM works fine under Windows Mobile and Windows desktop (plus Mono for iOS and Android to boot). In fact it was first written for Windows CE, so it works rather well for WinMo.

Best .NET Framework 2.0 book for C#, Libraries?

I am an senior-slash-"advanced" C#/.NET developer, currently using 3.5 Framework with WPF/WCF and Silverlight (WPF/E). I have come up right through 1.0 and 2.0 and so am well versed with the evolution of .NET. My next project could be "back" into 2.0 Framework, but with enough complexity (and time pressure) so as to call on "expert" skills, not just "advanced" ones.
Thus I am looking for a book with comprehensive coverage of the 2.0 Framework, primarily the organization and use of the libraries (by which, yes, I really just mean "the Framework"...) available in that rev. I want to have a complete, organized reference on hand for what tools are available in the box, so to speak, to choose the right ones at each step and not re-invent any wheels.
I own and love "CLR via C#", but this isn't a question about the CLR, it's about libraries (Framwork) primarily, and also interfacing techniques to .NET-supported related products.
If I "subtract out" my existing 3.0/3.5 knowledge/experience, I might say that I've only ever thoroughly investigated and used some 50-75% of the 2.0 Framework - so what I'd like to see is an authoritative guide to the full 100%. Doesn't need rigorous details or comprehensive examples, but rather a full assessment of scale and scope to be able to design and implement effective solutions in .net 2.0 "the right way".
C# 3.0 in a Nutshell covers parts of the framework in sufficient detail. I find it to be a very useful book to have around.
Programming Microsoft Visual C# 2005: The Base Class Library specifically covers the framework, but in my opinion the Nutshell book is better and you can always find additional information on MSDN.
Windows Forms Programming in C# covers WinForms in detail, or you may want to look at Chris Sells' book on WPF instead. I'm not familiar with the latter, but the first is okay.
It sounds like you have a good grasp on C# itself, so you probably want to know what was in 2.0 that isn't in 3.0 or 3.5. For this reason, you might be interested in some of the following resources, namely the C# 2.0 standard:
ECMA C# 2.0 Standard
C# 2.0 - The Complete Reference
Any of the C# books by Apress
I particularly like the C# 2.0 Complete Reference book, and keep a copy on my desk at home, but the C# 2.0 standard is incomparably good as well; it's just a question of whether you can stay awake long enough to get through any of it. :)
For WinForms programming, the book that has proved itself most useful to me is Windows Forms 2.0 Programming. If there isn't a single book that has everything you're looking for, I think this book would be part of the collection comprising the next best thing.

Help me convince higher-ups to allow switching to .Net 3.5 (from 2.0)

I have been sold on the fun of using linq in areas other than pure database interaction. (See Calling fellow code nerds - Alternatives to Nested Loops?).
We are stuck on 2.0. I have told the powers that be about the ease of updating to 3.5 (we have already migrated to VS2008) but they are wanting a list of "benefits" for upgrading.
Can those that have experience in 3.5 help provide some talking points for the benefits of updating an existing app to 3.5?
UPDATE: Found an additional reason: Microsoft's inclusion of Charting tools for Asp.Net as a patch on top of 3.5! They get their business value, I get the fun...
Can YOU make a case for it? Sounds like you want it because LINQ is fun. Other people are mentioning features that are fun. I've always had a problem selling fun features to management because they aren't very compelling reasons to potentially disrupt an environment.
Honestly, it really depends on what you are using C# for. Are you a web developer, system admin, something else? Taking a general approach, I would use the following selling points (you will need to do some work to prove these things):
Zero-disruption for end-users when upgrading. Upgrading to the new version will be seamless and we will have a thoroughly reviewed test plan for updating all clients to this version. All of our old applications that require .NET 1.x or .NET 2.0 will still work perfectly.
Programmer Efficiency. You could mention how more of the Windows API is wrapped by .NET classes, thus making programmer more efficient because they don't have to P/Invoke as much. LINQ makes your more productive because of x, y, and z. Lambda expressions make you more productive because of x, y, and z.
Ease pains of future OS migration. Moving to WPF now will prepare us for Vista/Windows 7. We won't have to migrate applications using the now deprecated "Windows Forms" to WPF, because we will already be using it.
More applications purchased from 3rd parties will require it, so we will have to upgrade sooner or later.
In the end, you need to prove that at the very least, this move will not cost you money in terms of increased support or testing costs. If you can show it will make you be more productive and it will be a rather painless switch, then you will get your wish.
Maybe you should talk to some Java developers who are probably still forced to develop using 1.3 or 1.4 despite 1.5 being out for over 3 years and 1.6 for a couple... it appears platform consistency across the business is often of greater importance than the benefits of using the latest and greatest.
Also remember that 3.5 is just additional BCL libraries. You are still running on CLR 2.0. Same is true for 3.0. Usually when people find out that the underlying framework is the same and that you are just adding in new libraries they are more likely to go along with it.
You don't need .NET 3.5 to get LINQ or C# 3.0 features. You can implement your own LINQ for .NET 2.0. I am using C# 3.0 all over the place in my .NET 2.0 application. I don't know the full details on how to start the conversion process because I didn't set it up myself. This might be a good link for you: http://www.danielmoth.com/Blog/2007/05/using-c-30-from-net-20.html.
http://msdn.microsoft.com/en-us/library/ms171868.aspx
Transitioning onto 3.5 would help you reap the benefits/ features of:
LINQ to (Entities/ XML / Objects / Datasets etc ).
WCF, WF and WPF.
ASP.net MVC where MVC is kind of a de facto standard in other
platforms like Ruby/Python which
allow you pure HTML/ Javacript based
development.
ORM options with ADO.net Entity
Framework/ Linq to Sql
4.
With a few addons you can have
support for dynamic languages
like
IronPython/IronRuby.
Oh ya I almost forgot ADO.net Data Services..one of my fav.
These are the few benefits that immediately come to my mind.
In my experience, the addition of LINQ and Extension methods alone have made many previously arduous and/or time consuming tasks much easier and faster. The increased developer productivity from that alone is worth the upgrade effort IMHO.
Lambda expressions are awesome. There is no end to the places where I find that lambda expressions help me out in a very concise and readable way.
Automatic properties, while being a simple concept, really help making the code base smaller and clearer.
Also, I sencond the extension methods.
Before I even opened this question I had my answer: LINQ - it's one of the greatest extensions ever in .NET - I love it. It took me a few days to figure out, but now I've got it, I use it all over the place. The ability to query collections and arrays is worth the upgrade alone in my mind.
Decreased development time (and therefore increased ROI)
Less time wasted finding workarounds for .NET bugs that've been fixed in newer releases.
Extension methods for native types (in a similar fashion to JavaScript prototyping)
LINQ extensions - they take a couple of days to get your head around, but it's awesome!
LINQ to XML makes working with XML so much simpler
LINQ to objects/collections
A nice new 3.5 poster from Microsoft that you can pin up in your cubicle.
As a manager if I have a happier more productive team that is producing more in less time, then its a no brainer.
Ask yourself this: Will the developers be more effective and will their increased productivity actually increase benefit to the company or reduce corporate costs once you've considered the upgrade/transition/installation on the servers/additional testing etc? If the answer is truly yes, then do the upgrade and quit arguing about it.