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

c# – Panel.Dock Fill ignoring other Panel.Dock setting – Stack Overflow

Posted by jpluimers on 2011/11/08

Every once in a a while I do WinForms development. On the .NET platform it still is the best way to create simple business applications that just, well: work.

WinForms apps are not fancy, but the actual users don’t care much, as long as they can their daily work done. They love fanciness of their mobile devices, but for stuff they use 8 hours a day, they just want something that works quickly, well and easily. So WinForms for a baseline is good.

WinForms historically has had two ways of automatically: Anchors and Dock (.NET 2 introduced another way using FlowLayoutPanel and TableLayoutPanel, but often they make things more complicated than needed).

One of the pitfalls of Docking is when you set Dock to Fill. Sometimes the affected control will be too large.
Every time that happens, I am baffled, as .NET is the only platform with that behaviour; I use other platforms too, and they don’t have this docking peculiarity (of course the have others, that’s the fun of using multiple platforms <g>).

The solution is simple:

  1. Right click on the control that misbehaves
  2. Choose “Bring to Front”
Done :)

–jeroen

Via: c# – Panel.Dock Fill ignoring other Panel.Dock setting – Stack Overflow.

Posted in .NET, C#, C# 2.0, C# 3.0, C# 4.0, Development, Software Development, VB.NET, WinForms | 2 Comments »

Using InputBox in C#

Posted by jpluimers on 2011/11/03

Sometimes you just want to ask a user for a simple string of input.

The InputBox function is an easy way to do do this. It has a tiny issue with the icon (it uses the one that belongs to the application installation, not the icon in the project properties).
InputBox has been part of Visual Basic since the 90s. And it is very easy to use from C# and other .NET languages:

  1. Add the Microsoft.VisualBasic assembly (which has been part of the .NET FrameWork since it first got released)  to your solution
  2. Make a call like
    Microst.VisualBasic.Interaction.InputBox("Did you know your question goes here?","Title","Default Text");

Sometimes you have to look a bit further than your regular toolbox for simple solutions.
I should dig up my 2006 session on the My Object in Visual Basic:  that is also very easy to use in C#.

–jeroen

via: Input Message Box in C#?.

Posted in .NET, C#, C# 2.0, C# 3.0, C# 4.0, Development, Software Development, VB.NET, VBS | Leave a Comment »

.NET/C# WinForms: simple solution to Panel.Dock Fill ignoring other Panel.Dock setting – Stack Overflow

Posted by jpluimers on 2011/11/02

It has been a while, but I have done some WinForms maintenance on business apps. For those kinds of apps, WinForms still is a productive environment, apart from one thing:

When you have a Dock of Fill, sometimes that control fills more than it should.

The reason is the order in which things are being calculated.

I always forget the trick, as other very productive environments for writing business apps don’t have this peculiarity (they have others, life is full of interesting peculiarities <g>).

Simple solution:

  1. Right-Click on the control that has Dock=Fill
  2. Choose “Bring to Front”

Now it fills exactly the wanted area :)

Thanks Jeff Cuscutis for posting this concise solution.

–jeroen

Via: c# – Panel.Dock Fill ignoring other Panel.Dock setting – Stack Overflow.

Posted in .NET, Development, Software Development, WinForms | Leave a Comment »

Jon Skeet and Tony the Pony on Vimeo

Posted by jpluimers on 2011/10/26

This is from 2009, but still sooooo funny.

Lets use these 2 thumbs as parity bits.
I should have done this with pounds and pounds.
Why doesn’t John Skeet does never sleep.
No, you can’t have Visual Studio … yes telepathy is fine.

And more great quotes, sample code and experiences (like the Turkey Test) in this wonderful presentation by Jon Skeet and the famous Tony the Pony
[Wayback] Jon Skeet and Tony the Pony on Vimeo on Vimeo

Hilarious, and true :)

--jeroen

via Jon Skeet and Tony the Pony on Vimeo.

Posted in .NET, Development, Jon Skeet, Pingback, Software Development, Stackoverflow | Leave a Comment »

.RESX translation and tools examples based on Paint.NET Forum -> Translation and Localization

Posted by jpluimers on 2011/10/20

The process of translating RESX files is time consuming, so it is wise to study a good example before starting such a journey.

Paint.NET (driven by Rick Brewster) happens to have great (and complete!) translations serving as great )ample materia.

So below are steps that you can use to get started.

The process

Create good Base RESX files

The first step is to create good .RESX files for your base language. This alone is a tedious process in itself, as for all the strings (and potentially other resources) used in your application, you need to determine if they should be translated. If so, you should make a key for each one, put them in the appropriate .resx file, and access it. The MSDN documentation explains how.

Use version control and differencing/merging/syncing tools

When translating software, you not only have the history axis, but also a language axis. That combination makes it much harder to keep everything, so a good version control together with good differencing tools is very handy.

I’ve had good experience with Team Foundation Server, Subversion (SVN), Git, and Mercurial (Hg), but less good experience with StarTeam, Visual SourceSafe and Serena Dimensions.

Beyond Compare is my favourite tool of choice for comparing files and managing with differences, merges and syncs.

Translate the RESX files

This is the really hard part; many translation agencies are specialized in this, companies have complete teams working on it (for instance, the Microsoft Developer Devision did the Paint.NET translation for 4 years in their free time).

Often, it helps to generate Excel or Word documents from the RESX files, but often translation deportments or agencies can handle RESX files fine.

Usually, there is much more to do than just translating, you should look at the whole internationalization picture, for instance by reading Guy Smith Ferriers book on .NET internationalization.

Verify the RESX files are complete and valid using ResxCheck

A important requirement of translation is to make sure the translated resources are at least technically valid and complete.

Doing that by hand is a very tedious job. Luckiliy, Rick Brewster (yes the Paint.NET one) wrote a great Resx tool to do just that.

An example is below.

Compile the RESX files into .resource and assembly files

When your RESX files are ready to be tested, you need to generate .resource files from that and sometimes resource assemblies.

You can use ResGen to generate resource files, and the Assembly Linker to link the resource files into assemblies, or generate sattelite assemblies.

Using the resources

I won’t go into much detail here, as there are many ways to use the translated resources.

The tooling

There are many tools you can use, and the actual use highly depends on the size of your project, the number of translations, and how your process is organized.

I’ll point to a few tools that are interesting or that I have used.

The Bing Translation API

Now that the Google Translate API has been deprecated, the only online translation API is the Bing Translate API provided by the Bing Translator team. There are plenty of examples on how to do that from various environments.  You need a Bing AppID in order to use this. And you can do “only” 50 translations per minute (each at a maximum of slightly less than 64 kilobyte).

Examples

I downloaded the Dutch 3.10 translations of Paint.NET because it includes an Excel document that is a good example of how to track progress or compare multiple translations.

Then I downloaded the Paint.NET 3.5.x original strings, and the Dutch 3.5.x translations and unpacked them in the C:\TEMP directory.

Finally, I ran the ResxCheck on them:

C:\temp\PaintDotNet.Strings.3.NL>ResxCheck.exe ..\Strings\Strings.resx PaintDotNet.Strings.3.NL.resx
ResxCheck v3.30.3033.25892
Copyright (C) 2008 dotPDN LLC, http://www.dotpdn.com/

--- Start @ 13:46:01
Analyzing base Strings.resx ...
Analyzing mui PaintDotNet.Strings.3.NL.resx ...
--- End @ 13:46:02 (156.25 ms), processed 2 resx files
There were no errors

Hopefully this will save you some time, and me too when I’m working on another translation project.

–jeroen

via: Paint.NET Forum -> Translation and Localization.

PS: If you want the Paint.NET installer to be multi-lingual, follow these steps on the Paint.NET forum.

PS2: For the people wondering why the Dutch language is not called Nederlandisch or something similar, please read the Wikipedia articles on  Names for the Dutch language and Netherlands (terminology).

