Microsoft MVP성태의 닷넷 이야기
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 

(시리즈 글이 6개 있습니다.)
오류 유형: 534. mstest.exe 실행 시 "Visual Studio Enterprise is required to execute the test." 오류
; https://www.sysnet.pe.kr/2/0/11886

개발 환경 구성: 438. mstest, QTAgent의 로그 파일 설정 방법
; https://www.sysnet.pe.kr/2/0/11889

개발 환경 구성: 439. "Visual Studio Enterprise is required to execute the test." 메시지와 관련된 코드 기록
; https://www.sysnet.pe.kr/2/0/11890

오류 유형: 539. mstest 실행 시 "The directory name is invalid." 오류 발생
; https://www.sysnet.pe.kr/2/0/11902

오류 유형: 575. mstest.exe - System.Resources.MissingSatelliteAssemblyException: The satellite assembly named "Microsoft.VisualStudio.ProductKeyDialog.resources.dll, ..."
; https://www.sysnet.pe.kr/2/0/12044

오류 유형: 576. mstest.exe 실행 시 "Visual Studio Enterprise is required to execute the test." 오류 - 두 번째 이야기
; https://www.sysnet.pe.kr/2/0/12045




"Visual Studio Enterprise is required to execute the test." 메시지와 관련된 코드 기록

지난 글에서,

mstest.exe 실행 시 "Visual Studio Enterprise is required to execute the test." 오류
; https://www.sysnet.pe.kr/2/0/11886

"Visual Studio Enterprise"가 설치되어 있는데도 "Visual Studio Enterprise is required to execute the test." 오류 메시지가 발생하는 상황을 설명했는데요, 그때의 스택 트레이스를 보면 다음과 같습니다.

(mstest.exe, PID 24268, Thread 21) ControllerExecution: Received exception calling InitializePlugin for test e77946db-2d9f-4453-b207-e1e3f83f7784: Microsoft.VisualStudio.TestTools.WebStress.LoadTestLicenseViolationException: Visual Studio Enterprise is required to execute the test.
   at Microsoft.VisualStudio.TestTools.WebStress.LoadTestUserLicenseManager.CheckForLoadTestExecution()
   at Microsoft.VisualStudio.TestTools.WebStress.LoadTestResultsCollector.Initialize(TestRun testRun, String[] agentNames)
   at Microsoft.VisualStudio.TestTools.WebStress.LoadTestControllerPlugin.Initialize(IControllerContext testContext)
   at Microsoft.VisualStudio.TestTools.Controller.ControllerPluginManager.InitializePlugin(Guid executionId)
   at Microsoft.VisualStudio.TestTools.Controller.ControllerExecution.SignalSyncStart(Object state)

이와 관련된 소스 코드들의 추적을 기록 차원에서 남깁니다.




// C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\PrivateAssemblies\Microsoft.VisualStudio.QualityTools.ControllerObject.dll
// Microsoft.VisualStudio.QualityTools.ControllerObject, Version=16.0.0.0

internal class ControllerPluginManager
{
    // Fields
    private Dictionary<Guid, ControllerPlugin> m_plugins;

    // Methods
    public ControllerPluginManager();
    public void CleanupPlugins();
    public void CleanupTest(Guid execId);
    public static IControllerPlugin CreateControllerPlugin(ITestElement testElement);
    public static void DeleteTestRun(Guid guidTestRunId, IExecutionRunConfiguration runConfig, ControllerInformation controllerInformation);
    public IControllerPlugin FindPlugin(Guid executionId);
    public void InitializePlugin(Guid executionId)
    {
        ControllerPlugin plugin;
        if (this.m_plugins.TryGetValue(executionId, out plugin) && (plugin != null))
        {
            ControllerPlugin plugin2 = plugin;
            lock (plugin2)
            {
                if (plugin.Initialized)
                {
                    return;
                }
                plugin.Initialized = true;
            }
            EqtTrace.Info("ControllerPluginManager: Calling Initialize on ControllerPlugin for test " + executionId.ToString());
            plugin.Plugin.Initialize(plugin.Context);
            EqtTrace.Info("ControllerPluginManager: Calling TestAgentsReady on ControllerPlugin for test " + executionId.ToString());
            plugin.Plugin.TestAgentsReady(plugin.Context.AgentNames);
        }
    }

