Problems with Microsoft Jet OLEDB on 64bit Windows?

If you have scenario like this:

  • In your C# / VB.NET application you are using Microsoft Access database (MDF file)
  • Target machines are 64 bit machines (Vista 64 or some of the Windows Operating System flavors
  • On target machines, where you plan to deploy solution, you installed Microsoft 2007 Office System Driver: Data Connectivity Components
  • And still, you are experiencing error like this:
System.InvalidOperationException: The 'Microsoft.Jet.OLEDB.4.0' provider is 
not registered on the local machine.

Check if your application is setup for any CPU (Properties / Build / Platform target) which is default. If that is the case, change it to x86 – at the moment, there are no 64bit drivers for Microsoft Office, so only 32bit applications will work as expected.

VS 2005/2008 and Vista – IE cannot display the webpage

Vista and Visual Studio - problems with IPv6 and internal WebDev.WebServerI recently reinstalled my laptop completely (it is very nice Dell XPS M1330) and took that opportunity to make it into decent development machine (w/o all the stupid preinstalled applications).

Installed also Visual Studio 2005 and 2008, SQL 2005 Express and all the little tools necessary (ClipX for example).

Fired up latest web site on which I work on, F5 and … nothing – dreadfull message of “Internet Explorer cannot display the webpage”.

Ok, no panic here, let try Visual Studio 2008 with same web site; nothing 🙁 Same site, on two other development machines (Vista & Vista 64) under VS 2005 and VS 2008 works w/o problem.

Started researching and debugging; it turns out that next generation protocol IPv6, or its implementation on Vista clashes with integrated web server WebDev.WebServer.exe; WebDev has a problem finding localhost address in default configuration.

Easy fix for this is to comment ::1 entry in hosts file:

Uncomment ::1 in hosts file to correct webdev / visual studio problems

No restart is needed, either of computer or Visual Studio.

(to edit hosts file you can use notepad started with elevated rigths or “Run as administrator“; in Open dialog you type in %windir%System32driversetchosts)

How to Get Command Line of Launched Process

One nice improvement in Vista is enhanced Task Manager – apart from very good Resource Monitor tool, there are a lot of new attributes which you can select for running processes (View / Select Columns); especially interesting are:

  • Image Path Name
  • Command Line:

Vista - Task Manager - ‘Image Path Name’ and ‘Command Line’ attributes of an process

However, Microsoft can make some tasks much complicated that they should be; reasonable expectation is that each standard application (and Task Manager is one – it is part of Windows operating system) supports at least basics of Copy / Paste – getting data displayed in a grid in some text format.

For Task Manager that is not case 🙁 – there is no way (to my knowledge) to get displayed data from grid in some text form which you can use later.

Solution for this particular problem (and many other related) is in excellent SysInternals package: ProcessExplorer will display full information about selected process and allow you to copy that info on Clipboard:

SysInternals - Process Explorer - Details about process

Best of all, this nice tool is not tied for any particular Windows version – it will work in Windows 2000, XP or Vista.

Vista 64 – First Experience

I am (happily) using Vista 32 bit for a year, both on my home (desktop) computer and on laptop. Both machines are mostly used for development (Visual Studio 2005 & 2008 and Visual Studio 2003 via Microsoft Virtual PC 2007) and usual Office tasks.

One of my tasks on work is to test new technologies – so, I decided that it is time to try new Vista: Vista 64 bit.

Hardware configuration used is pretty much standard one:

Dell Dimension E520 with Intel Core 2 Duo E4300 @ 1.8 Ghz and 2 GB RAM. Graphic card was NVIDIA GeForce 7300 LE.

Installation

Despite all my worries, installation went smoothly (apart for having 150Mb of fixes to download 😉 ) – all drivers were found and installed ok:

Vista 64 - all drivers found and installed ok

Basics

Once when all drivers are in place, you need software which will use your new operating system to the max. Most of 32bit software will work w/o any problems, via WOW64 technology, and it will benefit from better memory organization (you can utilize full 4Gb under Vista 64, which is not possible under XP) and more registers availabile.

You do need some native 64bit applications, for example, when mounting ISO image under Vista 64:

Mounting ISO image under Vista 64

While there is plethora of ISO software in 32 bit world (highly recommending Virtual Clone Drive, freeware), things are gloomy in 64 bit world.

Update Aug 2008: Virtual Clone Drive now does support Vista 64! so please use it instead of Daemon Tools.

There are some programs that state 64bit compatibility (MagicISO for example) but only one which proved as working under Vista 64 is Daemon Tools.

However, BIG WARNING – Daemon Tools comes with spyware / searchware! Good part is that you can select NOT TO INSTALL IT – so please do not follow click-click-click install logic but make sure to DESELECT following two options on this screen:

Daemon Tools on Vista 64 - install w/o sponsor

as well as SELECT DECLINE on next screen:

Daemon Tools on Vista 64 - decline change of home page

After that, you are fine.

Adding Vista 64 to network domain

There is no magic around this step; I just had little trouble to find right screen for adding computer to domain:

Control Panel -> System or even easier using keyboard shortcut: Win + Break (Pause):

Adding Vista 64 to Network Domain
(click for larger image)

Network printing (over HP LaserJet 4100)

There was a bit of a problem setting up network printer (ours is HP LaserJet 4100). There are 64 bit drivers on HP site, but Vista refused to get those installed from network location.

I even tried to fool it by installing ghost LPT1: printer and than to add network one – failed.

Finally, I installed network printer as “local” one, using TCP/IP connection and install program from HP. After that, printing is fine.

Applications

Microsoft Visual Studio 2008 Installation

This was, by far, most frustrating experience 😯 – with number of errors, stating that it can’t install .Net Framework 3.0, than it can’t install Web Authoring Component … all red, and apparently no solution 😕

Problems installing Visual Studio 2008 on Vista 64

In despair, I switched to local administrator account and all went fine! So, use your local administrator account when installing Microsoft Visual Studio 2008 on Vista 64 – it is not enough to be member of Administrators group (my initial attempts were with domain user which is member of Administrators group)

Paint.Net Installation

Paint.Net is brilliant example of quality program (and it is free) – elegant, efficient and does exactly what is intended for: various tasks around image editing; it is not Photoshop, but I found that I do not need anything “stronger” than Paint.Net – I highly recommend it.

I did not expected any problems with installation; however, I was getting error:

“Another installation is already in progress (Error 1618)” and failed installation; of course I used “Run as Administrator” option over Paint.NET.3.22.exe – that did not help.

Solution: start CMD prompt as Administrator, and run EXE file from there – installation will go smoothly.

Paint.Net - Brilliant Image Editor

QUEST Toad and Oracle

If your target database for applications is Oracle and main development tool Quest’s TOAD make sure to install 32bit Oracle client prior TOAD installation – TOAD does not support connection over native 64bit Oracle client.

Moreover, if you get cryptic error on a first connect:

Can’t initialize OCI. Error -1

make sure that you have correct version of Oracle Client; current good one is 10.2.0.3 Patch2 for Vista

Conclusion

Vista 64 is stable operating system, although it demands bit more of CPU and RAM than Windows XP/Vista 32. It has decent driver base, and if you have more than 2Gb RAM, or your primary application has native 64bit version and/or you are engaged in processing objects which require a lot of memory, it is good OS for you.

For more standard usage, I still recommend staying on Vista 32 or Windows XP – there is a wast support for drivers, software and games all around.

Transliteration easy way – Microsoft Transliteration Utility

If you are lucky enough 🙂 to have not one, but two alphabets in daily use, your regular task in programming will be transliteration – transformation of text from one script (alphabet) to another.

In Serbia, we are using Latin as well as Cyrillic alphabet (and that is not same Cyrillic as Russian one) and common task is conversion from one to another and vice-versa.

This is not too complicated request; you can easily create necessary procedures; however, there is a better way:

Microsoft Transliteration Utility (MTU) is not widely known, but very useful tool for just that purpose: transliteration. It can easily transliterate text either typed in a text box or from one file to another.

There is set of predefined translations:

  • Serbian Cyrillic to Latin / Serbian Latin to Cyrillic
  • Bosnian Cyrillic to Latin / Bosnian Latin to Cyrillic
  • Hangul to Romanization
  • Inuktitut to Romanization / Romanization to Inuktitut
  • Malayalam to Romanization / Romanization to Malayalam

You are not limited to above set; you can easily create your own translations, using Module Development Console:

Microsoft Transliteration Utility - Module Development Console
(click on image for larger version)

Creating simple textual file, you can use full power of MTU’s parsing engine: definitions of input and output characters, rules for transliteration including definitions of new states for translation state machine.

This is not the end – you can even use MTU programmatically (although please check EULA for commercial usage):

  • Add reference to MSTranslitTools.DLL (it can be found in %programfiles%Microsoft Transliteration Utility)
  • Add using System.NaturalLanguage.Tools;
  • Current translation files (.tms) can be found in %CommonProgramFiles%TransliterationModulesMicrosoft
  • Here is simple code fragment to demonstrate:
TransliteratorSpecification specification =
   TransliteratorSpecification.FromSpecificationFile("Serbian Latin to Cyrillic.tms");

Transliterator transliterator = Transliterator.FromSpecification(specification);
string rezultat = transliterator.Transliterate("Vesic.Org");

Console.WriteLine(rezultat);

VPN, Remote Desktop, Vista and MTU

LinkSys WAG325NMy home network is rather small: two desktop machines and one laptop. Access to outside world is done via usual ADSL connection. Bridge between two worlds was some unknown ADSL router connected to (good old) LinkSys WRT54G with custom DD WRT firmware; all work was done here: firewall, port forwarding, dhcp …

This combination was good, but not the best – main obstacles were having two devices instead of one (WRT54G has no ADSL port) and no VPN directly to offices where I work.

Recently, I replaced WRT54G with newer model: LinkSys WAG325N: ADSL port, 4 LAN ports, 802.11 a/b/g wireless and experimental (draft) implementation of 802.11n wireless protocol. Best of all, up to 5 VPN channels directly from router, so all machines can use VPN tunnel w/o problems.

After seting up VPN, access to business machines was just fine from desktop machines. However, that was not the case for laptop, which is using wireless connection.

Using Remote Desktop from laptop, I would see initial black or blue screen of remote computer (w/o login box) and after couple of minutes, Remote Desktop session would die.

After considerable time spend on Google (and with great help of our system administrator Nemanja), I found possible problem: size of MTU or Maximum Transmition Unit – size of the largest packed allowed on particular network.

Default size set by Windows Vista was 1500 and that was enought not to establish Remote Desktop connection over VPN. In Vista, you can check settings by going in Command Prompt and typing:

netsh interface ipv4 show subinterfaces

and you will get something like:


  MTU  MediaSenseState   Bytes In  Bytes Out  Interface
------  ---------------  ---------  ---------  -------------
4294967295          1          0       7127  Loopback Pseudo-Interface 1
1500                1     145661      51022  Wireless Network Connection
1500                5          0          0  Local Area Connection
1500                5          0          0  Bluetooth Network Connection

Now, you can change MTU for particular interface:

netsh interface ipv4 set subinterface "Wireless Network Connection" mtu=1440 store=persistent

(make sure that you are doing this from elevated Command Prompt, i.e. CMD started using right-click and option “Run as Administrator“) and that will sort out any Remote Desktop connection problems.

How to find out Volume Serial Number / CPU info

One of the techniques used when you plan to protect your valuable intellectual property 🙂 (your code) is reading some kind of hardware signature of machine where program is installed.

Usual initial approach is to read Volume serial number (bear in mind that this number can be easily changed) or similar hardware information. Here is where WMI – Windows Management Instrumentation comes in play – you can find enormous amount of information using WMI.

Let’s give small example – find out Volume Serial Number:

– add reference to System.Management.dll
– here is the code:


using System;
using System.Collections.Generic;
using System.Text;
using System.Management;

namespace Org.Vesic.WMI.Example
{
    class Program
    {
        static void Main(string[] args)
        {
            string targetVolume = "C";
            
            if((args != null) && args.Length > 0)
            {
                targetVolume = args[0];
            }

            string mngObject = String.Format("Win32_LogicalDisk.DeviceID="{0}:"", 
                                             targetVolume);
            try 
            {
                ManagementObject myDisk = new ManagementObject(mngObject);
                PropertyData myDiskProp = myDisk.Properties["VolumeSerialNumber"];
                
                Console.WriteLine("HDD Serial for Volume {0}: is {1}", 
                                  targetVolume, myDiskProp.Value);
            }
    
            catch(ManagementException ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
    }
}

Simple and very effective. Of course, you can read load of other data types, NIC info, even CPU info:


ManagementObjectSearcher mos = new ManagementObjectSearcher
	 ("SELECT Name, L2CacheSize, L2CacheSpeed FROM  Win32_Processor");

ManagementObjectCollection moc = mos.Get();

int procCount = -1;

foreach (ManagementObject mob in moc)
{
	 procCount++;
	 Console.WriteLine("Processor No. {0}: {1}, L2 Cache size/speed: {2} / {3}",
		  procCount,
		  mob.Properties["Name"].Value,
		  mob.Properties["L2CacheSize"].Value,
		  mob.Properties["L2CacheSpeed"].Value
		  );
}