internal static string GetTempAssemblyPath(string baseDir, Assembly assembly, string defaultNamespace)
{
if (assembly.IsDynamic)
{
throw new InvalidOperationException(SR.XmlPregenAssemblyDynamic);
}
try
{
if (baseDir != null && baseDir.Length > 0)
{
// check that the dirsctory exists
if (!Directory.Exists(baseDir))
{
throw new UnauthorizedAccessException(SR.Format(SR.XmlPregenMissingDirectory, baseDir));
}
}
else
{
baseDir = Path.GetTempPath();
// check that the dirsctory exists
if (!Directory.Exists(baseDir))
{
throw new UnauthorizedAccessException(SR.XmlPregenMissingTempDirectory);
}
}
if (baseDir.EndsWith("\\", StringComparison.Ordinal))
baseDir += GetTempAssemblyName(assembly.GetName(), defaultNamespace);
else
baseDir += "\\" + GetTempAssemblyName(assembly.GetName(), defaultNamespace);
}
finally
{
}
return baseDir + ".dll";
}