    public IControllerPlugin LoadPlugin(ControllerExecution execution, ITestElement testElement);
    public void SetMessageSinkBad(Guid executionId);
}

// Microsoft.VisualStudio.QualityTools.LoadTest, Version=16.0.0.0 
// C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\PrivateAssemblies

internal class LoadTestResultsCollector : ICounterProvider
{
    // ...[생략]...

    public LoadTestResultsCollector(WebTestSuite suite, LoadTestIntervalCallback intervalDataCallback, LoadTestResultsCollectorStatusCallback statusCallback, IControllerContext controllerContext)
    {
        // ...[생략]...
        this.m_suite = suite;
        // ...[생략]...
    }
    
    public void Initialize(TestRun testRun, string[] agentNames)
    {
        // ...[생략]...
        this.m_licenseManager = new LoadTestUserLicenseManager(this.m_suite.AvailableFeatures, isRemote);
        try
        {
            this.m_licenseManager.CheckForLoadTestExecution();
            this.m_licenseManager.CheckForRemoteExecution();
            this.m_licenseManager.CheckUserCountForLoadTest((long) this.m_suite.GetMaximumUserLoad());
        }
        catch (LoadTestLicenseViolationException exception4)
        {
            this.ProcessException(exception4, this.m_counterWriter > null, false);
            throw;
        }

        // ...[생략]...
    }

    internal class LoadTestControllerPlugin : IControllerPlugin
    {
        public void Initialize(IControllerContext testContext)
        {
            CheapDateTime.Initialize();
            this.m_context = testContext;
            this.m_suite = this.m_context.get_TestElement();
            // ...[생략]...
        }
    }

    // ...[생략]...
}

internal class LoadTestUserLicenseManager
{
    // Fields
    private LoadTestFeature m_allowedFeatures;
    private bool m_isRemote;

    // Methods
    internal LoadTestUserLicenseManager(LoadTestFeature allowedFeatures, bool isRemote)
    {
        this.m_allowedFeatures = allowedFeatures;
        this.m_isRemote = isRemote;
    }
    
    public void CheckForLoadTestExecution()
    {
        if ((this.m_allowedFeatures & 4) == null)
        {
            WebTestLoadTrace.Warning("LoadTestResultsCollector.Initialize(): MaxAllowedVUsers is 0.");
            LoadTestLicenseViolationException exception = new LoadTestLicenseViolationException((string) Messages.WebLoadTestExecution_NoLicenseShort);
            throw exception;
        }
    }
 
    public void CheckForRemoteExecution();
    public void CheckUserCountForLoadTest(long userLoad);
}

[CompilerGenerated, TypeIdentifier("A94BC0A0-5884-4D45-8C9E-D9BF9CA0C99A", "Microsoft.VisualStudio.LicenseManagement.Interop._VSSKUEdition")]
public enum _VSSKUEdition
{
    VSEDITION_UNKNOWN,
    VSEDITION_IntShell,
    VSEDITION_Professional,
    VSEDITION_Premium,
    VSEDITION_Ultimate
}

internal class LicenseHandler // Microsoft.VisualStudio.TestTools.WebStress
{
    // Methods
    public LicenseHandler()
    {
        try
        {
            this.InitializeLoadTestLicenseInfo();
        }
        catch (Exception exception)
        {
            /*
            "mstest.exe 실행 시 "Visual Studio Enterprise is required to execute the test." 오류" 글에서 설명한 "Microsoft.VisualStudio.Threading" 로딩 예외의 기록이 여기서 발생한 것입니다.
            
            */
            WebTestLoadTrace.Verbose("LicenseHandler(): Failed to Initialize LoadTestLicense Info: " + exception.ToString());
        }
    }

