当前位置: 首页>>代码示例>>C#>>正文


C# System.Reflection.AssemblyName.SetPublicKeyToken方法代码示例

本文整理汇总了C#中System.Reflection.AssemblyName.SetPublicKeyToken方法的典型用法代码示例。如果您正苦于以下问题:C# System.Reflection.AssemblyName.SetPublicKeyToken方法的具体用法?C# System.Reflection.AssemblyName.SetPublicKeyToken怎么用?C# System.Reflection.AssemblyName.SetPublicKeyToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Reflection.AssemblyName的用法示例。


在下文中一共展示了System.Reflection.AssemblyName.SetPublicKeyToken方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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();
        }
开发者ID:conniey,项目名称:dotnet-apiport,代码行数:14,代码来源:AssemblyIdentityHelpers.cs

示例2: Load

 private static System.Reflection.Assembly Load(string assemblyNameVal) {
     System.Reflection.AssemblyName assemblyName = new System.Reflection.AssemblyName(assemblyNameVal);
     byte[] publicKeyToken = assemblyName.GetPublicKeyToken();
     System.Reflection.Assembly asm = null;
     try {
         asm = System.Reflection.Assembly.Load(assemblyName.FullName);
     }
     catch (System.Exception ) {
         System.Reflection.AssemblyName shortName = new System.Reflection.AssemblyName(assemblyName.Name);
         if ((publicKeyToken != null)) {
             shortName.SetPublicKeyToken(publicKeyToken);
         }
         asm = System.Reflection.Assembly.Load(shortName);
     }
     return asm;
 }
开发者ID:ThinerZQ,项目名称:CrowdSourcingWithWWF,代码行数:16,代码来源:_CrowdSourcing.g.cs

示例3: initclr

// ReSharper disable InconsistentNaming
    public static void initclr()
// ReSharper restore InconsistentNaming    
    {
#if DEBUG_PRINT
        System.Console.WriteLine("Attempting to load Python.Runtime using standard binding rules... ");
#endif
#if USE_PYTHON_RUNTIME_PUBLIC_KEY_TOKEN
        var pythonRuntimePublicKeyTokenData = new byte[] { 0x50, 0x00, 0xfe, 0xa6, 0xcb, 0xa7, 0x02, 0xdd };
#endif

        // Attempt to find and load Python.Runtime using standard assembly binding rules.
        // This roughly translates into looking in order:
        // - GAC
        // - ApplicationBase
        // - A PrivateBinPath under ApplicationBase
        // With an unsigned assembly, the GAC is skipped.
        var pythonRuntimeName = new System.Reflection.AssemblyName("Python.Runtime")
            {
#if USE_PYTHON_RUNTIME_VERSION
                Version = new System.Version("4.0.0.1"), 
#endif
                CultureInfo = System.Globalization.CultureInfo.InvariantCulture,
            };
#if USE_PYTHON_RUNTIME_PUBLIC_KEY_TOKEN
        pythonRuntimeName.SetPublicKeyToken(pythonRuntimePublicKeyTokenData);
#endif
        // We've got the AssemblyName with optional features; try to load it.
        System.Reflection.Assembly pythonRuntime;
        try
        {
            pythonRuntime = System.Reflection.Assembly.Load(pythonRuntimeName);
#if DEBUG_PRINT
            System.Console.WriteLine("Success!");
#endif
        }
        catch (System.IO.FileNotFoundException)
        {
            try
            {
                // If the above fails for any reason, we fallback to attempting to load "Python.Runtime.dll"
			    // from the directory this assembly is running in. "This assembly" is probably "clr.pyd",
			    // sitting somewhere in PYTHONPATH.  This is using Assembly.LoadFrom, and inherits all the
			    // caveats of that call.  See MSDN docs for details.
			    // Suzanne Cook's blog is also an excellent source of info on this:
			    // http://blogs.msdn.com/suzcook/
			    // http://blogs.msdn.com/suzcook/archive/2003/05/29/57143.aspx
			    // http://blogs.msdn.com/suzcook/archive/2003/06/13/57180.aspx

                var executingAssembly = System.Reflection.Assembly.GetExecutingAssembly();
                var assemblyDirectory = System.IO.Path.GetDirectoryName(executingAssembly.Location);
                if (assemblyDirectory == null)
                    throw new System.InvalidOperationException(executingAssembly.Location);
                var pythonRuntimeDllPath = System.IO.Path.Combine(assemblyDirectory, "Python.Runtime.dll");
#if DEBUG_PRINT
                System.Console.WriteLine("Attempting to load Python.Runtime from: '{0}'...", pythonRuntimeDllPath);
#endif
                pythonRuntime = System.Reflection.Assembly.LoadFrom(pythonRuntimeDllPath);
            }
            catch (System.InvalidOperationException) {
#if DEBUG_PRINT
                System.Console.WriteLine("Could not load Python.Runtime, so sad.");
#endif
                return;
            }
        }

        // Once here, we've successfully loaded SOME version of Python.Runtime
		// So now we get the PythonEngine and execute the InitExt method on it.
        var pythonEngineType = pythonRuntime.GetType("Python.Runtime.PythonEngine");
        pythonEngineType.InvokeMember("InitExt", System.Reflection.BindingFlags.InvokeMethod, null, null, null);
    }
开发者ID:ruisebastiao,项目名称:pythonnet,代码行数:72,代码来源:ClrModule.cs

示例4: GetAssemblyName

 public System.Reflection.AssemblyName GetAssemblyName()
 {
     if(this.assemblyName == null)
     {
         System.Reflection.AssemblyName aName = new System.Reflection.AssemblyName();
         aName.CultureInfo = new System.Globalization.CultureInfo(this.Culture == null ? "" : this.Culture);
         if(this.PublicKeyOrToken != null && this.PublicKeyOrToken.Length > 8)
             aName.Flags = System.Reflection.AssemblyNameFlags.PublicKey;
         if((this.Flags & AssemblyFlags.Retargetable) != 0)
             aName.Flags |= (System.Reflection.AssemblyNameFlags)AssemblyFlags.Retargetable;
         aName.HashAlgorithm = System.Configuration.Assemblies.AssemblyHashAlgorithm.SHA1;
         if(this.PublicKeyOrToken != null)
         {
             if(this.PublicKeyOrToken.Length > 8)
                 aName.SetPublicKey(this.PublicKeyOrToken);
             else if(this.PublicKeyOrToken.Length > 0)
                 aName.SetPublicKeyToken(this.PublicKeyOrToken);
         }
         else
             aName.SetPublicKey(new byte[0]);
         aName.Name = this.Name;
         aName.Version = this.Version;
         switch(this.Flags & AssemblyFlags.CompatibilityMask)
         {
             case AssemblyFlags.NonSideBySideCompatible:
                 aName.VersionCompatibility = System.Configuration.Assemblies.AssemblyVersionCompatibility.SameDomain;
                 break;
             case AssemblyFlags.NonSideBySideProcess:
                 aName.VersionCompatibility = System.Configuration.Assemblies.AssemblyVersionCompatibility.SameProcess;
                 break;
             case AssemblyFlags.NonSideBySideMachine:
                 aName.VersionCompatibility = System.Configuration.Assemblies.AssemblyVersionCompatibility.SameMachine;
                 break;
         }
         this.assemblyName = aName;
     }
     return this.assemblyName;
 }
开发者ID:modulexcite,项目名称:SHFB-1,代码行数:38,代码来源:Nodes.cs


注:本文中的System.Reflection.AssemblyName.SetPublicKeyToken方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。