How to read assembly attributes

This is reasonably easy. You have to use reflection. You need an instance of Assembly that represents the assembly with the attributes you want to read. An easy way of getting this is to do: typeof(MyTypeInAssembly).Assembly Then you can do this, for example: object[] attributes = assembly.GetCustomAttributes(typeof(AssemblyProductAttribute), false); AssemblyProductAttribute attribute = null; if (attributes.Length > … Read more

Gacutil.exe successfully adds assembly, but assembly not viewable in explorer. Why?

That’s because you use the .NET 4.0 version of gacutil.exe. It stores the assembly in a different GAC, the one in c:\windows\microsoft.net\assembly. Where all .NET 4.0 assemblies are stored. There is no shell extension handler for that one, the folders are visible as-is. You can have a look-see with Windows Explorer, .you’ll see the internal … Read more

C# compiling for 32/64 bit, or for ‘Any CPU’? [duplicate]

On a 32-bit machine: Any CPU: runs as a 32-bit process, can load Any CPU and x86 assemblies, will get BadImageFormatException if it tries to load an x64 assembly. x86: same as Any CPU. x64: BadImageFormatException always. On a 64-bit machine: Any CPU: runs as a 64-bit process, can load Any CPU and x64 assemblies, … Read more

Is there a way to force all referenced assemblies to be loaded into the app domain?

This seemed to do the trick: var loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies().ToList(); var loadedPaths = loadedAssemblies.Select(a => a.Location).ToArray(); var referencedPaths = Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory, “*.dll”); var toLoad = referencedPaths.Where(r => !loadedPaths.Contains(r, StringComparer.InvariantCultureIgnoreCase)).ToList(); toLoad.ForEach(path => loadedAssemblies.Add(AppDomain.CurrentDomain.Load(AssemblyName.GetAssemblyName(path)))); As Jon noted, the ideal solution would need to recurse into the dependencies for each of the loaded assemblies, but in my specific scenario … Read more

Namespace or Assembly?

System.Data is a namespace, System.Data.DLL (the file) is an assembly. A namespace is a logical grouping of types (mostly to avoid name collisions). An assembly can contain types in multiple namespaces (System.DLL contains a few…), and a single namespace can be spread across assemblies (e.g. System.Threading).

How did Microsoft create assemblies that have circular references?

I can only tell how the Mono Project does this. The theorem is quite simple, though it gives a code mess. They first compile System.Configuration.dll, without the part needing the reference to System.Xml.dll. After this, they compile System.Xml.dll the normal way. Now comes the magic. They recompile System.configuration.dll, with the part needing the reference to … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)