3

我的测试解决方案有问题。测试运行良好,但是当涉及到在测试运行后进行清理的类和方法时,基本上是删除共享点组、站点和数据库索引条目,因为我正在为 SQL 数据库上的站点和组编制索引。如果我从主程序运行清洁方法,一切都会好起来的。当我从 ClassCleanup 调用方法时,问题就开始了:

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

这些方法一直执行到委托:

    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) .....

此时我得到一个例外:

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

当单独调用该方法时,该方法可以完美运行,唯一的问题是清理方法何时进行调用。

谢谢你。

ps 该项目在带有 SP 2010 的 win 2008 上 cpu 设置为 ANY 的框架 3.5 上运行。

我按照从http://msdn.microsoft.com/en-us/library/ee782531.aspx将 cpu 执行模式更改为 x64 的说明进行操作,但仍然无法运行任何东西。

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.

4

1 回答 1

4

将 CPU 设置为 x64,然后重试。

于 2012-04-17T15:52:07.050 回答