Custom Assembly Attributes

Yes you can. We do this kind of thing. [AttributeUsage(AttributeTargets.Assembly)] public class MyCustomAttribute : Attribute { string someText; public MyCustomAttribute() : this(string.Empty) {} public MyCustomAttribute(string txt) { someText = txt; } … } To read use this kind of linq stmt. var attributes = assembly .GetCustomAttributes(typeof(MyCustomAttribute), false) .Cast<MyCustomAttribute>();

how to load all assemblies from within your /bin directory

Well, you can hack this together yourself with the following methods, initially use something like: string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); to get the path to your current assembly. Next, iterate over all DLL’s in the path using the Directory.GetFiles method with a suitable filter. Your final code should look like: List<Assembly> allAssemblies = new List<Assembly>(); string … Read more

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

C#: Custom assembly directory

You can add additional search paths to your app.config that it looks in to load assemblies. For example <runtime> <assemblyBinding xmlns=”urn:schemas-microsoft-com:asm.v1″> <probing privatePath=”lib;thirdParty” /> </assemblyBinding> </runtime> You can see more details here.

How to load a .NET assembly for reflection operations and subsequently unload it?

From the MSDN documentation of System.Reflection.Assembly.ReflectionOnlyLoad (String) : The reflection-only context is no different from other contexts. Assemblies that are loaded into the context can be unloaded only by unloading the application domain. So, I am afraid the only way to unload an assembly is unloading the application domain. To create a new AppDomain and … Read more

What exactly is an Assembly in C# or .NET?

An assembly is the compiled output of your code, typically a DLL, but your EXE is also an assembly. It’s the smallest unit of deployment for any .NET project. The assembly typically contains .NET code in MSIL (Microsoft Intermediate language) that will be compiled to native code (“JITted” – compiled by the Just-In-Time compiler) the … Read more