2012-04-17 4 views
2

テストソリューションに問題があります。テストは正常に実行されますが、テストの実行後にクラスとメソッドを実行すると、基本的に、SQLデータベースのサイトとグループのインデックスを作成しているので、共有グループ、サイト、およびDBインデックスエントリが削除されます。 メインからクリーニングメソッドを実行すると、すべて正常に機能します。受信CLSID {}のコンポーネントのCOMクラスファクトリを取得できませんでした。次のエラーが原因で失敗しました:テストクラスのクリーンアップを実行中の80040154.

[ClassCleanup()] 
    public static void MyClassCleanup() 
    { 
     DelSphere.delGroups(SPHEREID); 
     DelSphere.delSites(SPHEREID); 
    } 

方法は、デリゲートまで実行します:

Retrieving the COM class factory for component with CLSID {BDEADF26-C265-11D0-BCED-00A0C90AB50F} failed due to the following error: 80040154. 

public static void delGroups(long sphereId) 
    { 

     using (SupportDB DB = new SupportDB()) 
     { 
      var gruppi = (from grp in DB.Gruppo where grp.Sfera.PK_Sfera == sphereId select grp).ToList(); 
      var id = (from sphere in DB.Sfera where sphere.PK_Sfera == sphereId select sphere).ToList(); 

      var SC = GetSCfromSphere(id.First().PK_Sfera); 
      try 
      { 
      Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(delegate() 
       { 
        using (SPSite scSite = new SPSite(SC.SiteCollectionUrl)) 
        { 
         foreach (var grp in gruppi) ..... 

その時点で、私は例外を取得、私が代わりにClassCleanupからメソッドを呼び出すとき 問題が開始しますメソッド自体が呼び出され、完全に実行されるのは、クリーンアップメソッドが呼び出しを行うときだけです。

ありがとうございます。

p.s.このプロジェクトは、SP 2010を使用して2008年にCPUをANYに設定したフレームワーク3.5で動作しています。

CPU実行モードをhttp://msdn.microsoft.com/en-us/library/ee782531.aspxからx64に変更する手順に従いましたが、まだ何も実行できません。 x64および再試行するCPUを設定し

Error loading C:\Users\Administrator\Documents\WSTests\WSTests\bin\Debug\WSTests.dll: Unable to load the test container 'C:\Users\Administrator\Documents\WSTests\WSTests\bin\Debug\WSTests.dll' or one of its dependencies. If you build your test project assembly as a 64 bit assembly, it cannot be loaded. When you build your test project assembly, select "Any CPU" for the platform. To run your tests in 64 bit mode on a 64 bit processor, you must change your test settings in the Hosts tab to run your tests in a 32 bit process. Error details: Could not load file or assembly 'file:///C:\Users\Administrator\Documents\WSTests\WSTests\bin\Debug\WSTests.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format.

+1

テストユニットランナーは、64ビットモードで実行する必要があります。 –

答えて

3

+0

http://msdn.microsoft.com/en-us/library/ee782531.aspxからCPU実行モードをx64に変更する手順に従いましたが、まだ何も実行できません。 – iris

+0

@iris Hmm、それではうまくいきません... Hansのコメントは役に立ちましたか? –

+0

さて、まあまあ、私は、その厄介な初期エラーを受けて停止したが、実行が64ビットモードに変更されたにもかかわらず実行されない理由をまだ理解できません。 – iris

関連する問題

 関連する問題