The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,861 other subscribers

Archive for the ‘.NET’ Category

Known #VS2010 issue + workaround: Visual Studio 2010 crashes when trying to edit a macro or record a temporary macro (via: Microsoft Connect)

Posted by jpluimers on 2012/07/03

Vsaenv: Cannot find one or more components. Please reinstall the application.One of my Visual Studio 2010 VMs gives me an error when recording a temporary macro:

---------------------------
Vsaenv
---------------------------
Cannot find one or more components. Please reinstall the application.
---------------------------
OK
---------------------------

Followed by: Read the rest of this entry »

Posted in .NET, Development, Software Development, Visual Studio 2010, Visual Studio and tools | Leave a Comment »

Visual Studio and Delphi: Getting a new GUID in the code editor

Posted by jpluimers on 2012/06/28

Earlier this week, I already wrote about different idioms in different IDEs.

Here is another one, again a feature I don’t use often: getting a fresh GUID in the IDE. Read the rest of this entry »

Posted in .NET, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Delphi, Development, Software Development, Visual Studio and tools | 7 Comments »

C# Remove Duplicate Lines From Text File? – Stack Overflow

Posted by jpluimers on 2012/06/27

Recently I had to do a quick removal of duplicate lines in bunch of text files.

A quick search revealed that back in 2009, John Skeet came to the rescue with a couple of examples (:

--jeroen

via: C# Remove Duplicate Lines From Text File? – Stack Overflow.

Posted in .NET, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Development, Jon Skeet, Software Development | 1 Comment »

Repeating characters into strings in C# and Delphi (via: .net – Best way to repeat a character in C# – Stack Overflow)

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 »

.NET/C# – WinForms splash screen research material

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:

  1. Mahin Gupta | Winforms splash screen – Great work by Tom. which is an update of
  2. 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 »

Direct Visual Studio 2012 RC and Windows 8 Release Preview ISO download URLs

Posted by jpluimers on 2012/06/20

Somehow many software vendors seem to make it a sport to make it hard to get download URLs.

So here is a bunch of direct download URLs for the (almost new <g>) Visual Studio 2012 RC (formerly and internally known as Visual Studio 11).

There are both ISO files (big, but convenient for offline installation).

Visual Studio 2012 (formerly VS11) ISO downloads
Edition Download page Download binary
Ultimate http://go.microsoft.com/fwlink/?LinkId=247147 http://download.microsoft.com/download/6/9/7/697096F6-4EEA-4704-AF2D-F3BAF57C7634/VS2012_RC_ULT_ENU.iso
Premium http://go.microsoft.com/fwlink/?LinkId=247144 http://download.microsoft.com/download/4/D/6/4D602B41-DFB6-4350-89CD-DC78B0C06996/VS2012_RC_PREM_ENU.iso
Professional http://go.microsoft.com/fwlink/?LinkId=247141 http://download.microsoft.com/download/0/B/2/0B29F8C6-C2C7-4187-A792-BDBAFB1802ED/VS2012_RC_PRO_ENU.iso
Test Professional http://go.microsoft.com/fwlink/?LinkId=247152 http://download.microsoft.com/download/F/A/D/FAD0D06E-A8BA-40D4-8F12-FE94A153EB85/VS2012_RC_TESTPRO_ENU.iso
Express For windows 8 http://go.microsoft.com/?linkid=9810160 http://download.microsoft.com/download/A/7/C/A7C0FFAF-E8D6-45F9-8820-0A7972DF5683/VS2012_RC_WinExp_ENU.iso

Web installers (depending on the choose install options, the total download can be a lot less than the complete ISO, but your system needs to be online during the full installation process).

Visual Studio 2012 (formerly VS11) ISO downloads
Edition Download page Download binary
Ultimate http://go.microsoft.com/?linkid=9810263 http://download.microsoft.com/download/6/9/7/697096F6-4EEA-4704-AF2D-F3BAF57C7634/vs_ultimate.exe
Premium http://go.microsoft.com/?linkid=9810243 http://download.microsoft.com/download/4/D/6/4D602B41-DFB6-4350-89CD-DC78B0C06996/vs_premium.exe
Professional http://go.microsoft.com/?linkid=9810223 http://download.microsoft.com/download/0/B/2/0B29F8C6-C2C7-4187-A792-BDBAFB1802ED/vs_professional.exe
Test Professional http://go.microsoft.com/?linkid=9810304 http://download.microsoft.com/download/F/A/D/FAD0D06E-A8BA-40D4-8F12-FE94A153EB85/vs_testprofessional.exe
Express For windows 8 http://go.microsoft.com/?linkid=9810150 http://download.microsoft.com/download/A/7/C/A7C0FFAF-E8D6-45F9-8820-0A7972DF5683/win8express_full.exe

You can find similar Windows 8 Release Preview download links here (they were distilled from the official download page, which now gives a 404 because of the atdmt link redirect is broken).

I use the x64 and x86 shortcuts for the x64 and x86 ISO links.

The Windows 8 Release Preview Upgrade Assistant also comes in handy.

The above links give a sustained transfer rate here of at least 3 megabit/second.

–jeroen

Posted in .NET, .NET 4.5, C#, C# 5.0, Development, Power User, Software Development, Visual Studio 11, Visual Studio and tools, Windows, Windows 8 | Leave a Comment »

Strong name for Interop.Scripting – .NET Framework

Posted by jpluimers on 2012/06/20

So I won’t forget:

I was trying to generate from the interop.scripting.dll which I guess was the automatically generated dll without strong naming. A wrapperof a wrapper apperently doesnt work.
The following did work:

tlbimp.exe C:\WINDOWS\system32\scrrun.dll /keyfile:..\nameHere.snk /out:Interop.Scripting.StrongNamed.dll

The suite of .NET projects I’m refactoring relies in part on scripting in the Microsoft Script Runtime because the original was build by people bringing their COM love from the VB6 world into the .NET world.

I don’t see COM as the first class citizen it was in the VB6 era. On the other hand, COM and ActiveX play an important role in the .NET world. Sometimes I regret that, as dealing with COM is hard.

Some consider COM a first class citizen in .NET as it was in VB6, especially after the dynamic keyword was added in C# 4.0. The variant type available since Delphi 2 since 1996 does more or less the same as dynamic keyword in C#. I know how Anders Heijlsberg disliked the Delphi Variant support of COM. But COM is what the market wanted in 1996, and that seems true until today.

But I digress.

At least parts of the .NET code needs to become strongly named, so I’m hesitating:

  1. kick out the COM stuff – and verify through unit tests that the encompassing code still works – or
  2. generate a strongly named COM Interop Wrapper as described above.

Not sure yet.

Opinions anyone?

Anyway, I’m expecting a few problems here and there, so I’ll be using the CLR Interop Tools like the P/Invoke Interop Assistant and Type Library Importer in Managed Code where needed.

–jeroen

via: Strong name for Interop.Scripting – .NET Framework.

Posted in .NET, C#, Delphi, Development, Software Development, VB.NET | 1 Comment »

TFS – Undelete File or Folder – brilliantly easy from the Visual Studio IDE: just enable “Show deleted items in the Source Control Explorer”

Posted by jpluimers on 2012/06/19

Never knew it was so brilliantly easy to undelete files from TFS: you can do it in Visual Studio, by enabling “Show deleted items in the Source Control Explorer” in the settings.

Just look at TFS – Undelete File or Folder for the screen shots.

Not sure in which Visual Studio version this got introduced, but it works in VS 2010 and up.

–jeroen

Posted in Development, Software Development, Source Code Management, TFS (Team Foundation System), Visual Studio 11, Visual Studio 2010, Visual Studio and tools | Leave a Comment »

.NET Enums enumerated: System.ArgumentException was unhandled by user code Message=An item with the same key has already been added.

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 »

.NET/C#: reading/writing Excel workbooks and worksheets

Posted by jpluimers on 2012/06/06

Basically there are many ways to read/write Excel workbooks and worksheets:

  1. Use the open source EPPlus .NET assembly (which is based on ExcelPackage)
  2. Use the open source ExcelLibrary which seems to be derived from PHP ExcelWriter
  3. Use OleDB to read/write Excel with either the JET (Office <= 2003) or ACE (Office +> 2007) drivers
  4. Use COM/OleAutomation/Interop/VSTO

The latter is used by many many people, and has two big drawbacks:

  • it requires Excel to be installed
  • it is painfully slow

The others can run server side as they do not require Excel to be installed. They are also much faster.

I’ve used OleDB, and it is sort of OK, but hard work.

EPPlus is much faster and versatile and seems to be the most active open source project.

–jeroen

Posted in .NET, .NET 4.5, ASP.NET, C#, Development, Excel, Office, Software Development | 2 Comments »