assemblies

Referencing different versions of the same assembly

只谈情不闲聊 提交于 2019-11-27 01:28:39
问题 If A references assembly B 1.1 and C, and C references B 1.2, how do you avoid assembly conflicts? I nievely assumed C's references would be encapsulated away and would not cause any problems, but it appears all the dll's are copied to the bin, which is where the problem occurs. I understand the two ways around this are to use the GAC or assembly bindings? The GAC doesn't seem like the best approach to me, as I don't like assuming dlls will be there, I prefer to reference dlls from a lib

How to prevent others from using my .Net assembly?

巧了我就是萌 提交于 2019-11-27 01:11:17
问题 I have an assembly which should not be used by any application other than the designated executable. Please give me some instructions to do so. 回答1: You can sign the assembly and the executable with the same key and then put a check in the constructor of the classes you want to protect: public class NotForAnyoneElse { public NotForAnyoneElse() { if (typeof(NotForAnyoneElse).Assembly.GetName().GetPublicKeyToken() != Assembly.GetEntryAssembly().GetName().GetPublicKeyToken()) { throw new

Modifying Existing .NET Assemblies

无人久伴 提交于 2019-11-27 01:02:35
问题 Is there a way to modify existing .NET assemblies without resorting to 3rd party tools? I know that PostSharp makes this possible but I find it incredibly wasteful that the developler of PostSharp basically had to rewrite the functionality of the whole System.Reflection namespace in order to make existing assemblies modifiable. System.Reflection.Emit only allows the creation of new, dynamic assemblies. However, all the builder classes used here inherit from the basic reflection classes (e.g.

How to reference .NET assemblies using PowerShell

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-27 00:54:15
I am a C# .NET developer/architect and understand that it uses objects (.NET objects) and not just streams/text. I would like to be able to use PowerShell to call methods on my .NET (C# library) assembies. How do I reference an assembly in PowerShell and use the assembly? Darin Dimitrov Take a look at the blog post Load a Custom DLL from PowerShell : Take, for example, a simple math library. It has a static Sum method, and an instance Product method: namespace MyMathLib { public class Methods { public Methods() { } public static int Sum(int a, int b) { return a + b; } public int Product(int a,

How do I list all loaded assemblies?

限于喜欢 提交于 2019-11-27 00:43:16
In .Net, I would like to enumerate all loaded assemblies over all AppDomains. Doing it for my program's AppDomain is easy enough AppDomain.CurrentDomain.GetAssemblies() . Do I need to somehow access every AppDomain? Or is there already a tool that does this? Bogdan Gavril MSFT Using Visual Studio Attach a debugger to the process (e.g. start with debugging or Debug > Attach to process) While debugging, show the Modules window (Debug > Windows > Modules) This gives details about each assembly, app domain and has a few options to load symbols (i.e. pdb files that contain debug information). Using

how to load all assemblies from within your /bin directory

半世苍凉 提交于 2019-11-27 00:19:58
In a web application, I want to load all assemblies in the /bin directory. Since this can be installed anywhere in the file system, I can't gaurantee a specific path where it is stored. I want a List<> of Assembly assembly objects. Wolfwyrd 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:

How to pre-load all deployed assemblies for an AppDomain

好久不见. 提交于 2019-11-26 23:59:31
问题 UPDATE: I now have a solution I'm much happier with that, whilst not solving all the problems I ask about, it does leave the way clear to do so. I've updated my own answer to reflect this. Original Question Given an App Domain, there are many different locations that Fusion (the .Net assembly loader) will probe for a given assembly. Obviously, we take this functionality for granted and, since the probing appears to be embedded within the .Net runtime ( Assembly._nLoad internal method seems to

Visual Studio 2008: Creating Single DLL from Solution with Many Projects

我与影子孤独终老i 提交于 2019-11-26 23:21:45
问题 I have an ASP.NET web application developed in Visual Studio 2008, composed of 3 different projects (one for UI, one of BO and the third for DAL). How can I generate a single assembly file which holds all 3? Now it's generating 3 DLLS each for each project in the solution. 回答1: I do not know if there's indeed this feature in VS2008. But you certainly can do it outside VS. E.g.: Merging .NET assemblies using ILMerge 回答2: For each of your projects create a netmodule or an assembly and compile

.NET Reference “Copy Local” True / False Being Set Based on Contents of GAC

只谈情不闲聊 提交于 2019-11-26 23:13:36
问题 We had a very interesting problem with a Win Forms project. It's been resolved. We know what happened, but we want to understand why it happened. This may help other people out in the future who have a similar problem. The WinForms project failed on 2 of our client's PCs. The error was an obscure kernel.dll error. The project ran fine on 3 other PCs. We found that a .DLL (log4net.dll - a very popular open-source logging library) was missing from our release folder. It was previously in our

Could not load file or assembly 'someProject' or one of its dependencies. Access is denied

南楼画角 提交于 2019-11-26 23:13:26
问题 I am stuck with one asp.net error. My application work fine on development and test environemnt. But on production it give me following error: Could not load file or assembly 'someProject' or one of its dependencies. Access is denied. 回答1: Go to Sysinternals and download Process Monitor: http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx Then start it up, filter thread and registry actions away. Clear contents. Run your app and get the error, and then stop the collection in process