本文整理汇总了C#中System.Reflection.AssemblyName类的典型用法代码示例。如果您正苦于以下问题:C# System.Reflection.AssemblyName类的具体用法?C# System.Reflection.AssemblyName怎么用?C# System.Reflection.AssemblyName使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
System.Reflection.AssemblyName类属于命名空间,在下文中一共展示了System.Reflection.AssemblyName类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InstallConfig
private BXWizardResult InstallConfig()
{
Directory.CreateDirectory(BXPath.MapPath("~/bitrix/updates"));
if (!File.Exists(BXPath.MapPath("~/bitrix/updates/updater.config")))
{
BXUpdaterConfig config = SiteUpdater.BXSiteUpdater.GetConfig();
config.UpdateUrl = GetMessage("Updater.Server") ?? "http://www.bitrixsoft.com";
config.Language = WizardContext.Locale;
config.Key = "";
System.Reflection.AssemblyName name = new System.Reflection.AssemblyName(typeof(BXUpdaterConfig).Assembly.FullName);
config.Version = new BXUpdaterVersion(name.Version.Major, name.Version.Minor, name.Version.Build);
string proxy = WizardContext.State.GetString("Options.UpdaterProxy");
if (!string.IsNullOrEmpty(proxy))
{
config.UseProxy = true;
config.ProxyAddress = proxy;
string user = WizardContext.State.GetString("Options.UpdaterProxyUsername");
if (!string.IsNullOrEmpty(user))
{
config.ProxyUsername = user;
string password = WizardContext.State.GetString("Options.UpdaterProxyPassword");
if (!string.IsNullOrEmpty(password))
config.ProxyPassword = password;
}
}
config.Update();
}
return Result.Action("finalize");
}
示例2: CurrentDomain_AssemblyResolve
System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
var ass = AppDomain.CurrentDomain.GetAssemblies();
var trgName = new System.Reflection.AssemblyName(args.Name);
foreach (var a in ass)
{
var aN = new System.Reflection.AssemblyName(a.FullName);
if (aN.Name == trgName.Name)
{
return a;
}
}
if (trgName.Name == "gnomorialib")
{
return System.Reflection.Assembly.Load(System.IO.File.ReadAllBytes(System.IO.Path.Combine(base_dir, trgName.Name + "Modded.dll")));
}
var file = System.IO.Path.Combine(base_dir, trgName.Name + ".dll");
if (trgName.Name == "GnomoriaModController")
{
return System.Reflection.Assembly.Load(System.IO.File.ReadAllBytes(file));
}
else if (System.IO.File.Exists(file))
{
return System.Reflection.Assembly.LoadFile(file);
}
return null;
}
示例3: CompileProject
public Assembly CompileProject(string projectFileName)
{
Assembly existing;
if (Compilations.TryGetValue(Path.GetFullPath(projectFileName), out existing))
{
return existing;
}
var project = new Microsoft.Build.BuildEngine.Project();
project.Load(projectFileName);
var projectName = Environment.NameTable.GetNameFor(project.EvaluatedProperties["AssemblyName"].Value);
var projectPath = project.FullFileName;
var compilerOptions = new SpecSharpOptions();
var assemblyReferences = new List<IAssemblyReference>();
var moduleReferences = new List<IModuleReference>();
var programSources = new List<SpecSharpSourceDocument>();
var assembly = new SpecSharpAssembly(projectName, projectPath, Environment, compilerOptions, assemblyReferences, moduleReferences, programSources);
var helper = new SpecSharpCompilationHelper(assembly.Compilation);
Compilations[Path.GetFullPath(projectFileName)] = assembly;
assemblyReferences.Add(Environment.LoadAssembly(Environment.CoreAssemblySymbolicIdentity));
project.Build("ResolveAssemblyReferences");
foreach (BuildItem item in project.GetEvaluatedItemsByName("ReferencePath"))
{
var assemblyName = new System.Reflection.AssemblyName(item.GetEvaluatedMetadata("FusionName"));
var name = Environment.NameTable.GetNameFor(assemblyName.Name);
var culture = assemblyName.CultureInfo != null ? assemblyName.CultureInfo.Name : "";
var version = assemblyName.Version == null ? new Version(0, 0) : assemblyName.Version;
var token = assemblyName.GetPublicKeyToken();
if (token == null) token = new byte[0];
var location = item.FinalItemSpec;
var identity = new AssemblyIdentity(name, culture, version, token, location);
var reference = Environment.LoadAssembly(identity);
assemblyReferences.Add(reference);
}
foreach (BuildItem item in project.GetEvaluatedItemsByName("ProjectReference"))
{
var name = Environment.NameTable.GetNameFor(Path.GetFileNameWithoutExtension(item.FinalItemSpec));
var location = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(project.FullFileName), item.FinalItemSpec));
var reference = CompileProject(location);
assemblyReferences.Add(reference);
}
foreach (BuildItem item in project.GetEvaluatedItemsByName("Compile"))
{
var location = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(project.FullFileName), item.FinalItemSpec));
var name = Environment.NameTable.GetNameFor(location);
var programSource = new SpecSharpSourceDocument(helper, name, location, File.ReadAllText(location));
programSources.Add(programSource);
}
return assembly;
}
示例4: Assembly
IAssembly IAssemblyLoader.Load(AssemblyName assembly)
{
try {
return new Assembly(new DefaultTypeLoader(), Load(assembly));
} catch(FileLoadException) {
return new MissingAssembly(assembly);
} catch(FileNotFoundException) {
return new MissingAssembly(assembly);
}
}
示例5: Main
static void Main()
{
AppDomain.CurrentDomain.AssemblyResolve += (s, e) =>
{
var filename = new System.Reflection.AssemblyName(e.Name).Name;
var path = System.IO.Directory.GetCurrentDirectory().Split(System.IO.Path.DirectorySeparatorChar).ToList();
while (path[path.Count() - 1] != "Bin")
path.RemoveAt(path.Count() - 1);
var pathBin = string.Join(System.IO.Path.DirectorySeparatorChar.ToString(), path);
path[path.Count() - 1] = "Lib";
var pathLib = string.Join(System.IO.Path.DirectorySeparatorChar.ToString(), path);
// Attempt to load from lib first
foreach (var file in System.IO.Directory.GetFiles(pathLib))
{
if (file.Split(System.IO.Path.DirectorySeparatorChar).Last().Split(new string[]{".dll"}, StringSplitOptions.None)[0] == filename)
return System.Reflection.Assembly.LoadFrom(file);
}
foreach (var dir in System.IO.Directory.GetDirectories(pathLib))
{
foreach (var file in System.IO.Directory.GetFiles(dir))
{
if (file.Split(System.IO.Path.DirectorySeparatorChar).Last().Split(new string[] { ".dll" }, StringSplitOptions.None)[0] == filename)
return System.Reflection.Assembly.LoadFrom(file);
}
}
// Attempt to load from bin
foreach (var file in System.IO.Directory.GetFiles(pathBin))
{
if (file.Split(System.IO.Path.DirectorySeparatorChar).Last().Split(new string[] { ".dll" }, StringSplitOptions.None)[0] == filename)
return System.Reflection.Assembly.LoadFrom(file);
}
foreach (var dir in System.IO.Directory.GetDirectories(pathBin))
{
foreach (var file in System.IO.Directory.GetFiles(dir))
{
if (file.Split(System.IO.Path.DirectorySeparatorChar).Last().Split(new string[] { ".dll" }, StringSplitOptions.None)[0] == filename)
return System.Reflection.Assembly.LoadFrom(file);
}
}
return null;
};
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
//Application.Run(new gameEditorMainForm());
//Application.Run(new TestJsonEdit());
//Application.Run(new Dialog.Forms.GuidSelector());
//Application.Run(new Dialog.Forms.GuidManagerForm());
Application.Run(new mainForm());
//new TestJsonEdit().Show();
//new mainForm().Show();
//new Dialog.Forms.GuidSelector().Show();
//new Dialog.Forms.GuidManagerForm().Show();
//Application.Run(new Form());
}
示例6: Load
ReflectionAssembly Load(AssemblyName assembly)
{
try {
return ReflectionAssembly.Load(assembly);
} catch (FileLoadException) {
var altPath = Path.Combine(binPath, assembly.Name + ".dll");
if (File.Exists(altPath))
return ReflectionAssembly.LoadFrom(altPath);
throw;
}
}
示例7: App
public App()
{
//integrated SQLite dll : unmanaged code
AppDomain.CurrentDomain.AssemblyResolve += (sender1, args) =>
{
string resourceName = new System.Reflection.AssemblyName(args.Name).Name + ".dll";
string resource = Array.Find(this.GetType().Assembly.GetManifestResourceNames(), element => element.EndsWith(resourceName));
EmbeddedAssembly.Load(resource, resourceName);
return EmbeddedAssembly.Get(args.Name);
};
}
示例8: CurrentDomain_AssemblyResolve
/// <summary>
/// Método para resolução das assemblies.
/// </summary>
/// <param name="sender">Application</param>
/// <param name="args">Resolving Assembly Name</param>
/// <returns>Assembly</returns>
static System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
string assemblyFullName;
System.Reflection.AssemblyName assemblyName;
string PRIMAVERA_COMMON_FILES_FOLDER = Instancia.daPastaConfig();//pasta dos ficheiros comuns especifica da versão do ERP PRIMAVERA utilizada.
assemblyName = new System.Reflection.AssemblyName(args.Name);
assemblyFullName = System.IO.Path.Combine(System.IO.Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFilesX86), PRIMAVERA_COMMON_FILES_FOLDER), assemblyName.Name + ".dll");
if (System.IO.File.Exists(assemblyFullName))
return System.Reflection.Assembly.LoadFile(assemblyFullName);
else
return null;
}
示例9: Parse
public static AssemblyIdentity Parse(INameTable nameTable, string formattedName)
{
var name = new System.Reflection.AssemblyName(formattedName);
return new AssemblyIdentity(nameTable.GetNameFor(name.Name),
name.CultureName,
name.Version,
name.GetPublicKeyToken(),
#if COREFX
"");
#else
name.CodeBase);
#endif
}
示例10: CurrentDomain_AssemblyResolve
static System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
System.Reflection.AssemblyName name = new System.Reflection.AssemblyName(args.Name);
if (name.Name.ToLowerInvariant().EndsWith(".resources")) return null;
string installPath = HpToolsLauncher.Helper.getLRInstallPath();
if (installPath == null)
{
log(Resources.CannotLocateInstallDir);
Environment.Exit((int)Launcher.ExitCodeEnum.Aborted);
}
//log(Path.Combine(installPath, "bin", name.Name + ".dll"));
return System.Reflection.Assembly.LoadFrom(Path.Combine(installPath, "bin", name.Name + ".dll"));
}
示例11: Global
public Global()
{
var root = ConfigurationManager.AppSettings["RootPath"];
AppDomain.CurrentDomain.AssemblyResolve += (object sender, ResolveEventArgs args) => {
var assemblyName = new System.Reflection.AssemblyName(args.Name);
string path = System.IO.Path.Combine (root, assemblyName.Name + ".dll");
if (System.IO.File.Exists (path))
{
return System.Reflection.Assembly.LoadFile (path);
}
return null;
};
}
示例12: Format
public static string Format(this AssemblyIdentity assemblyIdentity)
{
var name = new System.Reflection.AssemblyName();
name.Name = assemblyIdentity.Name.Value;
#if !COREFX
name.CultureInfo = new CultureInfo(assemblyIdentity.Culture);
#endif
name.Version = assemblyIdentity.Version;
name.SetPublicKeyToken(assemblyIdentity.PublicKeyToken.ToArray());
#if !COREFX
name.CodeBase = assemblyIdentity.Location;
#endif
return name.ToString();
}
示例13: FromResource
public static WriteableBitmap FromResource(this WriteableBitmap bmp, string relativePath)
{
if (bmp == null)
throw new ArgumentNullException("bmp");
var fullName = System.Reflection.Assembly.GetCallingAssembly().FullName;
var asmName = new System.Reflection.AssemblyName(fullName).Name;
using (var bmpStream = Application.GetResourceStream(new Uri(string.Format("{0};component/{1}", asmName, relativePath), UriKind.Relative)).Stream)
{
var bmpi = new BitmapImage();
bmpi.SetSource(bmpStream);
bmp = new WriteableBitmap(bmpi);
return bmp;
}
}
示例14: Main
static void Main(string[] args)
{
System.Reflection.AssemblyName myAssemblyName = new System.Reflection.AssemblyName("Fubar, Version=100.0.0.2001, Culture=sv-FI, PublicKeyToken=null");
Console.WriteLine("Name: {0}", myAssemblyName.Name);
Console.WriteLine("Version: {0}", myAssemblyName.Version);
Console.WriteLine("CultureInfo: {0}", myAssemblyName.CultureInfo);
Console.WriteLine("FullName: {0}", myAssemblyName.FullName);
Console.WriteLine("Assembly: {0}", typeof(Tuple<string, int>).Assembly.FullName);
Console.WriteLine("Type: {0}", typeof(Tuple<string, int>).FullName);
using (var program = new Program())
program.Run();
}
示例15: CreateRegExDLL
/// <summary>
///
/// </summary>
/// <param name="assmName"></param>
public static void CreateRegExDLL(string assmName)
{
RegexCompilationInfo[] RE = new RegexCompilationInfo[2]
{new RegexCompilationInfo("PATTERN", RegexOptions.Compiled,
"CompiledPATTERN", "Chapter_Code", true),
new RegexCompilationInfo("NAME", RegexOptions.Compiled,
"CompiledNAME", "Chapter_Code", true)};
System.Reflection.AssemblyName aName =
new System.Reflection.AssemblyName();
aName.Name = assmName;
Regex.CompileToAssembly(RE, aName);
}