How to: Target .NET 4.0 Client Profile with C++/CLI

While porting Paint.NET v3.5.5 to .NET 4, I naturally ran head-first into the problem of making sure my two C++/CLI assemblies were targeting the client profile and not requiring the full framework. The problem here is that Visual Studio 2010 does not have a UI for setting a C++/CLI assembly’s target framework version and profile.

On MSDN, I found that someone had added a note on how to target a non-v4 version of the framework by editing or adding a <TargetFrameworkVersion> element to the VCXPROJ file. Once I saw this, I looked as the CSPROJ files for my other assemblies to see how they did it, and they were using the same element with the same value in the same location. They also used an additional element to specify which profile (Client or Full) was targeted. On a whim, I decided to guess and check to see if this same element was honored by the C++/CLI compiler, and it is!

So here we go: (this is modified from the text already at the page linked to above)

To change the version and profile of the .NET Framework for C++/CLI projects (VS 2010)

1. Right click on project in Solution Explorer and click Unload project
2. Right click on unloaded project in Solution Explorer and select Edit <projectname>.vcxproj
3. In project XML file locate node <PropertyGroup Label=”Globals”>
4. In that node locate node <TargetFrameworkVersion> (if the node cannot be found, add it)
5. Inner text of the node defines target framework. It can be v2.0,v3.0, v3.5 or v4.0
6. In that node locate node <TargetFrameworkProfile> (if the node cannot be found, add it)
7. Inner text of the node defines the target framework profile. For the Client profile, set it to Client (for Full, just omit the element)
8. Save vcxproj file and close it
9. Right click on unloaded project in Solution Explorer and click Reload Project

Example:

<PropertyGroup Label="Globals">     
    …       
    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>      
    <TargetFrameworkProfile>Client</TargetFrameworkProfile>      
</PropertyGroup>

The Paint.NET forum has moved! Yay!

image When I mentioned that the forums were down for most of last week, I also promised it’d be worth it: we have finally moved the forum so that it’s sitting on our own hosting and not on freebie hosting. We’ve also migrated to IPB from phpBB, and will be adding and enabling more great features over the coming days and weeks.

Sorry to keep everyone in the dark, but we had to keep everyone in the dark, including our old freebie forum hosting provider.

The new address is http://forums.getpaint.net/

As with any large exodus or migration, there will be some glitches. For instance, apparently everybody on the forum was born on January 1st, 1970 🙂

Over time I’ll try to make sure all the links on this blog are pointing at the new location.

One nice thing about a big leap like this is that we can shed some dead weight. I just deleted over 16,000 accounts which had zero posts: that’s more than half the entire list of users!

Direct2D and WinForms: It Just Works

About a month ago I ported the Curves adjustment UI to use Direct2D for the transfer map (the interactive spline/grid). This meant that a rectangular portion of the form was carved out for Direct2D. If you’ve used WPF interop then you’ll be familiar with “airspace limitations”, and I was curious as to whether it would be possible to put a WinForms button on top of an area that is being rendered to with Direct2D. In other words, if you use Direct2D to render to an area of a Form, does it completely take over that rectangular area?

image 

Now, you can always take a guess, “Well of course you could/couldn’t do that because of explanation involving logical deduction or other example setting precedent.” For engineering purposes, however, something like this must be shown to work before taking a dependency on it.

And what do you know, it does work:

image

This screenshot shows a Form that contains a single control of type “D2DThingy.” That control then has 5 children controls of various types, and they are all stock WinForms controls. Clearly, they are able to coexist peacefully and without artifacts like clipping or flickering. Like with any WinForms UI there is still a lot of work to make sure that the background of the Button matches up with what’s behind it, etc. but that is a known problem with known solutions.

This is of special importance to me because I want to write a new toolbar UI for Paint.NET v4.0. However, I absolutely do not want to write my own ComboBox or TextBox controls. I could spend a full 12 months on a globalized TextBox that can work with all languages, input types, etc. Thankfully I won’t have to.

