22 June 2011 0 Comments

SQL Server セットアップトラブルシューティング – 初級編

神谷 雅紀 Escalation Engineer   対象バージョン   SQL Server 2008 R2 SQL Server 2008   Step 1 – Summary.txt でエラー内容を確認する   SQL Server のセットアップに失敗した場合、まず最初に確認するべきは、Summary.txt ファイルの記録です。このファイルは、既定では、以下の場所に保存されています。 C:Program FilesMicrosoft SQL Server100Setup BootstrapLog Log フォルダ下に、最新のセットアップの Summary.txt があります。また、Log フォルダ下には、セットアップを実行した日時を示す YYYYMMDD_HHMMSS 形式のフォルダ名を持つフォルダもあり、そのフォルダ下には Summary_ computername_date_time .txt 形式のファイル名を持つ Summary.txt があります。 Summary.txt には、エラーとなったコンポーネント、エラーコード、エラーメッセージなどが記録されています。   Summary.txt サンプル   Overall summary:  Final result: 失敗しました: 以下の詳細を参照してください   Exit code (Decimal): -2068052371  Exit facility code: 1212   Exit error code: 1645  Exit message: 失敗しました: 以下の詳細を参照してください  Start time: 2011-06-21 09:40:10  End time: 2011-06-21 09:41:30  Requested action: ComponentUpdate  Log with failure: C:Program FilesMicrosoft SQL Server100Setup BootstrapLog20110621_094055WatsonX64_Cpu64_1_ComponentUpdate.log             上のサンプルでは、エラーメッセージとして詳しいメッセージは出ていません。しかし、Exit error code として、エラーコード 1645 が記録されています。また、Exit code (Decimal) も記録されています。Exit code (Decimal) として記録されている値 -2068052371 は、16 進数 (hexadecimal) に変換すると 0x84bc066d となります。プログラムを書く人には馴染みのある形式かと思いますが、これは HRESULT 形式のエラーコードであると考えられます。試しにこれを HRESULT のフォーマットに従って分解してみると、先頭ビットが 1 なので FAILURE、Facility code 0x4bc, Error code 0x66d となります。Error code の 0x66d は、10 進数 (decimal) の 1645 であるため、意味するところは、Exit error code と同じだということが分かります。 確認すべきは 1645 だろうということで、net helpmsg コマンドを使って、このエラーコードが何を意味しているのかを確認します。     エラー 1645 は ERROR_INSTALL_REMOTE_PROHIBITED として、Platform SDK 付属のヘッダーファイル winerror.h に定義されているエラーです。 このメッセージから、リモートデスクトップを使わず、セットアップ先コンピュータにローカルログオンしてセットアップを実行することで、このエラーに対処できそうだということが分かります。   Step 2 – インターネットを検索してみる   他の人が考えも付かないようなすごい事をしていない限り、世界中のどこかに自分と同じ事をしている人がいる可能性は高いと思います。こんなツールがあったら便利と思って探すと、多くの場合、既にそう思った人がいて、そんなツールを作っていたりするものです。セットアップのトラブルも、製品リリースから時間が経過すればするほど、多くの事例がインターネット上に存在するようになります。Summary.txt で確認することのできたエラーの内容でインターネットを検索すると、何かしらの解決方法を見つけ出せる可能性は高いと思います。 上のサンプルで確認したエラーコード 1645 とエラーメッセージ中の “Windows Installer” で検索すると、以下の技術情報が見つかります。   Error message when you try to install a MSI package on a Windows Server 2003-based computer by using RDP connection: “Windows Installer does not permit installation from a Remote Desktop Connection” http://support.microsoft.com/kb/927063/en-us   これを見ると、他のコンピュータからのリモートデスクトップ接続上で Windows Installer パッケージをインストールしようとすると、Windows Installer バージョンが 2.0.3790 以上の場合に 1645 エラーになる場合があると書かれています。また、エラーになる条件は、UNC 形式のTSClient 共有を使っている場合であると書かれています。Summary.txt の後半部分を確認すると、TSClient が使われていることが確認できます。   Package properties:  Description: SQL Server Database Services 2008 R2  ProductName: SQL Server 2008 R2  Type: RTM  Version: 10  SPLevel: 0   Installation location: \tsclientDx64setup  Installation edition: STANDARD               この技術情報には、セットアップの場所を TSClient 共有ではなく\computernameshare 形式やドライブ文字をマップすることで、エラーに対処できると書かれています。 これで新たな対処方法が見つかりました。この方法であれば、どうしてもリモートデスクトップを使ってセットアップを実行しなければならない状況であっても対処可能です。   TSClient 共有は、リモートデスクトップ接続時のオプションとして、[ローカルリソース] タブの [詳細] でローカルコンピュータのディスクを指定した場合に、接続先コンピュータ上でローカルコンピュータ上のディスクにアクセスできる機能です。   Tips   インターネットを検索する場合、やはり、英語の情報の方が圧倒的に多いため、エラーメッセージも英語で検索した方が情報を得られる可能性が高くなります。英語メッセージを確認するために、chcp コマンドでコマンドプロンプト環境を英語 (コードページ 437) に切り替えた後で net helpmsg コマンドを実行するという方法があります。     上の方法がうまくいかない場合は、err.exe という便利なツールがあります。個人的には、エラーコードからエラーメッセージを調べる場合には、いつも err.exe を使っています。   Microsoft Exchange Server Error Code Look-up http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=985

30 January 2011 0 Comments

Tip: Search Multiple Strings Using Regular Expression