    [MethodImpl(MethodImplOptions.NoInlining)]
    private void InitializeLoadTestLicenseInfo()
    {
        IVsLicensingState state = VsLicensingStateInitializationHelpers.CreateIVsLicensingStateForOnlineLicensingSKU(OnlineLicensingSKUs.VisualStudio);
        _VSSKUEdition vsEdition = (_VSSKUEdition) state.GetVsEdition();
        WebTestLoadTrace.Verbose("LicenseHandler.InitializeLoadTestLicenseInfo(): skuEdition: " + vsEdition);
        this.IsLicensedForLoadTest = vsEdition == _VSSKUEdition.VSEDITION_Ultimate;
        if (!this.IsLicensedForLoadTest)
        {
            WebTestLoadTrace.Error("LicenseHandler.InitializeLoadTestLicenseInfo(): Failed to Initialize LoadTestLicense Info. Sku is not ultimate");
        }
        else
        {
            IVsClientRights clientRights = null;
            state.RefreshClientRights();
            state.ValidateClientRights(out clientRights, null);
            this.UpdateLicensingInformation(clientRights);
        }
    }

    private void UpdateLicensingInformation(IVsClientRights clientRights)
    {
        if (clientRights == null)
        {
            WebTestLoadTrace.Error("LicenseHandler.UpdateLicensingInformation(): unable to fetch clientRights ");
        }
        else if (!clientRights.IsLicenseGood)
        {
            WebTestLoadTrace.Error("LicenseHandler.UpdateLicensingInformation(): clientrights' license is not valid.");
        }
        else
        {
            this.AvailableFeatures = 4;
            _VSLicenseType licenseType = (_VSLicenseType) clientRights.LicenseType;
            this.IsLicensedForAllLoadTestFeatures = ((this.IsLicensedForLoadTest && (licenseType != _VSLicenseType.VSLICTYPE_UNKNOWN)) && ((licenseType != _VSLicenseType.VSLICTYPE_TrialPID) && (licenseType != _VSLicenseType.VSLICTYPE_VSExtensionTrial))) && (licenseType != _VSLicenseType.VSLICTYPE_PrereleaseTrialPID);
            WebTestLoadTrace.Verbose("LicenseHandler.UpdateLicensingInformation(): licenseType: " + licenseType);
            if (this.IsLicensedForAllLoadTestFeatures)
            {
                this.AvailableFeatures |= 8;
                this.AvailableFeatures |= 0x20;
            }
        }
    }

    // Properties
    public LoadTestFeature AvailableFeatures { get; [CompilerGenerated] private set; }
    public bool IsLicensedForAllLoadTestFeatures { get; [CompilerGenerated] private set; }
    public bool IsLicensedForLoadTest { get; [CompilerGenerated] private set; }
}

// C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\PrivateAssemblies\
// Microsoft.VisualStudio.Shell.Connected, Version=16.0.0.0

public enum OnlineLicensingSKUs
{
    VisualStudio,
    VSWinExpress,
    VWDExpress,
    WDExpress
}

public static class VsLicensingStateInitializationHelpers
{
    // Fields
    private const string InstallDirValueName = "InstallDir";

    // Methods
    public static IVsLicensingState CreateIVsLicensingStateForOnlineLicensingSKU(OnlineLicensingSKUs sku)
    {
        IVsClientRightsTokenCacheManager clientRightsTokenCacheManager = new VsClientRightsTokenCacheManager();
        IVsLicensingState state = new VsLicensingState();
        if (state != null)
        {
            IVsLicensingStateInitialize initialize = (IVsLicensingStateInitialize) state;
            Guid subscriptionLicenseId = new Guid(sku.LicenseId());
            initialize.InitializeForPidAndOnlineLicensing(null, (int) sku.ProductFamily(), ref subscriptionLicenseId, sku.RightsName(), sku.RegistryRoot(), clientRightsTokenCacheManager, null);
        }
        return state;
    }