Intel’s Xeon X5680 gives you 24 threads, empties bank account

The guys over at 2CPU are quick on the draw with a review of the brand new, can’t-even-find-it-yet Intel Xeon X5680. It’s the bigger brother to the Intel Core i7-980X, itself a monstrous 3.33GHz, 6-core CPU. The Xeon has the extra pins and needles and validation to let you hook up 2 of them for a total of 12 cores. With HyperThreading that leaves you with 24 tiny little CPU graphs in Task Manager.

Do. Want.

Apparently AMD has some crazy chips coming out with 8- and 12-cores for 4-processor configurations, albeit at very low clock speeds. Still, 48 cores is within spitting distance of giving Windows 7 / 2008 R2 the fits. I have a nagging feeling that this level of performance will never make its way down to the $300 netbook/nettop level 🙂 As-is, a brand-new dual Xeon X5680 will set you back $1,600 USD per CPU, putting a whole system in the $5K+ USD range. Well, if you could find anyone who’s selling it anyway.

But the real question is, how fast does it run Paint.NET!? One of these would certainly cut my build times, now that Paint.NET is acquiring a large amount of C++/CLI in order to properly support Direct2D and DirectWrite. Using the /MP switch with the Visual C++ compiler results in all 8 threads of my Core i7-920 @ 4.0GHz being pegged at 100% for a significant amount of time.

Core i7-920 @ 4.0GHz, struggling to build the latest PaintDotNet.SystemLayer.Native DLL’s

Upgraded the blog

Whew, that was interesting.

Anyway the blog is now upgraded to the latest WordPress, has a new theme, etc. blah blah blah. So if you saw weird stuff earlier today, that’s what was going on.

New things to look forward to include February usage stats, and a version 3.5.4 update. I was going to post January stats, but the web logs had some problem so I’m going to wait and do them for February instead.

More Thoughts on Apple’s iPad

In my previous post, I lambasted the Apple iPad as a useless device.

Miguel de Icaza has a really good post praising the iPad:

This is a whole new space in which we can research, a new space that we can explore and where we can create a whole new class of computer/user interactions. With the new form factor, we can now create applications that just made no sense on the iPhone.

It is fascinating*.

And you know what? I agree with him: for developers who’re interested in writing touch-centric UI, the iPad is potentially a great* device.

Most people, however, will not be interested in this first revision of the iPad and should absolutely wait at least for iPad 2 or the next major OS revision. The feature set is still puny, and I think it’s far too expensive for what you get.

Personally, I’m not interested in writing an iPad application, but that’s because I’m more interested in what Windows 7 and multitouch can offer. It might have something to do with the fact that Paint.NET is a Windows app.

* not magical

Apple's iPad is a "magical device" … really!?

While watching all that iPad announcement hoopla, I kept thinking about this parody video that makes fun of Microsoft Paint:

http://www.youtube.com/watch?v=Hxx2KcPWWZg

Now, go to http://www.apple.com/ipad/ and click on the “watch the iPad video” link. See any similarities?

I kept waiting for Jobs to say something like, “haha just kidding, did you really think this is why we gathered all of you here today?” … except he didn’t. They’re completely serious about it. The apple.com home page says it is a “magical device”. Magical? Really? Unicorns and wizards are magical. They’re fun, but also fictional and nobody* actually takes them seriously.

magical!

That image is not edited with Paint.NET or Photoshop — they really had that slide up!

I’ll skip all of the obvious feminine hygiene references and jokes.

It’s a really big iPod Touch, and it has some wickedly good looking, and probably even well-written, UI.

But it can’t multitask. It doesn’t have a webcam for video calls. You still need a full PC/Mac to sync with. Apple, while publicly dissing them, has completely missed the point of netbooks: they are very cheap, and you can use all your existing stuff (apps, data, and devices) with them. If you drop it or lose it or break it, it’s not a big problem for the most part. Netbooks aren’t new or revolutionary devices: they’re simply a new price point.

I don’t believe that people want a third device. It isn’t something I would want to use everyday … why would I pay $500+ for it? Why would I buy a $30/month 3G data plan for it? Why should I have an iPhone in my pocket, and both an iPad and MacBook (or whatever) in my backpack? If I have a laptop and an iPhone, then I don’t need an iPad.

Any plausible reason that myself or my coworkers could come up with for actually buying an iPad was something that we could already do — and do better — on our iPhones, laptops, or desktops, or was just not possible with the iPad:

  • eBook reader? It’ll honestly be really good at that. But at a minimum of $500, I’d rather get the Amazon Kindle (it’s what, $200?). Or, and this is my personal preference, I’ll just buy the paperback for $10. I guess I’m old fashioned. Then again, my book shelf has been filling itself with books on physics and cosmology lately.
  • Taking notes in class? Except you still need a PC/Mac to sync with, and college kids don’t have oodles of money to throw at these things. So, I think they’ll skip it and just get a laptop. And there’s no stylus for free form note drawing, which I personally would need for any type of mathematics.
  • Can I plug it into my Mac/PC to use as a drawing tablet? Nope.
  • How about a Remote Desktop terminal so you can hook up to your main desktop/workstation while at the coffee shop or wherever? Sweet. A native iPad Remote Desktop app is very plausible. Except you have to buy a keyboard dock at that point, and you still won’t have a mouse. Why not just use your existing laptop? Or buy a $250 netbook?
  • A really big remote control for my home theater PC? Too expensive. Could be cool though.
  • How about docking it to my PC to use as an additional monitor? Nope.
  • Gaming! That must be it! Except I already have an iPhone. And an XBOX and a PS3. I really don’t need to play geoDefense on a larger screen, or Mass Effect 2 on a smaller one.
  • Install Windows 7. Nope, I don’t think you can do that 🙂

The list goes on and on. There’s nothing I can do on my iPhone or PC (laptop or desktop) that I can do better on the iPad. Nor is there anything the iPad can do that my other devices can’t. It’s too expensive, and there’s really no killer app. It does, however, have beautiful software, so I would like to give kudos to the software engineers who’ve worked on it.

I just don’t see the point. I’m still hoping for the “just kidding!” slide. I think they should’ve just extended Mac OS X to work better with a touch-only interface, and to scale down to even lower-end hardware. Add an iPhone emulator and extend the AppStore to Mac apps. Tada … I think that would sell.

Maybe they’ll prove me wrong. Maybe their stock price will hit $500. Or we could appeal to Occam’s Razor and observe that the Steve Jobs Reality Distortion Field has, apparently, been fully upgraded. Just like the Enterprise in-between every Star Trek movie …

* ok some people do … maybe they are the target market for the iPad?

Help test .NET Framework 4.0 Beta 2!

As I blogged about the other day, Paint.NET will be adopting .NET 4.0 fairly rapidly after its eventual release. The current release of Paint.NET, v3.5.2, makes use of .NET 3.5 SP1.

Scott Hanselman just blogged about how you can help to test out .NET 4.0 Beta 2 by setting a registry key so that it pops up in your Windows Update. The goal there is to test the deployment (aka installation) to help ensure things continue to go smoothly later this year when it’s rolled out to everyone.

It’s actually pretty easy and straightforward to do this… he’s got a .REG file you can download which pretty much does the whole thing for you.

Now, here’s where we can use big words like transitivity … by helping to test out .NET 4.0 Beta 2, you are in effect also helping out Paint.NET! I’m finally getting over this cold that seems to have hit everyone here in the Seattle area, and one of my next goals is to pop in that Visual Studio 2010 Beta 2 DVD and see how Paint.NET copes with the big scary framework upgrade…

You can also just go and install .NET 4.0 Beta 2 directly. However, Paint.NET won’t use it just yet.

I’ve also been doing a lot of deep thinking about what needs to be done for Paint.NET v4.0. There’s going to be a lot of changes under the hood in order to enable a whole lot of things that everyone’s been wanting for awhile, including and especially myself (please don’t ask what – at this point it’s just research, hope, and speculation). Many whiteboard markers are giving their lives for it …

