assemblies

Initialize library on Assembly load

﹥>﹥吖頭↗ 提交于 2019-11-27 05:14:27
I have a .net library dll that acts like a functional library. There are a bunch of static types along with static methods. There is some initialization code that I need to run to set up the library ready for use. When the assembly gets loaded is there a way to ensure that a particular method is run? Something like AppDomain.AssemblyLoad but called automatically from the assembly itself. I was thinking that maybe there is something like an AssemblyAttribute that could be used? At the moment I have this initialization code in a static constructor but as this is a library with many entry points

Is there a way to specify assembly references based on build configuration in Visual Studio?

感情迁移 提交于 2019-11-27 05:14:09
问题 I have a project that adds some extensibility to another application through their API. However, I want to be able to use the same project for multiple versions of their application, because most of the code is the same. However, each version of the application requires a reference to the proper assembly for that version of the software. They load their assemblies into the GAC, so even if I could specify the version of the assembly to use based on build configuration I would be fine. Is there

Load WPF styles or other Static Resources from an external file or assembly

大憨熊 提交于 2019-11-27 05:06:57
问题 I have a few WPF applications and I want all my styles to be in a shared assembly instead of declaring them in each application separately. I am looking for a way so I don't have to change all my Style="{StaticResource BlahBlah}" in the existing applications; I just want to add the reference to this style assembly, and delete it from the current application, so it's taken from the assembly. Is there any way? 回答1: Referencing an external ResourceDictionary (XAML File): <Application.Resources>

Finding all Namespaces in an assembly using Reflection (DotNET)

走远了吗. 提交于 2019-11-27 04:48:22
I've got an assembly (loaded as ReflectionOnly) and I want to find all the namespaces in this assembly so I can convert them into "using" ("Imports" in VB) statements for an auto-generated source code file template. Ideally I'd like to restrict myself to top-level namespaces only, so instead of: using System; using System.Collections; using System.Collections.Generic; you'd only get: using System; I noticed there is a Namespace property on the System.Type class, but is there a better way to collect Namespaces inside an assembly that doesn't involve iterating over all types and culling

GetEntryAssembly for web applications

耗尽温柔 提交于 2019-11-27 04:27:59
Assembly.GetEntryAssembly() does not work for web applications. But... I really need something like that. I work with some deeply-nested code that is used in both web and non-web applications. My current solution is to browse the StackTrace to find the first called assembly. /// <summary> /// Version of 'GetEntryAssembly' that works with web applications /// </summary> /// <returns>The entry assembly, or the first called assembly in a web application</returns> public static Assembly GetEntyAssembly() { // get the entry assembly var result = Assembly.GetEntryAssembly(); // if none (ex: web

.NET Assembly Diff / Compare Tool - What's available? [closed]

落花浮王杯 提交于 2019-11-27 04:06:09
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . I'd like to be able to do a code-level diff between two assemblies; the Diff plug-in for Reflector is the closest thing I've found so far, but to compare the entire assembly is a manual process requiring me to drill-down into every namespace/class/method. The other tools I've found so far appear to be limited to

How do I find the fully qualified name of an assembly?

假如想象 提交于 2019-11-27 03:38:00
How do I find out the fully qualified name of my assembly such as: MyNamespace.MyAssembly, version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 I've managed to get my PublicKeyToken using the sn.exe in the SDK, but I'ld like to easily get the full qualified name. If you can load the assembly into a .NET application, you can do: typeof(SomeTypeInTheAssembly).Assembly.FullName If you cannot then you can use ildasm.exe and it will be in there somewhere: ildasm.exe MyAssembly.dll /text This is a shameless copy-paste from I Note It Down and is a simple way to get the FQN for the

Get paths of assemblies used in Type

前提是你 提交于 2019-11-27 03:30:47
问题 I need a method that takes a Type and returns the paths of all assemblies that used in the type. I wrote this: public static IEnumerable<string> GetReferencesAssembliesPaths(this Type type) { yield return type.Assembly.Location; foreach (AssemblyName assemblyName in type.Assembly.GetReferencedAssemblies()) { yield return Assembly.Load(assemblyName).Location; } } Generally this method do the job, but have some disadvantages: I didn't found how to get the referenced assemblies/types from the

Custom Assembly Attributes

你说的曾经没有我的故事 提交于 2019-11-27 03:27:16
I would like to know if I can define custom assembly attributes. Existing attributes are defined in the following way: [assembly: AssemblyTitle("MyApplication")] [assembly: AssemblyDescription("This application is a sample application.")] [assembly: AssemblyCopyright("Copyright © MyCompany 2009")] Is there a way I can do the following: [assembly: MyCustomAssemblyAttribute("Hello World! This is a custom attribute.")] Preet Sangha Yes you can. We do this kind of thing. [AttributeUsage(AttributeTargets.Assembly)] public class MyCustomAttribute : Attribute { string someText; public

Details of Assembly version

对着背影说爱祢 提交于 2019-11-27 03:25:46
问题 we will find Assembly version from Assembly.cs in every library. [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] My question is what is 1.0.0.0 meant by this? Thanks 回答1: As stated in the file itself: // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown