locked
Problem to launch my test outside Visual Studio RRS feed

  • Question

  • Hi all

    I am a French intern and I got a really big issue so can you help me please : 

    The goal of my project is to automatize some tests from a .dll coded in VB6 in a C# programs.

    In fact I use some classes from my VB project which will allow us to prevent regressions in the code. The .dll is in x86 so my C# project.

     

    Here is an example of how I use the dll

     

           using E2S_Equipment;

                

                 public void verifyEquipmentTextProperty(string eqpCode, bool equipmentIsDynamic, string textPropertyCode, bool textPropertyIsDynamic, string propValue)

                {

                   //Class from E2S_Equipment dll

                   claEQPSRVReadString readStrService = new claEQPSRVReadString();

                   readStrService.LoadByKey(eqpCode);

                            

                }

    All my test are in success when I launch them in Visual Studio but when I launch them with Command Line with MSTest the first test is in success and the others are in failure. My error is :

     

    *“System.Runtime.InteropServices.COMException: Creating an instance of the COM component with CLSID {987C190C-8CFD-4E41-882B-3BAE73768066} from the IClassFactory failed due to the following error: 800a005b Exception from HRESULT: 0x800A005B.”*

     

    My problem concern the declaration of claEQPSRVReadString

    My first thought was that mycode created for each test a new instance of the COM Object and so I created a Singleton pattern to have only one instance of my COM component like this:

     

        public static class SrvReadTextPropertySingleton

        {

            private static claEQPSRVReadString mEqpSrvReadTextProperty;

            public static claEQPSRVReadString EqpSrvReadTextProperty

            {

                get

                {

                    if (mEqpSrvReadTextProperty == null)

                    {

                        mEqpSrvReadTextProperty = new claEQPSRVReadString();

                    }

                    return mEqpSrvReadTextProperty;

                }

            }

        }


    And now I get this error (“SrvReadTextPropertySingleton. EqpSrvReadTextProperty.LoadByKey(eqpCode);”).

    *“System.Runtime.InteropServices.InvalidComObjectException: COM object that has been separated from its underlying RCW cannot be used.”*

    So, do you have any idea?

    Thanks you in advance !

    • Moved by Anna Cc Monday, June 16, 2014 1:45 AM
    Friday, June 13, 2014 2:50 PM

Answers

  • Hi Arkieffer,

    >>Do you have any Idea (It is the same than testseeting?)

    You could open the .testsettings file with XML:

    ...

    <Execution> 

      <ExecutionThread apartmentState="MTA"/>   

    </Execution>

    </TestSettings>

    http://ralessi.wordpress.com/2013/09/11/mta-testing-on-vs2012/

    Note: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you.

    Microsoft does not control these sites and has not tested any software or information found on these sites;

    Therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there.

    There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

    Best Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, June 20, 2014 6:40 AM

All replies

  • Hi,

    I help move this case to Visual Studio Unit Testing forum for better response.

    Thank you for your understanding!

    Best regards,


    • Edited by Anna Cc Monday, June 16, 2014 1:44 AM
    Monday, June 16, 2014 1:43 AM
  • Thanks you, I did not know where to put my post.

    Respectfully.

    Monday, June 16, 2014 7:23 AM
  • Hi Arkieffer,

    Thank you for posting in the MSDN forum.

    The goal of my project is to automatize some tests from a .dll coded in VB6 in a C# programs.

    Actually you know that we didn’t support VB 6 issue now, so the real issue is that how you create the unit test project in your side, you create the unit tests for a C# app, am I right? If so, whether you could create/run tests well without the VB code, which VS version are you using?

    *“System.Runtime.InteropServices.InvalidComObjectException: COM object that has been separated from its underlying RCW cannot be used.”*

    Based on the error message in your unit test, maybe you could check whether it is related to the ExecutionThread element

    http://blogs.msdn.com/b/martijnh/archive/2009/12/31/unit-testing-com-object-that-has-been-separated-from-its-underlying-rcw-cannot-be-used.aspx

    Best Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Monday, June 16, 2014 8:33 AM
  • Hi,

    Thank you for your reply !

    Actually you know that we didn’t support VB 6 issue now, so the real issue is that how you create the unit test project in your side, you create the unit tests for a C# app, am I right?

    Yes I make my test for a C# app .

    If so, whether you could create/run tests well without the VB code, which VS version are you using?

    Yes I use VB .dll in my C# Project and I work vith Visual Studio 2012.

    Based on the error message in your unit test, maybe you could check whether it is related to the ExecutionThread element

    In the link, they talk about testrunconfig but I don’t have any .testrunconfig and I don’t find this element when I tried to add an item in my solution. Do you have any Idea (It is the same than testseeting?)

    Respectfully.

     

     

    Thursday, June 19, 2014 8:18 AM
  • Hi Arkieffer,

    >>Do you have any Idea (It is the same than testseeting?)

    You could open the .testsettings file with XML:

    ...

    <Execution> 

      <ExecutionThread apartmentState="MTA"/>   

    </Execution>

    </TestSettings>

    http://ralessi.wordpress.com/2013/09/11/mta-testing-on-vs2012/

    Note: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you.

    Microsoft does not control these sites and has not tested any software or information found on these sites;

    Therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there.

    There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

    Best Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, June 20, 2014 6:40 AM
  • It's works thank you very much !

    Respectfully.

    Armelle Kieffer

    Monday, June 23, 2014 4:08 PM