Heads up: Paint.NET will require XP SP3 / Vista SP1 later this year

I’ve blogged about system requirements before. So far I’ve been content to leave the minimum version of Windows set to XP SP2, based both on user feedback and lack of necessity. It has come at the cost of adding about 2MB to the download package, but the work had already been completed and it was useful.

However, that will have to change soon. Later this year, Paint.NET will move to .NET 4.0. I am planning to do this before the increasingly mythic release of Paint.NET v4.0, and shortly after the public release of .NET 4.0 (whenever that ends up being). If you check out the download page for Microsoft .NET Framework 4.0 Beta 2, you will see that it requires XP SP3 or Vista SP1.

For many users this won’t be an issue. The updates are free*, and if you’re lucky then they’ll be automatically applied on some nice lazy weekend when you’re out sleeping, drinking, or fishing. Maybe even all three! Although if you haven’t updated yet, then please do so soon.

Many computers’ updates, especially those within the walls of corporate environments or educational institutions, are more conservatively applied (and with good reason). For those administrators in charge of such things, consider this blog post as my request to make sure all your XP boxes are at SP3, and that all your Vista boxes are at SP1 or SP2. There will then be one less obstacle toward getting .NET 4.0 installed, and thus one step closer toward the Paint.NET update which will require it.

While the minimum for Vista users will be SP1, I still recommend SP2 of course. That will help ensure you have the latest updates and security fixes as well as allowing you to install the Platform Update which includes DirectWrite, something that Paint.NET makes good use of if available.

For your convenience, here are download links for the service packs:

You can also just open up Windows Update and have it download and install things until it’s done.

* free in the sense that Microsoft does not charge for them.

How to fix: Unable to save .DDS files in Paint.NET v3.5.x

For those who just want the fix and to skip the commentary, go here.

Paint.NET v3.5.x requires a CPU with SSE support. Since SSE is a 10-year old technology, it was a pretty safe bet. I have only received one e-mail from a user who was confused about this. Oh, and a single blog comment from a gentleman who apparently believes he’ll be using the computer he bought in 2001 for a total of 20 years. That certainly is a long time to stick with XP! More power to him, but I certainly won’t be supporting XP anymore in the year 2020. Anyway …

The reason that SSE is required is for three reasons, none of which are really good enough on their own but together they were acceptable:

  1. DDS (DirectDraw Surface) file type support makes use of a C++ library called “Squish”. It has 3* optimization levels that can be chosen at compile time: normal, SSE, and SSE2. Enabling SSE for 32-bit systems was shown to yield a very large performance improvement. For 64-bit systems, enabling SSE2 is a no-brainer because all x64 CPUs support it.
  2. I wanted to cut down on the number of native DLLs that I had to dispatch out to, which would reduce the surface area of code that I was liable to maintain. Put simply: fewer code configurations means fewer bugs. In Paint.NET v3.36, I had 3 versions of Squish: x86, x86_SSE2, and x64. I knew that going forward this would turn into a rat’s nest of spaghetti code as I added more functionality to the “native” DLLs. Thus, I eliminated x86_SSE2 and switched on SSE “1” for the x86 DLL. There was also some additional native code consolidation. Almost all CPUs nowadays have SSE support, so this didn’t alienate very much of the user base.
  3. Eventually I will move Paint.NET to require SSE2, for reasons I will discuss later. Requiring SSE is a step in that direction.

Anyway, all this discussion aside, I just discovered that I accidentally compiled Squish to use SSE2. Oops ! The consequence is that if you have a Pentium III or Athlon XP and try to save a DDS file, Paint.NET will just crash, silently close, or print “Error” in the Save Configuration dialog.

You can wait for the next update, Paint.NET v3.5.3, or you can make use of the patch that I’ve published on the forum.

* Actually it has 4, because it also supports AltiVec. However, that’s for PowerPCs, and so doesn’t matter for Paint.NET.