Posted in .NET, Development, RESX, Software Development | 2 Comments »

process – How to check if a program is using .NET? – Stack Overflow

Posted by jpluimers on 2011/10/18

Many processes use or host the .NET run-time.

For Microsoft implementations of the CLR, this is a quick trick of listing them:

tasklist /m "mscor*"
tasklist /m "clr.dll"

The first statement lists all processes that use or host .NET 1.x through 3.x.
The last statement lists all processes that user or host .NET 4.0

On my system, this is the output:

C:\Users\jeroenp>tasklist /m “mscor*”

Image Name PID Modules
========================= ======== ============================================
explorer.exe 1696 mscoree.dll, mscoreei.dll
PrivacyIconClient.exe 7256 MSCOREE.DLL, mscoreei.dll, mscorwks.dll,
mscorlib.ni.dll, mscorjit.dll
PaintDotNet.exe 459736 MSCOREE.DLL, mscoreei.dll, mscorwks.dll,
mscorlib.ni.dll, mscorjit.dll

C:\Users\jeroenp>tasklist /m “clr.dll”

Image Name PID Modules
========================= ======== ============================================
explorer.exe 1696 clr.dll
[/sourecode]

–jeroen

via: process – How to check if a program is using .NET? – Stack Overflow.

Posted in .NET, C#, Development, Power User, Software Development | 1 Comment »

MonoTouch 5.0 released: iOS 5 support for Mono on the iOS 5 release day

Posted by jpluimers on 2011/10/13

With the and iOS 5 release today and the MonoDevelop 2.8 release last week, there is also a new MonoTouch 5.0 released that binds the two and allows you to develop iOS 5 using Mono.

Almost like a mirracle: on the iOS 5 release day, MonoTouch 5 gets released. Lot’s of new stuff to play with, just read the announcement :)

Quote: “If you already have MonoTouch, simply launch MonoDevelop and you will be prompted to update – it’s that easy!

Be sure to also read the new MonoTouch 5 documentation on new iOS  5 features and the comprehensive API diff between MonoTouch 4.2 and 5.0.

–jeroen

via: MonoTouch 5.0 – MonoTouch.

Posted in .NET, C#, Development, Mobile Development, MonoTouch, Software Development, xCode/Mac/iPad/iPhone/iOS/cocoa | Leave a Comment »

MonoDevelop 2.8 is Here! via: Xamarin blog

Posted by jpluimers on 2011/10/12

Last week, Xamarin released version 2.8 of the MonoDevelop development environment.

Biggest feature is xCode 4 support (which integrated the Interface Builder therefore broke MonoDevelop 2.6).

Since it is hard to run xCode 3 on Mac OS X Lion (Mac OS X Lion more than prefers xCode 4), and you need at least xCode 4.2 beta to develop for iOS 5, this welcome upgrade when you are staying current on Mac OS X.

You can use MonoDevelop to create .NET applications for:

  • iOS (iPhone/iPad/iPod-touch)
  • Mac OS X
  • Android
  • Windows
  • ASP.NET

Be sure to read the MonoDevelop 2.8 release notes, as even the list of Major Highlights is long:

  • C# 4.0
  • Defaults to the 4.0 profile.
  • New Garbage Collection engine
  • New Frameworks:
    • Parallel Framework
    • System.XAML
  • Threadpool exception behavior has changed to match .NET 2.0
    • potentially a breaking change for a lot of Mono-only software
    • See information below in the “Runtime” section.
  • New Microsoft open sourced frameworks bundled:
    • System.Dynamic
    • Managed Extensibility Framework
    • ASP.NET MVC 2
    • System.Data.Services.Client (OData client framework)
  • Performance
    • Large performance improvements
    • LLVM support has graduated to stable
      • Use mono-llvm command to run your server loads with the LLVM backend
  • Preview of the Generational Garbage Collector
  • Version 2.0 of the embedding API
  • WCF Routing
  • .NET 4.0’s CodeContracts
  • Removed the 1.1 profile and various deprecated libraries.
  • OpenBSD support integrated
  • ASP.NET 4.0
  • Mono no longer depends on GLIB

