Microsoft Developer Network > 포럼 홈 > Visual Studio Team System - Testing > Unit test AppDomain names and custom performance counters
질문하기질문하기
 

답변됨Unit test AppDomain names and custom performance counters

  • 2006년 8월 4일 금요일 오후 6:38Peter RitchieMVP사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     

    I'm getting a really strange InvalidOperationException exception when trying to invoke a web service method from within a unit test.

    The message from the exception is "Instance names used for writing to custom counters must be 127 characters or less."  You can imagine my bewilderment at the message because I do not use custom counters in my unit test or in the web service.

    Looking at the stack I see a call to System.Diagnostics.SharedPerformanceCounter's ctor.  And to my surprise I see parameters like:

    (string catName = ".net clr networking", string counterName = "connections established", string instanceName = "unittestadapterdomain_forc:_documents and settings_XXXXXX_my documents_visual studio 2005_projects_XXXXXXXXXXXXXXXXXXXX_testresults_XXXXXX_XXXXXXXXXXXX 2006-08-04 14_11_01_out_unittests.dll[4036]", System.Diagnostics.PerformanceCounterInstanceLifetime lifetime = Process)

    [were sensitive data is replaced char-for-char by 'X']

    Clearly using a path for the instanceName parameter is a really bad idea, given a path can contain up to 260 characters and a performance counter instance name is limited to 127 characters.

    I get the impression this string is the name of the AppDomain for the unit test.  Is there anything I can do to get around this?

답변

  • 2006년 8월 8일 화요일 오후 6:20Boris Vidolov MSFT 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     답변됨

    Hello Peter,

    Yes, you are right - the name of the AppDomain is in the form above. We are currently changing the design around creation of the AppDomains for the next version of Visual Studio. The following steps will make that name shorter and could potentially fix the problem for you:

    1.     Edit the test run configuration file in an XML editor and modify the following two fields:

    <userDeploymentRoot type="System.String">c:\temp</userDeploymentRoot>

    <useDefaultDeploymentRoot type="System.Boolean"> False</useDefaultDeploymentRoot>

    2.     Save the file and open it in the test run configuration editor

    3.     Go to “General” pane, set “User-defined scheme” for the test run naming.

    4.     Add some short prefix, e.g. MyRun

    5.     Uncheck “Append date-time stamp”

    6.     Save the test run configuration and retry the run.

    Again, I am sorry about this problem and I will make sure that it won’t appear in the next version.

     

    Regards,

    Boris

     

모든 응답

  • 2006년 8월 8일 화요일 오후 6:20Boris Vidolov MSFT 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     답변됨

    Hello Peter,

    Yes, you are right - the name of the AppDomain is in the form above. We are currently changing the design around creation of the AppDomains for the next version of Visual Studio. The following steps will make that name shorter and could potentially fix the problem for you:

    1.     Edit the test run configuration file in an XML editor and modify the following two fields:

    <userDeploymentRoot type="System.String">c:\temp</userDeploymentRoot>

    <useDefaultDeploymentRoot type="System.Boolean"> False</useDefaultDeploymentRoot>

    2.     Save the file and open it in the test run configuration editor

    3.     Go to “General” pane, set “User-defined scheme” for the test run naming.

    4.     Add some short prefix, e.g. MyRun

    5.     Uncheck “Append date-time stamp”

    6.     Save the test run configuration and retry the run.

    Again, I am sorry about this problem and I will make sure that it won’t appear in the next version.

     

    Regards,

    Boris

     

  • 2006년 8월 9일 수요일 오후 6:41Peter RitchieMVP사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
     Boris Vidolov MSFT wrote:

    Hello Peter,

    Yes, you are right - the name of the AppDomain is in the form above. We are currently changing the design around creation of the AppDomains for the next version of Visual Studio. The following steps will make that name shorter and could potentially fix the problem for you:

    1.     Edit the test run configuration file in an XML editor and modify the following two fields:

    <userDeploymentRoot type="System.String">c:\temp</userDeploymentRoot>

    <useDefaultDeploymentRoot type="System.Boolean"> False</useDefaultDeploymentRoot>

    2.     Save the file and open it in the test run configuration editor

    3.     Go to “General” pane, set “User-defined scheme” for the test run naming.

    4.     Add some short prefix, e.g. MyRun

    5.     Uncheck “Append date-time stamp”

    6.     Save the test run configuration and retry the run.

    Again, I am sorry about this problem and I will make sure that it won’t appear in the next version.

     

    Regards,

    Boris

     

    Thanks, Boris.  Just gave it a try and it is a valid workaround.

    Thanks again.

  • 2007년 10월 4일 목요일 오전 1:37Enoc Pardue 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     

    Hi Boris,

     

    The problem still exists in the Unit Testing code that ships with VS2008 Beta2, about 1 year after you said you would not let the next version ship with it (unless you mean the RTM).  Also, the workaround does not work in VS2008 Beta2.  I resorted to creating a special folder structure off of C:\ in order to ensure that the working path of the project was short enough to avoid making the AppDomain name longer than 127 characters.

     

    Regards,

    Enoc Pardue

  • 2007년 10월 4일 목요일 오후 3:24Peter RitchieMVP사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     

    Enoc, I opened a bug about this on Connect around the time I created this thread.  See https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=176361  Voting/validation, I'm told, increases the likelihood the bug will get fixed.  I'm trying to followup on what's going on with this issue in Orcas.

  • 2008년 8월 21일 목요일 오후 6:31Jay Thaler 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     

     

    It looks like they closed your Connect entry without giving any solution or workaround.  There is something you can do, though.

     

    In the testrunconfig file, you can add an element similar to the following:

    <NamingScheme baseName="MyTests" appendTimeStamp="false" useDefault="false" />

     

  • 2008년 8월 21일 목요일 오후 6:33Peter RitchieMVP사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
     Jay Thaler wrote:

     

    It looks like they closed your Connect entry without giving any solution or workaround.
    Yep, they're suggesting it's an external problem.  I've given up on the issue.