assemblies

Create custom AppDomain and add assemblies to it

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-27 14:48:24
How can I create an appdomain, add assemblies to it, then destroy that app domain? This is what I have tried: static void Main(string[] args) { string pathToExe = @"A:\Users\Tono\Desktop\ConsoleApplication1.exe"; AppDomain myDomain = AppDomain.CreateDomain("MyDomain"); Assembly a = Assembly.Load(System.IO.File.ReadAllBytes(pathToExe)); myDomain.Load(a.FullName); // Crashes here! } I have also tried: myDomain.Load(File.ReadAllBytes(pathToExe)); how can I add an assembly to the appdomain. Once I do that I can find the method via reflection execute it and then destroy the appdomain The exception

How do I get the version of an assembly without loading it?

限于喜欢 提交于 2019-11-27 14:37:14
One small function of a large program examines assemblies in a folder and replaces out-of-date assemblies with the latest versions. To accomplish this, it needs to read the version numbers of the existing assembly files without actually loading those assemblies into the executing process. I found the following in this article . using System.Reflection; using System.IO; ... // Get current and updated assemblies AssemblyName currentAssemblyName = AssemblyName.GetAssemblyName(currentAssemblyPath); AssemblyName updatedAssemblyName = AssemblyName.GetAssemblyName(updatedAssemblyPath); // Compare

Is it possible to replace a reference to a strongly-named assembly with a “weak” reference?

▼魔方 西西 提交于 2019-11-27 14:21:45
I'm writing a .NET tool that requires the SQL Server SMO library. I don't care if it's the version from Server 2005 (9.0), 2008 (10.0) or 2008 R2 (probably 10.5, didn't check). The SMO library is installed together SQL Server, so I can safely assume that on any system with SQL Server installed, some version of the SMO library is available as well. Unfortunately, the SMO libraries are strongly-named: If I add a reference to SMO 9.0 in my project, it will fail ( FileNotFoundException ) if only SMO 10.0 is present on the customer's system, and vice versa. Is there some way to tell the compiler

C# - Referencing a type in a dynamically generated assembly

最后都变了- 提交于 2019-11-27 14:02:20
I'm trying to figure out if it's possible when you are dynamically generating assemblies, to reference a type in a previously dynamically generated assembly. For example: using System; using System.CodeDom.Compiler; using System.Reflection; using Microsoft.CSharp; CodeDomProvider provider = new CSharpCodeProvider(); CompilerParameters parameters = new CompilerParameters(); parameters.GenerateInMemory = true; CompilerResults results = provider.CompileAssemblyFromSource(parameters, @" namespace Dynamic { public class A { } } "); Assembly assem = results.CompiledAssembly; CodeDomProvider

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

早过忘川 提交于 2019-11-27 13:10:05
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 API-level (namespaces, classes, methods) differences--which won't cut it for what I'm looking for. Does anyone know of such a tool? My requirements (from highest to lowest) are: Be able to analyze / reflect the code content of two versions of the same assembly and report the

What is a partially trusted assembly/application/code/etc in .NET?

橙三吉。 提交于 2019-11-27 13:08:52
问题 Could someone please explain? I couldn't find anything on the internet, everything talks about how to go about it in some way, but nothing says exactly what it is. Also, what is a fully trusted assembly and how do they differ from one another? I have a MS certification exam and this is the only topic that I just don't understand. EDIT: Thanks guys. Now I have a better understanding of security in .NET. I was able to pass my certification exam. 回答1: A full-trust assembly has an unrestricted

C# Namespaces and Assemblies Best Practice

陌路散爱 提交于 2019-11-27 12:52:23
问题 C#: are there any guidelines, best practices when it comes to dividing a solution up into name-spaces and assemblies? Should name spaces normally be nested, with the most low level and fundamental classes in the top level name space? Should there generally be one name-space to one assembly? Are their any pitfalls to having multiple assemblies in one name-space or multiple name-spaces in one assembly. Are there any compile time/ run time penalties for multiple assemblies or very large

ILMerge DLL: Assembly not merged in correctly, still listed as an external reference

牧云@^-^@ 提交于 2019-11-27 12:45:21
问题 In the build process for a .NET C# tool, I have been using ILMerge to merge the assemblies into a single exe. I added a new class library recently, and now the ILMerge is failing. I have remembered to tell it to merge in the new DLL! It is now giving me this error, which I don't really understand: ILMerge.Merge: The assembly 'DataObjects' was not merged in correctly. It is still listed as an external reference in the target assembly. All of the assembly references I have done using 'project'

How to read assembly attributes

久未见 提交于 2019-11-27 12:16:45
In my program, how can I read the properties set in AssemblyInfo.cs: [assembly: AssemblyTitle("My Product")] [assembly: AssemblyDescription("...")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Radeldudel inc.")] [assembly: AssemblyProduct("My Product")] [assembly: AssemblyCopyright("Copyright @ me 2008")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] I'd like to display some of these values to the user of my program, so I'd like to know how to load them from the main program and from komponent assemblies I'm using. This is reasonably easy. You have to

ASP.NET - AppDomain.CurrentDomain.GetAssemblies() - Assemblies missing after AppDomain restart

寵の児 提交于 2019-11-27 12:04:17
I have a Bootstrapper that looks through all Assemblies in an ASP.NET MVC application to find types that implement an IBootstrapperTask interface, and then registers them with an IOC Contrainer. The idea is that you can literaly place your IBootstrapperTasks anywhere, and organise your Projects how you please. Code for Bootstrapper: public class Bootstrapper { static Bootstrapper() { Type bootStrapperType = typeof(IBootstrapperTask); IList<Assembly> assemblies = AppDomain.CurrentDomain.GetAssemblies(); List<Type> tasks = new List<Type>(); foreach (Assembly assembly in assemblies) { var types =