–jeroen

via: MonoDevelop 2.8 is Here! « Xamarin.

Posted in .NET, C#, Development, Mono for Android, MonoTouch, Software Development, xCode/Mac/iPad/iPhone/iOS/cocoa | 1 Comment »

Impersonation on the iSeries: Changing Profile User

Posted by jpluimers on 2011/10/12

When running on Windows, changing the current user is called impersionation.

There are various ways to do this in Windows, including

On the iSeries, there is only one way, as everything goes through the same API: use QSYGETPH (Get Profile Handle) to verify a username/password combination and obtain a handle to the authentication token, then use QWTSETP (Set Profile Handle) to change the user currently signed on, as for instance mentioned by Colin Williams directing to the CHGCURUSR tool on FreeRpgTools.com and an article on Swapping AS/400 User Profiles by Shannon O’Donnel that comes with source code.

On the iSeries, when you are done, you should use QSYRLSPH (Release Profile Handle) when done impersonating, and you need to get the handle from the original user profile if you want to return to it.

The IBM documentation contains a small sample with QSYGETPH, QWTSETP and QSYSRLSPH that sets and restores the profile handle (edit 20120214: it got moved to http://publib.boulder.ibm.com/infocenter/iseries/v5r3/index.jsp?topic=%2Fapis%2Fapiexushand.htm)

Note that on both Windows ans iSeries, impersonation within a process/thread will make it run in the new context, but the process still keeps the identity of the user that started the process.

If you want to change that, then on both you need to start a new process from the impersonated thread.

In Windows, you can combine the impersionation and the creation of a new process by using the CreateProcessWithLogonW function (as mentioned at the Old New Thing by Raymond Chan). I’ve yet to find an equivalent on the iSeries.

–jeroen

Posted in .NET, C#, Delphi, Development, iSeries, Software Development | Leave a Comment »

Bring back support for Smart Device Extensions – Customer Feedback for Microsoft

Posted by jpluimers on 2011/10/11

Having done quite a bit of Windows CE development work in .NET, I totally support the below UserVoice request: re-add support for Windows CE in Visual Studio 2010.

Please vote both the underlying Microsoft connect request, and the uservoice entryif you support it too!

Bring back support for Smart Device Extensions

Microsoft caused outrage when without warning or explanation they dropped support for the Smart Device Extensions. Meaning that there is no support for both managed (Compact Framework) and unmanaged (C++) development for the Windows CE platform.

Microsoft promised support would be added by the time VS2010 was released but then back tracked, to date the official line is use VS2008. This product is nearly 4 years old, it is becoming increasingly more impractical to use VS2008 solely for the purpose of developing for the Windows CE platform. Many development teams invested heavily in the benefit of having a single UI for both embedded and desktop development, with the advent of the Compact Framework skill sets and more importantly the code base could easily be shared across platforms. This is now no longer true, as the desktop development/source control/build/test environments have moved on the embedded development environment is stuck in the past. This means duplication of code, duplication of effort and increased cost.

Anyone wanting to start developing for Windows CE has to first buy an MSDN subscription because you can no longer buy VS2008 retail.

As support for Smart Devices has been inherent in VS since VS2003 many people have been caught out when upgrading to VS2010, in many cases those who make their living in the embedded world are now stuck with no upgrade path. Microsoft has refused to comment or discuss the future of embedded development, this silence has forced many to look at alternative platforms.

One of the top voted suggestions on the Connect site was to restore Smart Device Extension support in VS2010, Microsoft has ignored this in typical fashion.

See the Connect Item.

–jeroen

via Bring back support for Smart Device Extensions – Customer Feedback for Microsoft.

Posted in .NET, .NET CF, Development, Mobile Development, Software Development, Windows CE | 3 Comments »