HRESULT CDebugLog::Init(IApplicationContext *pAppCtx, IAssemblyName* pName, LPCWSTR szCodebase)
{
    HRESULT hr = S_OK;
    _ASSERTE(pName || szCodebase);

    hr = SetAsmName(pName, szCodebase);
    if (FAILED(hr)) {
        goto Exit;
    }

    hr = SetProperties(pAppCtx);

Exit:
    return hr;
}
Beispiel #2
0
HRESULT CDebugLog::Init(IApplicationContext *pAppCtx, LPCWSTR pwzAsmName)
{
    HRESULT                                  hr = S_OK;
    LPWSTR                                   wzAppName = NULL;

    if (!pwzAsmName) {
        hr = E_INVALIDARG;
        goto Exit;
    }

    hr = SetAsmName(pwzAsmName);
    if (FAILED(hr)) {
        goto Exit;
    }
    
    // Get the executable name

    hr = ::AppCtxGetWrapper(pAppCtx, ACTAG_APP_NAME, &wzAppName);
    if (FAILED(hr)) {
        goto Exit;
    }

    if (wzAppName && lstrlenW(wzAppName)) {
        _wzEXEName = WSTRDupDynamic(wzAppName);
        if (!_wzEXEName) {
            hr = E_OUTOFMEMORY;
            goto Exit;
        }
    }
    else {
        LPWSTR               wzFileName;

        // Didn't find EXE name in appctx. Use the .EXE name.

        wzFileName = PathFindFileName(g_wzEXEPath);
        ASSERT(wzFileName);

        _wzEXEName = WSTRDupDynamic(wzFileName);
        if (!_wzEXEName) {
            hr = E_OUTOFMEMORY;
            goto Exit;
        }
    }

    // Log path
    
    if (!PAL_FetchConfigurationString(TRUE, REG_VAL_FUSION_LOG_PATH, _szLogPath, MAX_PATH))
    {
        // fallback to default
        if (!PAL_GetUserConfigurationDirectory(_szLogPath, MAX_PATH))
        {
            hr = HRESULT_FROM_WIN32(GetLastError());
            goto Exit;
        }

        StrCatBuff(_szLogPath, L"\\FusionLogs", MAX_PATH);
    }

    PathRemoveBackslashW(_szLogPath);

Exit:
    SAFEDELETEARRAY(wzAppName);

    return hr;
}