    public static IVsLicensingState CreateIVsLicensingStateForPidLicensedSKU(_VSPIDFamily pidFamily);
    public static string GetVisualStudioInstallPath();
}

public static class VsLicensingStateInitializationConstants
{
    // Methods
    public static string LicenseId(this OnlineLicensingSKUs sku)
    {
        switch (sku)
        {
            case OnlineLicensingSKUs.VisualStudio:
                return "715f10eb-9e99-11d2-bfc2-00c04f990235";

            case OnlineLicensingSKUs.VSWinExpress:
                return "E16EC553-041C-403A-A275-958469FCDE74";

            case OnlineLicensingSKUs.VWDExpress:
                return "68CBDD3E-C6BC-4d26-84B6-6411EA3C327A";

            case OnlineLicensingSKUs.WDExpress:
                return "971DCC97-7904-4F36-9744-D21D39B557B3";
        }
        throw new ArgumentException("Invalid sku type for LicenseIds");
    }

    public static _VSPIDFamily ProductFamily(this OnlineLicensingSKUs sku)
    {
        switch (sku)
        {
            case OnlineLicensingSKUs.VisualStudio:
                return _VSPIDFamily.VSPID_GROUP_VS;

            case OnlineLicensingSKUs.VSWinExpress:
                return _VSPIDFamily.VSPID_GROUP_VSWIN;

            case OnlineLicensingSKUs.VWDExpress:
                return _VSPIDFamily.VSPID_GROUP_VWD;

            case OnlineLicensingSKUs.WDExpress:
                return _VSPIDFamily.VSPID_GROUP_V1;
        }
        throw new ArgumentException("Invalid sku type for ProductFamily");
    }

    public static string RegistryRoot(this OnlineLicensingSKUs sku) => 
        Path.Combine(@"Software\Microsoft", sku.RightsName(), VSGeneralVersion);

    public static string RightsName(this OnlineLicensingSKUs sku)
    {
        switch (sku)
        {
            case OnlineLicensingSKUs.VisualStudio:
                return "VisualStudio";

            case OnlineLicensingSKUs.VSWinExpress:
                return "VSWinExpress";

            case OnlineLicensingSKUs.VWDExpress:
                return "VWDExpress";

            case OnlineLicensingSKUs.WDExpress:
                return "WDExpress";
        }
        throw new ArgumentException("Invalid sku type for RightsName");
    }
    
    // Properties
    public static string VSGeneralVersion => "16.0";
}

// C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE
// Microsoft.VisualStudio.ProductKeyDialog.dll

public class VsLicensingState : IVsLicensingState, IVsLicensingStateInitialize2, IVsLicensingStateInitialize, IVsCurrentVsEdition
{
    // ...[생략]...
    private VsClientRightsToken GetUserClientRightTokens(VisualStudioLicenseSource source);

    public int GetVsEdition() => ((int) ProductLicensingUtilities.MapToVSSKUEdition((_VSSKUEdition2) this.CurrentVsEdition));

    [AsyncStateMachine(typeof(<InitializeAsync>d__30))]
    private Task InitializeAsync(JoinableTaskContext joinableTaskContext, int productFamily, bool isSubscriptionAware, Guid subscriptionLicenseId, string subscriptionRightsName, string registryRoot, IVsClientRightsTokenCacheManager vsClientRightsTokenCacheManager, IVsOnlineLicensingManager onlineLicensingManager);

    public void InitializeForPidAndOnlineLicensing(object joinableTaskContext, int productFamily, ref Guid subscriptionLicenseId, string subscriptionRightsName, string registryRoot, IVsClientRightsTokenCacheManager clientRightsTokenCacheManager, IVsOnlineLicensingManager onlineLicensingManager)
    {
        JoinableTaskContext jtc = ((JoinableTaskContext) joinableTaskContext) ?? this.CreateJoinableTaskContext();
        Guid subscriptionLicenseIdLocal = subscriptionLicenseId;
        jtc.Factory.Run(() => this.InitializeForPidAndOnlineLicensingAsync(jtc, productFamily, subscriptionLicenseIdLocal, subscriptionRightsName, registryRoot, clientRightsTokenCacheManager, onlineLicensingManager));
    }
 
