Archive for the ‘C# 2.0’ Category
Posted by jpluimers on 2012/06/26
Switching back and forth between mainly Delphi and C#, sometimes it is hard to remember which idiom works best in each environment.
Recently, I had to dupe a lot of tab characters for some Tab-Delimited interface to an archaic system.
I remembered the Delphi idiom: use the DupeString function as about Delphi explains (yes, I know: it dupes more than just characters).
In C#, these work best for me:
Small code sample of the first way (thanks CMS):
static string Tabs(int n)
{
return new String('\t', n);
}
–jeroen
via: .net – Best way to repeat a character in C# – Stack Overflow.
Oh BTW: I have reduced my StackOverflow presence. It looks like the success of StackOverflow made them instantiate many moderators. A lot of those moderators work under the mantra “we follow the rules strictly, and favour punishment over encouragement” (some even talk about “changing heritage“). That’s a real pity, as I see a lot of StackOverflow users get scared by the very active downvoting, question/answer closing and even deletion of material that is in essence valuable, if it were edited up a bit. Deleting content is always bad, as it increases the link rot that StackOverflow are trying to prevent in questions/answers as per their FAQ. Links are the foundation of the web.
Alas, devoting real attention to the quality of StackOverflow requires putting real energy in it, which for some of the moderators seems to be too much to ask.
Posted in .NET, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Delphi, Development, Pingback, Software Development, Stackoverflow | 5 Comments »
Posted by jpluimers on 2012/06/21
I’m in the midst of converting a suite of WinForms C# projects from a range of .NET versions (1.x till 3.x) to 4 totalling some million lines of code.
One of the problems is that some people hacked together some splash screen stuff using multi-threading, doing all sorts of things that was forbidden in .NET 1 (and broke in .NET 2+).
On my research list for getting this to work:
- Mahin Gupta | Winforms splash screen – Great work by Tom. which is an update of
- A Pretty Good Splash Screen in C# – CodeProject.
–jeroen
Posted in .NET, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, Development, Software Development, Visual Studio 2002, Visual Studio 2003, Visual Studio 2005, Visual Studio 2008, Visual Studio 2010, Visual Studio and tools, WinForms | Leave a Comment »
Posted by jpluimers on 2012/06/13
All .NET languages have a cool feature: enumerated types, for instance enum in C#, Enum in VB.NET, or the enum in the Oxygene language of Delphi Prism. You can even specify the underlying integral type.
It allows you to name values, which can make your code very readable.
It also allows you to assign an integer to each of those values, which allows you to map them to existing integers in the ‘real’ world. This is both a powerful and potentially uncool feature of enums (the other uncool feature is that though you can have bitflags in Enums, most .NET languages don’t have a Set type. You need Set Extensions to do things like Set operations on Card Suit bitflags using C# extension methods).
Because of my background in the 80s in MuSimp and Turbo Pascal, I’ve done quite a bit of enums and sets in the past, hence the mentioned C# enum extension methods mentioned above. While writing this article I also found out Extending’ the Enum Class to Validate the Enum Values with the Flags Attribute that mentions quite a bit of stuff that is complementary to my code and what you will see below.
The risk of assigning integer values on C# enum is that you can assign the same integer value to multiple enum elements.
For instance, this code will fail:
Read the rest of this entry »
Posted in .NET, C#, C# 2.0, C# 3.0, C# 4.0, Development, Prism, Software Development, VB.NET | Leave a Comment »
Posted by jpluimers on 2012/05/23
Yes. Dorothy. There are people using the ADO .NET Entity Framework with SQL Server 2000 in parallel of moving towards a more modern Microsoft SQL Server version.
Entity Framework is lovely for developing data-centric applications.
By default, Visual Studio 2010 will target SQL Server 2008 as a database. That is fine, but it is kind of invisible it does: there is no property or dialog where you can change this.
What you have to change in order to have the Entity Framework send SQL Server 2000 compatible queries is to:
- Right click your .edmx file
- Choose “Open with”
- Choose the “XML (text) editor”
- Find the ProviderManifestToken attribute
- Change the value (usually from “2008”) into “2000”
- Save the .edmx file
- Build and run your application
A few caveats:
Read the rest of this entry »
Posted in .NET, .NET ORM, C#, C# 2.0, C# 3.0, C# 4.0, Development, EF Entity Framework, Software Development, SQL Server, SQL Server 2000, SQL Server 2005, SQL Server 2008, SQL Server 2008 R2, SQL Server 2012 | Leave a Comment »
Posted by jpluimers on 2012/05/16
As a Delphi user, I’m missing the “Reverse Assignment” feature in the Visual Studio version of CodeRush.
Since CodeRush is very extendable (Mark is still explaining to people how the idea for that came from Delphi Packages back in the mid 90s), you can add this one yourself, as the a answer to this DevExpress support issue shows:
Q:
Is there a quick way to reverse the assignment in CodeRush? For example:
FROM:
Field[“test1”] = edTest1.Value;
Field[“test2”] = edTest2.Value;
TO:
edTest1.Value = Field[“test1”];
edTest2.Value = Field[“test2”];
I know Delphi had this capability in its refactoring, does CodeRush for Visual Studio?
Thanks
Daniel Schipper
Read the rest of this entry »
Posted in .NET, C#, C# 2.0, C# 3.0, C# 4.0, Development, Software Development, Visual Studio 2005, Visual Studio 2008, Visual Studio 2010, Visual Studio and tools | Leave a Comment »
Posted by jpluimers on 2012/05/10
To bad that Greg Beechs Blog only has “42 Entries” as those entries (from the start of 2006 till the end of 2009) are well worth reading on various .NET related topics.
–jeroen
via Greg Beechs Blog | Greg Beechs Website.
Posted in .NET, C#, C# 2.0, C# 3.0, Development, Software Development | Leave a Comment »
Posted by jpluimers on 2012/04/26
Some very interesting tips from game development that apply juts as well to general software development.
On code health:
Now I always try to dig right down to the root cause of a bug, even if a simple, and seemingly safe, patch is available. I want my code to be healthy. If you go to the doctor and tell him “it hurts when I do this,” then you expect him to find out why it hurts, and to fix that.
Though tools like SourceMonitor can help you track your code health, the best tool is between your ears.
–jeroen
via: Dodgy Coder: Coding tricks of game developers.
Posted in .NET, Batch-Files, C#, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Delphi, Delphi x64, Delphi XE2, Development, JavaScript/ECMAScript, PHP, PowerShell, Scripting, Software Development | 1 Comment »
Posted by jpluimers on 2012/04/24
While transitioning from SQL Server 2000 to 2008, I recently had the “A severe error occurred on the current command. The results, if any, should be discarded.” occurring on SQL Server 2000 in the form as shown at the bottom of this message.
Many of the search results point you into the area of atabase corruption, or in using NVARCAR parameters with SQL Server 2000 or SQL Server 2005 (the app didn’t use NVARCAR, nor did it use large VARCHAR parameters).
The cool thing on the SQL Server Forums – System.Data.SqlClient.SqlException: A severe error occurred on the current command post was that it summed up causes, and asked for more:
Posted – 06/17/2004 : 15:05:20
Rashid writes “Hi: Gurus I am getting these errors when I try to execute my application. According to MS knowledge base (http://support.microsoft.com/default.aspx?scid=kb;en-us;827366) these errors happen due to following resons
- You use a SqlClient class in a Finalize method or in a C# destructor.
- You do not specify an explicit SQLDbType enumeration when you create a SqlParameter object. When you do not specify an explicit SQLDbType, the Microsoft .NET Framework Data Provider for SQL Server (SqlClient) tries to select the correct SQLDbType based on the data that is passed. SqlClient is not successful.
- The size of the parameter that you explicitly specify in the .NET Framework code is more than the maximum size that you can use for the data type in Microsoft SQL Server.
None of these are true in my case. Are there any other reasons that can cause these problems..
There is one more: sending huge SQL Statements to your SQL Server is always a bad idea and gives this error too. Read the rest of this entry »
Posted in .NET, C#, C# 2.0, C# 3.0, C# 4.0, Database Development, Development, Encoding, Software Development, SQL Server, SQL Server 2000, SQL Server 2008 R2, Unicode | Leave a Comment »
Posted by jpluimers on 2012/04/18
Everytime I get a warning like
Warning 1 'System.Configuration.ConfigurationSettings.AppSettings' is obsolete: 'This method is obsolete, it has been replaced by ConfigurationManager.AppSettings'
it reminds me I should have written a blog post about it, as the solution is a tiny bit more than just replacing System.Configuration.ConfigurationSettings.AppSettings by System.Configuration.ConfigurationManager.AppSettings.
Scott Gate wrote a nice post on his old blog about this (his new blog is awesome, he really should import his old posts into his new blog) that explains how to solve this well, so below is an elaboration on the how of the change, a tiny trick and a short series of steps to resolve this warning.
First of all, the above message means you are touching code that has been written in the .NET 1.x era, and the maintaining people (you! <g>) have been too lazy to solve the warning. That is bad, as your code should compile without warnings, and preferably without hints too. Read the rest of this entry »
Posted in .NET, C#, C# 2.0, C# 3.0, C# 4.0, Development, Software Development | Leave a Comment »