C#: why sign an assembly?

Why would the previous author have signed the assemblies in this way? No idea, maybe he wanted all his assemblies to be signed with the same key. Is signing assemblies necessary and what would be wrong with not signing it? No, it is not necessary but it is a mechanism allowing you to ensure the … Read more

What are the best practices for using Assembly Attributes?

We’re using a global file called GlobalAssemblyInfo.cs and a local one called AssemblyInfo.cs. The global file contains the following attributes: [assembly: AssemblyProduct(“Your Product Name”)] [assembly: AssemblyCompany(“Your Company”)] [assembly: AssemblyCopyright(“Copyright © 2008 …”)] [assembly: AssemblyTrademark(“Your Trademark – if applicable”)] #if DEBUG [assembly: AssemblyConfiguration(“Debug”)] #else [assembly: AssemblyConfiguration(“Release”)] #endif [assembly: AssemblyVersion(“This is set by build process”)] [assembly: AssemblyFileVersion(“This … Read more

Can I load a .NET assembly at runtime and instantiate a type knowing only the name?

Yes. You need to use Assembly.LoadFrom to load the assembly into memory, then you can use Activator.CreateInstance to create an instance of your preferred type. You’ll need to look the type up first using reflection. Here is a simple example: Assembly assembly = Assembly.LoadFrom(“MyNice.dll”); Type type = assembly.GetType(“MyType”); object instanceOfMyType = Activator.CreateInstance(type); Update When you … Read more

Why should you remove unnecessary C# using directives?

There are few reasons for removing unused using(s)/namespaces, besides coding preference: removing the unused using clauses in a project, can make the compilation faster because the compiler has fewer namespaces to look-up types to resolve. (this is especially true for C# 3.0 because of extension methods, where the compiler must search all namespaces for extension … Read more

How to fix “Referenced assembly does not have a strong name” error

To avoid this error you could either: Load the assembly dynamically, or Sign the third-party assembly. You will find instructions on signing third-party assemblies in .NET-fu: Signing an Unsigned Assembly (Without Delay Signing). Signing Third-Party Assemblies The basic principle to sign a thirp-party is to Disassemble the assembly using ildasm.exe and save the intermediate language … Read more

How can I get the assembly file version

See my comment above asking for clarification on what you really want. Hopefully this is it: System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly(); System.Diagnostics.FileVersionInfo fvi = System.Diagnostics.FileVersionInfo.GetVersionInfo(assembly.Location); string version = fvi.FileVersion;

How to enable assembly bind failure logging (Fusion) in .NET

Add the following values to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fusion Add: DWORD ForceLog set value to 1 DWORD LogFailures set value to 1 DWORD LogResourceBinds set value to 1 DWORD EnableLog set value to 1 String LogPath set value to folder for logs (e.g. C:\FusionLog\) Make sure you include the backslash after the folder name and that the Folder … Read more

What are differences between AssemblyVersion, AssemblyFileVersion and AssemblyInformationalVersion?

AssemblyVersion Where other assemblies that reference your assembly will look. If this number changes, other assemblies must update their references to your assembly! Only update this version if it breaks backward compatibility. The AssemblyVersion is required. I use the format: major.minor (and major for very stable codebases). This would result in: [assembly: AssemblyVersion(“1.3”)] If you’re … Read more

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