    public Task InitializeForPidAndOnlineLicensingAsync(JoinableTaskContext joinableTaskContext, int productFamily, Guid subscriptionLicenseId, string subscriptionRightsName, string registryRoot, IVsClientRightsTokenCacheManager clientRightsTokenCacheManager, IVsOnlineLicensingManager onlineLicensingManager) => 
        this.InitializeAsync(joinableTaskContext, productFamily, true, subscriptionLicenseId, subscriptionRightsName, registryRoot, clientRightsTokenCacheManager, onlineLicensingManager);


    public void InitializeForPidLicensingOnly(object joinableTaskContext, int productFamily, IVsOnlineLicensingManager onlineLicensingManager);
    public Task InitializeForPidLicensingOnlyAsync(JoinableTaskContext joinableTaskContext, int productFamily, IVsOnlineLicensingManager onlineLicensingManager);
    // ...[생략]...
}

internal static class ProductLicensingUtilities
{
    // Methods
    internal static bool EqualsDateTimeMax(DateTimeOffset expirationDate);
    internal static int GetMPCofCurrentVSInstance(IVsOnlineOperationLogger logger = null);
    internal static _VSSKUEdition2 GetVSSKUEditionFromSubscriptionFamilyLevel(string subscriptionFamilyLevel);

    internal static _VSSKUEdition MapToVSSKUEdition(_VSSKUEdition2 skuEdition2)
    {
        if (skuEdition2 <= _VSSKUEdition2.VSEDITION2_IntShell)
        {
            if (skuEdition2 == _VSSKUEdition2.VSEDITION2_UNKNOWN)
            {
                goto Label_0029;
            }
            if (skuEdition2 == _VSSKUEdition2.VSEDITION2_IntShell)
            {
                return _VSSKUEdition.VSEDITION_IntShell;
            }
            goto Label_0031;
        }
        if (skuEdition2 != _VSSKUEdition2.VSEDITION2_Community)
        {
            if (skuEdition2 == _VSSKUEdition2.VSEDITION2_Professional)
            {
                return _VSSKUEdition.VSEDITION_Professional;
            }
            if (skuEdition2 == _VSSKUEdition2.VSEDITION2_Ultimate)
            {
                return _VSSKUEdition.VSEDITION_Ultimate;
            }
            goto Label_0031;
        }
    Label_0029:
        return _VSSKUEdition.VSEDITION_UNKNOWN;
    Label_0031:
        return _VSSKUEdition.VSEDITION_UNKNOWN;
    }

    internal static string TrimPrefix(this string s, string prefix);
}




mstest.exe의 라이선스와 관련해 문제가 발생하면 위의 소스 코드에서 "WebTestLoadTrace"로 남겨지는 로그들을 함께 추적해 보면 원인을 추적할 수 있습니다. 한 가지 위의 소스 코드를 통해 알 수 있었던 재미있는 점은, Ultimate 에디션의 경우 명칭은 사라졌지만 결국 Enterprise의 내부 이름으로 남아 있다는 것입니다.

마지막으로, 실제적인 라이선스 체크는 PInvoke를 통한 내부 C/C++ 함수로 호출이 된다는 점!




[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]







[최초 등록일: ]
[최종 수정일: 5/8/2019]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