This is small piece of code snippet which I wanted to share as we face this necessity in our day to day programming. Suppose you have a need when you need to search multiple string Read More

28 January 2011 0 Comments

Top 10 WP7 Application Design Tips

I recently received the Windows Phone Marketplace Developer Newsletter and found a cool list of top 10 WP7 App development tips. These tips are posted on the Windows Phone 7 Developer Blog .

12 January 2011 0 Comments

AssemblyFileVersionAttribute and AssemblyVersionAttribute: A subtle difference

The AssemblyInfo.cs file generated by Visual Studio contains the following lines: // Version information for an assembly consists of the // following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Build // and Revision Numbers // by using the ‘*’ as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] I was trying to auto-increment the build number by changing them like this: [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyFileVersion("1.0.*")] However, when I looked at the properties dialog for my executable, the file version was “1.0.*”. This puzzled me until I came across Manfred Lange’s ( Manni on DotNet ) very clear explanation of the difference between these attributes and how to use them effectively to auto-increment assembly version numbers.

27 November 2010 0 Comments

Removing unwanted Facebook contacts from your Windows Phone 7

I just got my Windows Phone 7 and added my Outlook, Windows Live, and Facebook accounts to the phone. The phone automatically downloading and merging all my contacts from each source is GREAT but I quickly realized that I ended up with 800+ contacts in my People Hub making it a little overwhelming. Especially since most of the contacts came from Facebook and a number of them are contacts who I don’t interact with regularly or don’t need them to be in my phone’s contacts list.

4 November 2010 0 Comments

Test Automation Series 2 – Creation Functions

With the introduction of the NAV test features in NAV 2009 SP1 it has become easier to develop automated test suites for NAV applications. An important part of an automated is the setup of the test fixture. In terms of software testing, the fixture includes everything that is necessary to exercise the system under test and to expect a particular outcome

1 March 2010 1 Comment

Tip 55 – How to extend an IQueryable by wrapping it.

Over the last couple of years I’ve found myself in lots of situations where I’ve wanted to get ‘under the hood’ and see what is happening inside an IQueryable, but I haven’t had an easy solution, at least until now. Getting down and dirty like this is interesting because it means you can: Log Queries before they are executed Rewrite expressions, for example replacing expressions that are not supported by a provider – EF, LINQ to SQL, LINQ to Objects etc – with expressions that are. Anyway, I was very pleased a while back when reviewing some sample code by Vitek, who has a new blog by the way, and I realized I could generalize it to create an InterceptedQuery<> and an InterceptingProvider

8 September 2009 0 Comments

Adding Color to Bash List Command Part II

I previously blogged about how to add color to the ‘ls’ command utilizing an config file and alias.  I then stumbled across a nugget of wisdom from a Foresight Linux user on the developers mailing list who gave a handy command that remedies some problems with missing color in a terminal. On some distributions, the system-wide /etc/DIR_COLORS * files are removed or not present.  This results in no colors being given inside of a terminal when looking for color directories and filenames.  If you find yourself in this boat, try the following command to re-populate this setting: devnet-> cd ~/ devnet-> dircolors -p >.dircolors This should create a default profile for colors for your session if it hasn’t been done or was accidentally removed.  For more information on the dircolors command try ‘man dircolors’.  Please also note that dircolors command uses the environmental variable LS_COLORS to set your session. For more information on LS_COLORS and how it pertains to the terminal/shell/cli/prompt, there are a few blog posts that do an excellent job explaining here , here and here .

19 August 2009 0 Comments

Fix for Apple Bug Affecting Truphone and Other Apps in iPhone 3.0

Since updating to iPhone OS 3.0 on my iPod touch, the icons of some apps periodically get replaced with a faded version of another app’s icon, or with a strange combination of multiple images. Others don’t have an icon at all.

18 August 2009 0 Comments

Tip 33 – How cascade delete really works in EF

Imagine that in your database you have a cascade delete on an FK relationship.

11 August 2009 0 Comments

Tip 32 – How to create a database from SSDL – EF 4 only

We recently released a CTP that extends EF 4 Beta 1 which included Code Only. You can read more about Code Only here , here and here .

6 August 2009 1 Comment

Tip 30 – How to use a custom database function

Imagine you have a database function like the DistanceBetween function in Nerd Dinner : CREATE FUNCTION [dbo].[DistanceBetween](    @Lat1 as real ,    @Long1 as real ,    @Lat2 as real ,    @Long2 as real ) RETURNS real AS BEGIN … END And you want to use it with the Entity Framework. Declaring the Function The first step is to open your EDMX file in the XML editor and add a <Function> inside the <Schema> element of the <edmx:StorageModels> element. When you are done the function declaration (akin to a C++ header file or an extern declaration) should look like this: <Function Name=”DistanceBetween”           IsComposable=”true”            Schema=”dbo”            Aggregate=”false”           BuiltIn=”false”           ReturnType=”float”>    <Parameter Name=”Lat1″ Type=”float” Mode=”In”/>    <Parameter Name=”Long1″ Type=”float” Mode=”In”/>    <Parameter Name=”Lat2″ Type=”float” Mode=”In”/>    <Parameter Name=”Long2″ Type=”float” Mode=”In”/> </Function> Using the Function in eSQL Now you can call this function in eSQL like this: SELECT VALUE(D) FROM MyModel .Dinners AS D WHERE StorageNamespace .DistanceBetween(       D.Latitude,D.Longitude,-34,174) < 50 MyModel is simply the name of your EntityContainer (generally the same as your ObjectContext) and StorageNamespace is your storage model schema namespace.