Showing posts with label sux. Show all posts
Showing posts with label sux. Show all posts

Monday, September 29, 2008

For all those, who have problems with running WPF Performance Profiling tool – Microsoft cares

Three days ago, I announced the new release of WPF Performance Profiling Tool. A couple hours after this was announced, I got a number of comments from you, readers. It was about issues with running this tool. I checked the issue and forwarded it to development team from Microsoft. The problem was in bad parsing of comma and point characters in this tool, when using it on non-US locale. Dev team took care about it and hopefully they will provide a fix soon.

Thank you for reading my blog, reporting and your awareness of such issues. This is very important to me and I’m really appreciate your efforts to help us to develop WPF community.

I’ll update you as soon as the patch will be available.

Thank you and Shana Tova!

image

Thursday, July 24, 2008

Configuring and running Mono ASP.NET 3.5 (AJAX.NET) on Linux computers

Before we will start, we should install Linux. To do this, you can download any of LiveCDs with live installation. Officially, Mono supported only on one free Linux - openSuse. However, you can make it work on any RedHat (and its alternatives), OpenSolaris. It works, but unsupported on Debians, Ubuntu and Maemo. We’ll stick to openSuse by now.

image

Let’s install it - OS

I’m assuming, that you’re installing Linux as the only OS on the machine, so insert liveCD (it can be either Gnome or KDE) and wait for Linux to run. It will run live image directly on your machine without installation.

When it’ll up, you’ll see liveInstall icon in your desktop. Click it and skip first two screens (it is only language and local settings). Next screen (disk partitions) is necessary for us.

On this screen, first delete all automatic partitions. The only one main partition will remain (/DEV/SDA or /DEV/HDA). Next you should choose non-LVM option and then start creating partitions.

Create first partition with mount point /boot and size of 100Mb. File system for this partition should be ext3.

Create second partition with file system SWAP (you will not have mount point) and set the size twice bigger, then RAM amount.

Create last partition with mount point / and all remaining size on disk.

All other steps are optional, you can just click Next button.

After about 10 minutes you’ll have up and running openSuse system. (If you forgot to remove CD, choose HardDisk as boot option)

Web Server installation

Now we have to install web server. You can choose either Apache, FastCGI  or use build-in server within Mono – XSP. We’ll choose Apache

Goto “Computer” it’s in the same place as Start button :) and choose YaST. You’ll be asked for admin password, you entered while installing the system.

Now in the Filter field, type “Install”. Choose “Software Management” from the available programs at right. Now, when Package Selection dialog opens, type “apache”, you’ll find apache2. Select it and click Install. Apache will move to the right column. Optionally, you can install also prefork and utils packages.

Now hit “Apply” to install it. Within two minutes, you’ll be asked to log off and log on. Do it.

By now apache is not running, you should run it and set it starts automatically. To do this, enter terminal window (you can either do it from “Computer” menu or right clicking desktop).

You need elevation to administrate startup programs. So type: “su –“ and enter your password. Terminal color turns red. Type “chkconfig apache2 on”. Now you should check whether it done, so type: “chkconfig apache2 –list”. You should see “On” near number 3 and 5.

To run apache manually, just type “/etc/init.d/apache2 start” to stop “/etc/init.d/apache2 stop”, to restart “/etc/init.d/apache2 restart” and to check the status “/etc/init.d/apache2 status

We done, apache is up and running. Now we should install mono

Mono installation

Start with the same YaST but this time, type “mono” – you’'ll get a lot of programs. To simplified installation, choose (or type) mono-complete. This will all available Mono modules.

After Mono will be installed, you should install also apache2-mod_mono to make possible running ASP.NET mono pages in Apache. do this.

Log off – log on and move to configuration

Mono configuration

Now it’s time to configure what ASP.NET pages you want to run. We want ASP.NET 2.0, so we should run mono apache mode for this version. To do this, go to the terminal, elevate yourself (su –) and type following: “vi /etc/apache2/httpd.conf” This will open VI editor with apache configuration file in it.

Now it’s time to learn VI a little. To start editing, you should type “A” – it will write “INSERT” in the lower left corner. To return to the command mode, hit escape key. To save (from command mode) “:w” to exit and save:wq” to exit without save:q!”. To find/” and string the pattern you are looking for.