... 16  17  18  19  20  21  22  23  24  25  26  27  [28]  29  30  ...
NoWriterDateCnt.TitleFile(s)
12931정성태1/20/20226412개발 환경 구성: 632. ASP.NET Core 프로젝트를 AKS/k8s에 올리는 과정
12930정성태1/19/20227054개발 환경 구성: 631. AKS/k8s의 Volume에 파일 복사하는 방법
12929정성태1/19/20226854개발 환경 구성: 630. AKS/k8s의 Pod에 Volume 연결하는 방법
12928정성태1/18/20227000개발 환경 구성: 629. AKS/Kubernetes에서 호스팅 중인 pod에 shell(/bin/bash)로 진입하는 방법
12927정성태1/18/20226756개발 환경 구성: 628. AKS 환경에 응용 프로그램 배포 방법
12926정성태1/17/20227247오류 유형: 787. AKS - pod 배포 시 ErrImagePull/ImagePullBackOff 오류
12925정성태1/17/20227335개발 환경 구성: 627. AKS의 준비 단계 - ACR(Azure Container Registry)에 docker 이미지 배포
12924정성태1/15/20228825.NET Framework: 1134. C# - ffmpeg(FFmpeg.AutoGen)를 이용한 비디오 디코딩 예제(decode_video.c) [2]파일 다운로드1
12923정성태1/15/20227752개발 환경 구성: 626. ffmpeg.exe를 사용해 비디오 파일을 MPEG1 포맷으로 변경하는 방법
12922정성태1/14/20226807개발 환경 구성: 625. AKS - Azure Kubernetes Service 생성 및 SLO/SLA 변경 방법
12921정성태1/14/20225778개발 환경 구성: 624. Docker Desktop에서 별도 서버에 설치한 docker registry에 이미지 올리는 방법
12920정성태1/14/20226538오류 유형: 786. Camtasia - An error occurred with the camera: Failed to Add Video Sampler.
12919정성태1/13/20226350Windows: 199. Host Network Service (HNS)에 의해서 점유되는 포트
12918정성태1/13/20226591Linux: 47. WSL - shell script에서 설정한 환경 변수가 스크립트 실행 후 반영되지 않는 문제
12917정성태1/12/20225799오류 유형: 785. C# - The type or namespace name '...' could not be found (are you missing a using directive or an assembly reference?)
12916정성태1/12/20225529오류 유형: 784. TFS - One or more source control bindings for this solution are not valid and are listed below.
12915정성태1/11/20225807오류 유형: 783. Visual Studio - We didn't find any interpreters
12914정성태1/11/20227765VS.NET IDE: 172. 비주얼 스튜디오 2022의 파이선 개발 환경 지원
12913정성태1/11/20228279.NET Framework: 1133. C# - byte * (바이트 포인터)를 FileStream으로 쓰는 방법 [1]
12912정성태1/11/20228913개발 환경 구성: 623. ffmpeg.exe를 사용해 비디오 파일의 이미지를 PGM(Portable Gray Map) 파일 포맷으로 출력하는 방법 [1]
12911정성태1/11/20226223VS.NET IDE: 171. 비주얼 스튜디오 - 더 이상 만들 수 없는 "ASP.NET Core 3.1 Web Application (.NET Framework)" 프로젝트
12910정성태1/10/20226716제니퍼 .NET: 30. 제니퍼 닷넷 적용 사례 (8) - CPU high와 DB 쿼리 성능에 문제가 함께 있는 사이트
12909정성태1/10/20228104오류 유형: 782. Visual Studio 2022 설치 시 "Couldn't install Microsoft.VisualCpp.Redist.14.Latest"
12908정성태1/10/20225951.NET Framework: 1132. C# - ref/out 매개변수의 IL 코드 처리
12907정성태1/9/20226410오류 유형: 781. (youtube-dl.exe) 실행 시 "This app can't run on your PC" / "Access is denied." 오류 발생
12906정성태1/9/20227052.NET Framework: 1131. C# - 네임스페이스까지 동일한 타입을 2개의 DLL에서 제공하는 경우 충돌을 우회하는 방법 [1]파일 다운로드1
... 16  17  18  19  20  21  22  23  24  25  26  27  [28]  29  30  ...