locked
Question on 64bit testing RRS feed

  • Question

  • I am currently writing an application using the ACE provider for Access and I recently upgraded to the 64bit version of Office 2010 and thought that at the same time I would now write my app to work in either 32bit or 64bit mode. This sounded reasonable enough. I created separate platforms for x86 and x64 in Visual Studio 2010. Sounds reasonable. Had separate build folders and built my application.

    I have the following connection string

    Provider=Microsoft.ACE.OLEDB.12.0;Data Source=****

    I am using 12 because the OLEDB driver thinks it is 12 although using 14 makes no difference. 

    Now when I run my test project in 32bit (x86) mode I get

    'Microsoft.ACE.OLEDB.12.0/14.0' provider is not registered on the local machine

    Now I can understand this, I'm running a 64bit version of Office on a 64bit machine and I'm compiling the app using the x64 platform. Again all reasonable I believe.

    So then I switch to x64 and I get the rather cryptic message box error:

    Cannot start test project '' because the project does not contain any tests.

    On further investigation the output from the tests is (I've removed my paths):

    Error loading ...Tests.dll: Unable to load the test container '....Tests.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:///....Tests.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format.

    Now this error message is just full of unanswerable questions as far as I can see...

    1) "If you build your test project as a 64 bit assembly it cannot be loaded" - does this mean MSTest doesn't support 64 bit at all?

    2) When you build your test project assembly, select "Any CPU" for the platform. - OK so does this mean that you can test 64 bit applications but MS Test must run in 32 bit mode. In which case will 64bit OLEDB drivers load when testing?

    3) "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" - the plot thickens, the 2 options you have in the Hosts tab are "Run tests in 64 bit process on 64 bit machine" and "Force tests to run in 32 bit process" - So if MSTest either doesn't support 64 bit or the test dll needs to be compiled in 32 bit WHY is there an option for 64 bit here at all? And if setting this setting to 32 bit allows me to "run my tests in 64 bit on a 64 bit machine" then what on earth does setting the 64 bit option allow me to do. All very strange.

    4) Having endevaoured to follow both pieces of advice I attempted to run again and got the even stranger

    Error loading ...Tests.dll: Unable to load the test container ...Tests.dll' or one of its dependencies. 
    
    Error details: System.BadImageFormatException: Could not load file or assembly Model, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
    
    An attempt was made to load a program with an incorrect format.

    The assembly Model is simply a project reference in the test project.

    Firstly sorry for posting this to multiple forums but this does cross several boundaries. Any help would be much appreciated in getting my app to work both 32bit and 64 bit.

    Thanks in advance for any help.

    Colin

    Sunday, May 2, 2010 9:32 AM

Answers

  • Hello,

    As I know, MSTest.exe is a 32 bit process and there are some limitations while testing 64 bit assembly. MSTest.exe will need to load the test assembly into its own process.  Since MSTest.exe is a 32 bit process, the test assembly needs to be able to load into a 32 bit process (in other words it must target the x86 or “Any CPU” architecture) to load properly. This means that if you specifically target the x64 platform and you are using one of these test types, regardless of the setting of the Host Process Platform flag, the test assembly will fail to load and the tests will be aborted. In addition, the option for for 64 bit is for QTAgent.exe, not mstest.exe.

    Here is a blog you can refer to:

    http://blogs.msdn.com/lkruger/archive/2009/06/08/visual-studio-team-test-load-agent-goes-64-bit.aspx


    Edwer Fang [MSFT]
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Monday, May 3, 2010 8:30 AM
    Moderator

All replies

  • Hello,

    As I know, MSTest.exe is a 32 bit process and there are some limitations while testing 64 bit assembly. MSTest.exe will need to load the test assembly into its own process.  Since MSTest.exe is a 32 bit process, the test assembly needs to be able to load into a 32 bit process (in other words it must target the x86 or “Any CPU” architecture) to load properly. This means that if you specifically target the x64 platform and you are using one of these test types, regardless of the setting of the Host Process Platform flag, the test assembly will fail to load and the tests will be aborted. In addition, the option for for 64 bit is for QTAgent.exe, not mstest.exe.

    Here is a blog you can refer to:

    http://blogs.msdn.com/lkruger/archive/2009/06/08/visual-studio-team-test-load-agent-goes-64-bit.aspx


    Edwer Fang [MSFT]
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Monday, May 3, 2010 8:30 AM
    Moderator
  • This looks like it is designed for load testing agents as you say which I don't have in my version of Visual Studio. So essentially unit testing in Visual Studio does not work for 64 bit and the flag that is for QTAgent (which I don't have) shouldn't be on that page because it doesn't do anything. In addition the blog mentions MSIL which I don't even have as an option. Looks like I'm going back to 32bit then.

     

    Wednesday, May 5, 2010 8:53 AM
  • Hello,

    The MSIL option is for beta edition, in the RC and later edition, it has been changed to 'Run tests in 64 bit process on 64bit machine.'. For better compatibility, 32bit one would be a better choice.

    Thanks.


    Edwer Fang [MSFT]
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Send us any feedback you have about the help from MSFT at fbmsdn@microsoft.com.
    Thursday, May 6, 2010 8:19 AM
    Moderator