应用程序池重启后,GetManifestResourceNames()有时会失败

时间:2014-02-10 21:53:00

标签: c# asp.net iis application-pool

在极少数情况下,以下代码会在应用程序池被回收后立即返回损坏的字符串。没有抛出或捕获异常。一旦它开始发生,它将继续失败,直到IIS重新启动。

try {
    foreach (string resourceName in System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceNames())
        if (resourceName.Contains(LicenseResourceName))
            return System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName);

    throw new Exception(" \"" + LicenseResourceName + "\" not found in .GetManifestResourceNames()");
} catch (Exception ex) {
    var logger = new Logging.SqlLogger(System.Reflection.MethodBase.GetCurrentMethod());
    logger.Error("AsposeLicense Error " + ex);
}

0 个答案:

没有答案