Now go the the very end of the file  and write under Include “/etc/apache2/vhosts.d/*.conf” following:
(to short string “[D]” is your virtual directory (slash blank is root), “[P]” is physical path to your site without trailing slash)

MonoServerPath default /usr/bin/mod-mono_server2
Alias [D] “[P]”
AddMonoApplications default “[D]:[P]”
<Location [D]>
SetHandler mono
</Location>

So, if your site is MySite and it is in /srv/www/htdocs/MySite, this section will looks as following:

MonoServerPath default /usr/bin/mod-mono_server2
Alias /MySite “/srv/www/htdocs/MySite”
AddMonoApplications default “/MySite:/srv/www/htdocs/MySite”
<Location /MySite>
SetHandler mono
</Location>

If you want to turn it to the root site, this will looks following:

MonoServerPath default /usr/bin/mod-mono_server2
AddMonoApplications default “/:/srv/www/htdocs/MySite”
<Location />
SetHandler mono
</Location>

Now, we’ll add mono administrative site to be able to restart mono only without touching apache itself. To do this, after last </Location> you should add following:

<Location /mono>
SetHandler mono-ctrl
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Location>

I think it’s very clear what it did :)

If you have more, then one site and want to configure mono differently for each one of those, you should add VirtualHost section. To do this, include your configuration in to

<VirtualHost [IP and port you want, for example 1.1.1.1:80 or *:80 for all IPs on port 80]>
ServerName [Name you want]

</VirtualHost>

We done. Restart apache and enter the url you set (for example http://localhost/MySite/)

Working? Good. You finished.

Not working (familiar yellow error 500 screen)? Keep reading…

Debugging Mono website

Do you remember, that you have no development environment in this machine? You can install it, or download Mono liveCD with openSuse. But before doing it, please note, that GTK# (it’s devenv) is not very user friendly. It even worse, then Eclipse. So let’s try to understand first whether we can fix small compatibility problems without entering code.

The most convenient method to debug web site on Mono is by using XSP and XSP2 mini web servers. Just enter the directory of the site and run it. By default you’ll be able to access the site by using “http://localhost:8080” (it also be written for you). Enter and notice whether you have any errors in console. No? Keep doing

The most common problem is “error 500” with nonsense stack. If it contains ScriptManager error Type not found, the problem is in Web.config file. Try to regenerate it to be compatible to Mono (for example, Mono has different version of System.Web.Extensions assembly. In ASP.NET 3.5 it has version 3.5, Mono has only 1.0.61025.0 (the old AJAX.NET). To recreate your web.config all you have to do is to execute “mconfig af AJAX Web.config” It will create default web.config file, supports System.Web.Extensions (AJAX features).

Not helped? Keep doing. Let’s look another time into the stack – if it contains errors in “EnablePageMethods” or “ShouldGenerateScript” or “EncryptString” – the problem is serialization. Mono has very limited support for JSON, XML and SOAP serialization. Try to look into your code and notice if you have classes, marked with [Serializable] or you are transferring your own classes by using PageMethods. If so, replace it with regular strings (my grandma serialization).

Person p = new Person();
string sstr = string.Format(“{0}|{1}|{2}|{3}”, p.FirstName, p.LastName, p.Age, p.Wage);
return sstr;

var sstr = persons[i].split("|");
var p.FirstName =  sstr[0];
var p.LastName =  sstr[1];
var p.Age =  sstr[2];
var p.Wage =  sstr[3];

Not helped? Try to rename “Bin” directory into “bin” “mv Bin bin –r”. Actually this was fixed in latest versions of Mono, but who knows?…

No? Check whether you have partial classes, which is not supported by Mono. If so, recompile it like this

mcs /t:library /out:bin/test.dll –r:System.Web –r:System.Data –r:System.Web.Services –r:System.Web.UI.Controls test.aspx.cs

If you have Generics in your code, you should use gmcs, rather then mcs.

Not helped? It looks, that you have to either install Mono on your Windows machine and debug your code with it. Or, alternatively install GTK# and do in on Linux.

But wait, before doing such big step, install and check the binary compatibility of your code. To do this, you need “Moma” – a simple tool, that tell you if everything is ok for Mono in your assemblies.

Good luck and see you in my forthcoming TechEd session, where I’m presenting openSuse, running UDP multicast server with ASP.NET 3.5 extended methods (It uses recompiled ISAPI filters for apache, rather then regular limited AJAX support in Mono)

Have a nice day and be good people.

Thursday, June 12, 2008

Phone history or why I throw my Tytn II

I decided to throw out my HTC TYTN II (Actually AT&T Tilt) and get old Nokia E61 back. Why I’m doing it? Tytn is much better, then old Nokia? It’s 3.75G/HSUPA mobile phone, running latest Windows Mobile 6.1 OS. It also has full QUERTY keyboard, 2.8” LCD monitor, 3MP camera and even very good integrated GPS. Nokia has neither. It’s processor is x4 faster and memory x3 bigger. Why I cannot use it? Why I want my old “keyboard brick” back?

e61

First of all, I need phone. Not “freaky damn good uber extensible device”. I want to push one button to receive/make call, push another button to read/answer email. That’s all I need. I need business phone. I do not want to be worry about battery/alarms/meeting/time offset/current time/something wrong/too much processes/no memory/fault/occasionally shutdown/my ears near end call or mute button and all other “goodies” come with TYTN 2 device. I want to be able to dial number without looking on device. I want to be able to do it either when its sunny day outside. I want to push one button to refuse receive call, send “I’m sorry” SMS and turn ring off simultaneously. And I do not want to reinstall ROMS to figure one with small amounts of bugs and then reinstall 300 programs that allows me to do it. I want business phone, that knows what I need.

Just see the regular flow phone usage – make call:

  1. Click power/unlock button
  2. Enter password (there is exchange policy). To do this you have to look on screen. If you wont you’ll absolutely unable to know where each button on screen. Windows mobile using different keyboard for lock and phone utility.
  3. You should press left hardware button. It is not very easy task, ‘cos if your phone doing something now, you’ll wait for response between 1-2 seconds. If you’ll press it twice – you’ll arrive into calendar utility (only for this layout everyone in UX team of Windows Mobile should be fired.
  4. Press Phone button opens dialer utility. If you want any of your last incoming/outgoing/missed calls, you should press another soft button on screen (up jog button not always responses as required)
  5. Choose phone to call (another non-responsive hardware up/down buttons) and then
  6. Press middle big button…
  7. Nothing happes… “OK” button?
  8. You arrived to the contact information (I want to call)!!! Just side note, Windows Mobile is very smart system and if you have more, then one number per contact (work/mobile/office/text) it will call this number by default forever.
  9. Finally I choose a number I want to call (if you choose Text field of contact it brings your SMS interface instead of dialer) and calling the contact
  10. Busy… Redial? Automatic redial? Nothing. Now you should keep sitting and trying to process all above steps each time you want to redial…

Very useful, very easy tool. Isn’t it? Now let’s call the contact with E61

  1. Click unlock button
  2. Enter password (your keyboard is always the same and you should not look into it to dial 5 button is marked)
  3. Move jog up
  4. Move jog down
  5. Move your finger left and up (each button has its unique profile and you can feel it)
  6. Dial
  7. Busy? E61 will redial for you until it’ll catch the contact or you’ll cancel operation. You even do not need to hold phone near ear. Once it success, you’ll hear gentle sound from external speaker.

Should not it work this way? It should, because it is phone, not PDA device.

What about exchange synchronization? Works perfectly. I do not want E61I (successor of E61) it much slower and bugger, then E61. I’m waiting for E71 (smaller) to see if it good for me. but meanwhile, I’m paying $300 to get my E61 back. Someone want to buy my Tilt? Bid in comments.

All above is the reason I do not want IPhone. It’s toy. Very cool and beautiful toy. It is not tool I need everyday.

P.S. I think Microsoft should think a lot about Windows CE 5.x, used as WM. It is not OS for phones, it’s OS for devices with some tools to be able to make calls. Microsoft never be the favorite of mobile market (like Steve Ballmer want it to be), unless they understand, that CE is not operation system for phones. Just in case, currently Nokia holds 33% of the market, next is Motorola (20%), and Samsung (13%). Pay attention all three companies have phone operation system. It’s not about coolness of the device. It’s all about usability of tools.

P.P.S Yes, it’s much easier to find or develop additional tools for Windows Mobile, rather then for Symbian. But I’m ready to pay this bill if I’ll be able to use my phone as phone.

AT&T Tilt

Thursday, March 13, 2008

Localization fix for SAP ESA Explorer for Visual Studio

A couple of days ago, new great product [PDF] was released by SAP together with Microsoft. It named SAP Exterprise Services Explorer for Microsoft .NET (you can download sneak preview for free). It still in beta, however there is already major issue - it does not work in localized version of Visual Studio. Neither 2005 nor 2008. Why this happens? The reason is simple. Visual Studio always asks for localized resources for addins and there is no way to work around it.

From one hand, it's bad, that such global company as SAP does not want to localize it's products. From the other hand, there are very few developers, who working with localized versions of development environment. Anyway I started to look into the product to understand what has been done by developers. Oh, my god. They put resources into GAC. How to get them out there?

Actually, GAC is regular windows directory, that exists in %windir%\assembly\GAC\ or %windir%\assembly\GAC_MSIL\. But smart Windows replaces regular Explorer view by customize ActiveX. This does not mean, that you cannot pick files from there. To prove it map GAC folder to another disk. From command line run following command "subst z: %windir%\assembly\GAC_MSIL\". Now you have your GAC mapped to network virtual drive Z

So, if it is regular directory, you can get files from there and put it into any place you want. But why copy it if we can use hard links?

What's the hell are "hard links"? Hard links are symbolic links or symlinks, we know from Unix environment. Yes, you ca ln -fs in Windows :) To do it, you should use file system utility, named fsutil. Actually, those only pointers to real files in your file system. So, "fsutil hardlink create <copy> <original>" will do the work.

Now, when we know where to get those files and how to make symbolic links to them, we should know what versions of Visual Studio we have installed and what are languages of those products. To do this, we have to make a small trip into registry and look into HKLM\SOFTWARE\Microsoft\DevDic\VS\Servicing. There we will find node 8.0 if VS2005 installed and 9.0 if VS2008 installed. Actually, we can pick all necessary information there. Let's see. This key build according following pattern: HKLM\SOFTWARE\Microsoft\DevDiv\[Product Family]\Servicing\[Product Version]\[Product Edition]\[Product Language]. That's exactly what we need. But what are possible values?

  • Product family
    • URT - .NET framework
    • VB - Visual Basic Express
    • VC - Visual C++ Express
    • VCS - Visual C# Express
    • VJS - Visual J# Express
    • VNS - Visual Web Developer Express
    • VS - Visual Studio (all versions)
    • VSTF - Visual Studio Team Foundation Services
  • Product version
    • 8 (or 8.0) - 2005
    • 9.0 - 2008
  • Product Edition
    • VSTD - Standard
    • PRO - Professional
    • VSTS - Team System
  • Product Language
    • Integer of Culture identifier (or other words LCID)

Now, when we know what versions and what languages are installed we should detect where Visual Studio is installed. In this case, we'll need another registry key "HKLM\SOFTWARE\Microsoft\VisualStudio\". Under this node we'll find again 8 or 9 and then value "InstallDir", that, actually, tells us where the current version of Visual Studio is installed.

Last thing to remember, that Visual Studio looks into it's root directory (that we detected in previous step) for directory with two letter ISO language code and resources there.

At this point we know all necessary information in order to work, so we have our program ready. You can, even download and use it :)

image

So, after running and clicking "Apply fix" button (if possible - you have SAP ESA Explorer and localized version(s) of Microsoft Visual Studio), we can start using this great product in any available version of Visual Studio. In English of cause)

image

Have a nice day and do not forget, that not everyone work with English version of development tools.

Download Localization fix for SAP ESA Explorer for Visual Studio 2005 and 2008 (no installation needed - just unzip and run) >>

Tuesday, March 11, 2008

My XBAP deployment fails on user account, while administrators can run it well - what to do?

I know only one person, who has following problem, however it makes sense to post all steps to perform in order to solve the problem. Let's start from the error:

While trying to run XBAP application with user's account on my machine, I get following error:

System.UnauthorizedAccessException was unhandled Message="Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))" Source="System.Deployment

while administrators on the same machine have no problem to run the same XBAPs.

Side note: Similar problems might be while running XPS viewer directly from Internet Explorer.

Declaimer: This posting is provided "AS IS" with no warranties, and confers no rights. Following methods are not an officially supported feature. You can use it strictly for debugging purposes.

Following steps you should take in order to find the root of the problem

  • Check it your users able to get cookies (they should be able to write into isolated storage)
    in order to do it, repair simple HTML page on web server in the same security zone and put following code there

    document.cookie = "testxbapcookie=whatever;expires=12/12/2999 00:00:00";
    var c =
    document.cookie.match ( '(^|;) ?testxbapcookie=([^;]*)(;|$)' );
    if(c)
    document.cookie = "testxbapcookie=whatever;expires=12/12/1999 00:00:00";
    else
    alert("cannot set cookie");


    If you see alert - enable cookie support for this security zone
  • Next step is to check if the user able to write into storage. To do it try to copy and then read some file into "documents and settings\[USERNAME]\Local Settings\Apps\2.0" directory. If you cannot - ask the administrator to give full access to the user to this directory - it's the user's own directory
  • Next step is to check ability of the user to write into some registry key. Try to write something into HKCU\Software\Classes\Software\Microsoft\Windows\CurrentVersion\Deployment\SideBySide\2.0 if you cannot - ask administrator to give right for this node. Alternatively, you can run simple .NET program.

    Guid ri = new Guid("a5c62f6d-5e3e-4cd9-b345-6b281d7a1d1e");
    object o = GetUserStore(0,IntPtr.Zero, ref ri);

    if it failed, enable the access for this node. If you want to me  general, check whether client can read HKCU\Software\Classes before. Also you can check and access to HKCR\Interface\{79EAC9C9-BAF9-11CE-8C82-00AA004BA90B} registry node.
  • If the problem still exists, ask administrator to go to HKLM\SOFTWARE\Microsoft\.NETFramework\Windows Presentation Foundation\Hosting node in registry and create DWORD RunUnrestricted=1 value. This will force PresentationHost to restart itself might solve the problem. Please note, setting RunUnrestricted value might have side effects
  • If you still have a problem - try to delete and recreate the user or reinstall your operation system.

Have a nice day and don't fall with problem - if you do not really need XBAP - do not use it!

Monday, March 10, 2008

Quick Silverlight Tip: Networking in Silverlight 2.0 or my I'm getting HttpStatusCode.NotFound

If you're trying to implement sample XSS networking with Silverlight as it explained in QuickStart guide, but with your own remote host, you'll probably get strange "Not Found" error. You'll check your host, firewall setting, etc and everything looks ok. So what's the problem?

HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(new Uri("http://blogs.microsoft.co.il/blogs/tamir"));
           req.BeginGetResponse(getResponse, req);

void getResponse(IAsyncResult ar)
        {
           HttpWebRequest req = (HttpWebRequest)ar.AsyncState;
            HttpWebResponse res = (HttpWebResponse)req.EndGetResponse(ar);
            if (res.StatusCode == HttpStatusCode.OK)

 

WebClient client = new WebClient(new Uri("http://blogs.microsoft.co.il/blogs/tamir"));
            client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
            client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
            client.DownloadStringAsync();

void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
       {
           //DONE
       }

       void client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
       {
           //Update progress
       }

The reason for it, two small lines in the guide: "Note that the server hosting the feed must opt-in to cross-domain access by providing a Clientaccesspolicy.xml or Crossdomain.xml file at the root of the domain."

Oh, baby, how can I missed it? Create your own Crossdomain.xml now and put it into root directory of your web server. Remember to register XAP MIME type too :)

Have a nice day

Quick Silverlight tip: If you are unable to debug your own control

If you are unable to debug your own control. If nothing happens when you are using in your code the custom control created. If you do not know what's bad you're doing, and there is no error appears. Know, you should put user controls in other assembly and then reference to the assembly of controls in your project and in xaml code. Like this

<UserControl x:Class="MySilverlightProject.Page"
    xmlns="http://schemas.microsoft.com/client/2007"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   xmlns:c="clr-namespace:MySilverlightClassLibrary;assembly=MySilverlightClassLibrary"

In this case your controls will work.

Monday, March 03, 2008

Quick tip: How to open popup or ContextMenu in XBAP application

If you want to use ContextMenu in XBAP application this will work, only if your XBAP is in full trust mode. Else you'll get "Request for the permission of type 'System.Security.Permissions.UIPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed". But even with Full Trust application, if you'll try to open context menu explicitly it wont. The error, you'll get will be "Cannot create a top-level child window". This is right. You cannot use layered windows without explicitely set parent inside browser sandbox.

Why this happens? Honestly, as for me, this is bug inside System.Windows.Controls.PopupControlService internal class (tnx to Shared .NET source code). For some reason PopupControlService set parent of the context menu while it raises ToolTipOpenning event. More, then this, it uses internal dependency property OwnerProperty to do it. So pity.

_currentToolTip.SetValue(OwnerProperty, o);

And if it is not enough it probably has memory leak, I described earlier.

_currentToolTip.Closed += OnToolTipClosed;
private void OnToolTipClosed(object sender, EventArgs e)
        {
            ToolTip toolTip = (ToolTip)sender;
            toolTip.Closed -= OnToolTipClosed;

Never mind. The question is how to take care on it, when we have no public Owner property and Parent is read only? Fortunately, dev team leave us PlacementTarget property to explicitly set the owner of ContextMenu. So, all you have to do is to add one line before setting IsOpen property to true.

private void OnMouseDown(object sender, MouseEventArgs e)
        {
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                contextMenu.PlacementTarget = sender as UIElement;
                contextMenu.IsOpen = true;
            }
        }

 

That's all, folks. Now you can safely open ContextMenu in XBAP application not only with right, but also with Left mouse button as well as with keyboard event or any other code you want to.

Have a nice day.

Thursday, February 07, 2008

Oh, baby, C++ is dead (at least in MS Learning)

From the very beginning, all MS Learning exams were delivered in C++ only. Later come C# and VB (.NET) and you were able to choose one of those three languages (for .NET related dev exams). Starting today, for all new exams, you'll be able to choose from only two languages- C# and VB.NET. The reason is  3 exams in C++, related of thousands in VB and C#. C++ development is still focusing mainly on native... Is it? You should not know C++ anymore? As for me, too pity... Almost no one of new developers knows C++ and it's too bad for us and even worth for whole industry!

image

Tuesday, January 29, 2008

Microsoft almost never paying their presenters, so why we're coming?

In most cases, presenters, participate in TechEd, DevAcademy, open houses or other public sessions, arranged by Microsoft, are not get paid. However, we're still coming and presenting. Preparation of even small session takes at least a couple of days and costs us a lot of money, but we're still coming and presenting. Why?

The answer is not simple. So, in order to make it clearer to me, I created decision chart, that helps me to answer "yes" or "no" for next request to attend an event as presenter. Here it comes

image

Let me explain it for you. My hour costs at about 100$. To present at small event, I should prepare in ratio of 1/3 - for one hour session, I have to work at least three hours + arrangements, travel time, accommodations etc. Other words, one small session should costs about 1000$. Can they pay me what I'm worth? Probably they can, but there are other factors - what am I earn for example.

If I'm interested within attendees, I can generate more revenue from business opportunities, then from one time payment. Thus I wont ask to be paid. But sometimes, I might me unable to get such revenue. In this case, I'm asking another question: maybe inviters really need my help and I can allow myself to publish some charity? In this case I'll attend too.

So should Microsoft pay their presenters? Probably it should, but there are other factors should be took into account.

See me at TechEd '08 in Eilat :)

Monday, January 28, 2008

Weird bug in Windows Vista

Well, there are some (ghm) bugs in Windows Vista. Most of those bugs are not harmful for your system, however there are some, that ready are. Here the little bug, I experienced today. Follow those steps to repro (don't do it on files you need)

  • Select multiple files
  • Right click on those files and choose rename and change the name of one of those files
  • Hit enter
    • Expected result: all selected files renamed (name (0),name (1), name (2) etc)
    • Actual result: all selected files renamed (name (0),name (1), name (2) etc)
  • Hit Ctrl-Z (Undo)
    • Expected result: all renamed files undo to it's original names
    • Actual result: all renamed files undo to it's original names
  • Hit Ctrl-Y (Redo)
    • Expected result: all undid files redo to it's new names
    • Actual result: all files, except the first one, disappeared.

They are really disappear, they did not removed or deleted. They just disappear.

Workaround: Don't redo multiple rename action.

 

Have a nice day

Wednesday, January 09, 2008

How to merge help files to appear inside Visual Studio?

How many times after an installation of some SDK, you saw, that nothing has been merged into Visual Studio help. You press F1 and nothing happens? What to do? Actually, the answer is really stupid. You should go into Visual Studio Documentation (Programs->Visual Studio [number]->Visual Studio [number] documentation), go to Index and set filter by property to (unfiltered) and then look for collection manager->help

image

There you will find all help files installed in your system and now, you can merge (or unmerge) them manually by marking relevant checkboxes and clicking "Update VSCC" button.

This is really simple, but for me it looks a bit strange, that in order to do it, you should not go to any of options, but search into help context. However, this is the real live :)

Declaimer: this is not internal or private information of Microsoft Corporation. You can reference to online MSDN library to find small information pieces about this issue. Here one of such pieces (look for note section)

Monday, December 10, 2007

Hanukkah is almost over

Well, very smart Jew sells special made sufganiot (Hanukkah Jelly Doughnuts). Delicious!

image

via Ben Tamblyn

Wednesday, December 05, 2007

WPF - order is matter (especially with DependencyProperty)

What's wrong with following code:

class aaa : DependencyObject { }

class bbb : DependencyObject
    {
        static readonly bbb b = new bbb();
        public static bbb GetMe { get { return b; } }

        public static readonly DependencyProperty MyPropertyProperty =
            DependencyProperty.Register("MyProperty", typeof(aaa), typeof(bbb), new UIPropertyMetadata(default(aaa)));

        private bbb()
        {
            MyProperty = new aaa();
        }
        public aaa MyProperty
        {
            get { return (aaa)GetValue(MyPropertyProperty); }
            set { SetValue(MyPropertyProperty, value); }
        }
    }

Nothing special, One DependencyObject, that implement singleton pattern. You should call GetMe to create and get an instance and then use it.

Well, this code throws "Value cannot be null. Parameter name: dp" exception. Why this happens? Why class aaa can not be null? It can - it dependency object!

How to fix it? Just move registration of DependencyPropery above initialization of static bbb to solve it. Like this

class aaa : DependencyObject { }

class bbb : DependencyObject
    {
        public static readonly DependencyProperty MyPropertyProperty =
            DependencyProperty.Register("MyProperty", typeof(aaa), typeof(bbb), new UIPropertyMetadata(default(aaa)));

        static readonly bbb b = new bbb();
        public static bbb GetMe { get { return b; } }

        private bbb()
        {
            MyProperty = new aaa();
        }
        public aaa MyProperty
        {
            get { return (aaa)GetValue(MyPropertyProperty); }
            set { SetValue(MyPropertyProperty, value); }
        }
    }

Why this happens? Well, even compiled, WPF initializes static classes by using it's order in code. Don't believe me? Open ILDasm for evidences.

Conclusion - I think, it should be reported as bug, however, from the other hand, it makes sense. You choose what's right and what's wrong.

Great thank to Kael and Matthew for helping me to debug it.

Saturday, December 01, 2007

What did they smoke? (these are actual MSDN articles)

After publishing KB support article about unattended classical music, played by BIOS in Windows systems, I got an email from one of my friends with dozen (actually 20) of other real KBs, confirmed by Microsoft as known issues. Here it comes - what did they smoke, approving such stuff?

Q303969: How to Work with More Than 64,000 Children Per Parent

Q189826: PowerPoint Centimeters Different from Actual Centimeters

Q282850: Cookies Lost After Upgrading to Windows XP

Q811443: The Italian Proofing Tools Make a Potentially Offensive Suggestion

Q178748: SATAN Causes High Memory Utilization in WUSER32

Q133357: Differences Between Temporary and Permanent Relationships

Q259754: Invalid Page Fault If a Player Shoots the Moon "...you may receive the following error message if a player successfully shoots the moon...

Q269916: Office Assistant Makes Sudden Loud Noise

Q191241: Money: Stuck in Endless Loop When Reading Statement from Broker

Q145674: How Long Does it Take to Set Up Pregnancy and Child Care

Q138990: No Ball on Table in 3D Pinball

Q206145: Random Characters Appear in Network Adapters List

Q106121: Sleeping Server Stops Responding to Requests

Q244763: Access Violation Under High Cursor Stress

Q170433: Cannot Stop Ignoring a Person in a Whisper Box

Q264443: Wall Will Not Glue or Is Not Cleaned Up “Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article”

Q143366: ErrMsg: Solar System Needs More Memory to Run

Q227925: Access Violation When Sending One Million Faxes on VFSP Device

Q167705: Talking Loudly into Microphone May Cause Disconnect

Q811544: Holidays Available Only Through 2005 Calendar Year “This behavior is by design.”

bang

Smile and have a nice week

As promised, I reinstall my laptop with Windows Vista 64bit

I decided to reinstall my D820 with 64 bit version of Windows Vista as involvement act with Gadi. 13 minutes of installation. All hardware was found and all drivers were installed (this why I love Dell). The same score as was with 32 bit version - 3.2. Fist run of Windows Update = 38 fixes (about 130MB, only required updates, downloaded and installed within 55 minutes including first restart). Another turn of Windows Update brings me additional 2 fixes (63.9MB of driver's updates and 10 minutes ). It downgrade my computer to 3.0. Now I have to add my computer to domain. It was done via VPN over WiFi and took about 10 minutes including security check, policy update and IPSec. After Vista was activated, come Office's and Live Suite turn to be installed. 

image

Office installation took about 2(!) hours. Well, I do not know why it happens, however, let's go on and install VSTS 2008. The first step of VSTS installation required me to restart my computer twice. It looks like there are issues with "Microsoft .NET Framework v3.5 (x64)". However, after I "run as Administrator" the Visual Studio installer, the problem disappears. It looks like there are some files become locked, when running the installer without elevated permissions (THIS IS BUG). After the first step passed, I wait for another 35 minutes for VSTS to be completely installed. To be honest, in x64 HxMerge works a bit faster, then on x32 platform. Additional 15 minutes of MSDN library.

Well, overall experience of installations was rather bad, but much worse is how x64 works. More then half of system processes (see the example of such service - Console IME at screenshot)  are working in simulation mode, so performance of the system is sucks.

image

What will be my next step? Probably, uninstall of x64 bit version of Windows Vista and installation of x32 bit system. I can not see real advantages of using x64 due to fact, that this software is not ready for public use and waste your system resources.

What do you think about this point?

Thursday, November 22, 2007

Very bad startup name

Today morning, I got call from someone, who ask me to assist new startup with WPF development. I asked a name of the startup. The name is "Proc To Light". Nothing special, they are doing very interesting application, that support analysis to make right decisions regarding different business process. I typed the name of the startup and phone number into my E61 without spaces. Once I got to office, I looked into the note made burst out laughing like crazy. The name of this startup is "PROCTO LIGHT". I called the guy and told him, that I advice them to change their company name in order not to spawn investor's relation.

Image:Anorectum.gif

What other fun startup names do you know?

Wednesday, November 21, 2007

Why good programmer never write good programs

Here, one of visitors, begun a discussion about good and bad programmers. Here, I wrote about absolutely unnecessary and not relevant questions to good programmers. Someone things, that good programmers should write good programs. However, I want to interpose my objections to the statement. And this why.

image

Let's start with the term "good programmer". What is it?

  • He knows any, even small details of programming language
  • He knows to write very efficient algorithms
  • He always in new technologies and applies them in his everyday work
  • He is extremely innovative
  • He tries to make his every bit to be perfect
  • He glows with enthusiasm
  • He's very smart and inventive

Can such person write good program? Probably not. He can not write even average program, because of very small fact - the target of the programs we writing.

Whom we write for? For customers. The customers has no idea about what programming language we are using to write the program. He even do not know why we use this or other approach to solve his business problems. He do not care about algorithms, structures and abstract layers. He do not care about top and very efficient technologies, helps us to perform tasks better. He want to solve his problems and he want to do it quicker as possible with minimal effort from his side.

Now I want to ask you a question: "Do you (as programmers) interested with his (customer's) business processes and problems?" - the answer is NO! You're much more interested with how to make your work smaller and be able to expand it in the future upon customer's requests (not needs). To expand and enhance the program by yourselves - not by any other. You are the programmer!

Honestly, you are right, it is not your job to understand user - this is the job of business intelligence expert. However, how many companies hires this one? How many job boards advertises "BI experts"? - NONE (except those, how want him to sell their products). Everyone are looking for programmers, team leaders and architects. They want you to do it. They want you to understand customer's problem and you to solve it. Will you? Probably not, but you'll try to and this will take most of your work time. This why the programmers of today, probably good programmers, but, actually, they are not writing (and unable to write) good programs. It maybe very good from inside, but will be never good outside.

Tuesday, November 20, 2007

I love such SPAM

That's exactly what I mean, when writing such articles.

image

Translation for English speakers: "Wake up!!! Job boards are overloaded... Very high wage in HighTech. .NET. Press here and you're financially secured.

Sunday, November 18, 2007

How to make your code completely unreadable with .NET 3.5

With the time we got our developers less and less professional by enhancing programing languages and using easier code syntax. However, while we are trying to make things better, we discovered that things are going bad. Let's see following code sample

delegate string BringBeerDelegate(int amount);

 

static void Main(string[] args)
        {
            Console.WriteLine("Bringing beer using anonymous delegates");
            AskBarmenAboutBeer(2);

        }

 

static void AskBarmenAboutBeer(int amount)
        {
            BringBeerDelegate bringBeer = new BringBeerDelegate(BringBeer);

            Console.WriteLine("You got {0}", bringBeer.Invoke(amount));
            BringAnotherBeer(bringBeer, amount+1);
        }

 

static string BringBeer(int amount)
        {
            return string.Format("{0} beers",amount);
        }

 

static void BringAnotherBeer(BringBeerDelegate firstPint, int newAmount)
       {
           string res = firstPint(newAmount);
           Console.WriteLine("You got another {0}",res.ToString());
       }

It pretty clear what this code is doing. It creates new delegate named BringBeerDelegate, that actually formats string. Then it invokes the delegate. After it the delegate transferred into BringAnotherBeer method and invokes there. This way it works in .NET 1.1 So far, so good. Let's use anonymous delegate, introduced in .NET 2.0 instead on using method to invoke it. Now, we'll add another method, that creates and invokes the anonymous delegate BringBeerDelegate.

static void AskBarmenAnonymouslyAboutBeer(int amount)
        {
            BringBeerDelegate bringBeer = delegate(int am) { return string.Format("{0} beers", am); };

            Console.WriteLine("You got {0}", bringBeer.Invoke(amount));
            BringAnotherBeer(bringBeer, amount + 1);
        }

Now, calling AskBarmenAnonymouslyAboutBeer with number of pints we want, we'll create and invoke the anonymous delegate. The code less readable (as for me), but never mind, we saved a couple of code lines.

Now, let's write following:

BringBeerDelegate bringBeer = am => string.Format("{0} beers", am);
BringAnotherBeer(bringBeer, ++amount);

What the hell all those => are doing? This is anonymous delegate BringBeerDelegate defined by lambda¹ expression.

small lyrics: ¹Lambda (uppercase Λ, lowercase λ) - the 11th letter of the Greek alphabet. In the system of Greek numerals it has a value of 30. Letters that arose from Lambda include the Roman L and the Cyrillic letter El (Л, л).
Lambda expressions provide a more concise, functional syntax for writing anonymous methods.

Is it really more concise and functional syntax? What do you think, following code doing?

Func<int,string> firstTime = (int am) => { return string.Format("{0} beers", am); };

Func<T..> is generic delegate type for lambdas. That's piece of cake, isn't it? Let's see you to predict what following code will output...

BringBeerDelegate bringBeer = am => string.Format("{0} beers", am);
Func<int, BringBeerDelegate, string> bringBeerFunc = (int am, BringBeerDelegate beer) => { return beer(am); };
Func<int, Func<int, BringBeerDelegate, string>, string> lastTime = (int am, Func<int, BringBeerDelegate, string> func) => { return func(am, bringBeer); };

The other awful thing in new .NET 3.5 is anonymous types. So, great news, VB programmers, there is new king in the village. His name is VAR. Following previous code section, following make our life even more complicated.

var whatBeer = bringBeer;

//At least, either compiler and interpreter knows, that whatBeer variable is of BringBeerDelegate type

image

Happy and very unreadable coding, my friends.

Source code for this article.