How do I list all loaded assemblies?

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 Process … Read more

How to Load an Assembly to AppDomain with all references recursively?

You need to invoke CreateInstanceAndUnwrap before your proxy object will execute in the foreign application domain. class Program { static void Main(string[] args) { AppDomainSetup domaininfo = new AppDomainSetup(); domaininfo.ApplicationBase = System.Environment.CurrentDirectory; Evidence adevidence = AppDomain.CurrentDomain.Evidence; AppDomain domain = AppDomain.CreateDomain(“MyDomain”, adevidence, domaininfo); Type type = typeof(Proxy); var value = (Proxy)domain.CreateInstanceAndUnwrap( type.Assembly.FullName, type.FullName); var assembly = … Read more

How do you loop through currently loaded assemblies?

Getting loaded assemblies for the current AppDomain: var loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies(); Getting the assemblies referenced by another assembly: var referencedAssemblies = someAssembly.GetReferencedAssemblies(); Note that if assembly A references assembly B and assembly A is loaded, that does not imply that assembly B is also loaded. Assembly B will only be loaded if and when it … Read more

How to extract an assembly from the GAC?

I used the advice from this article to get an assembly from the GAC. Get DLL Out of The GAC DLLs once deployed in GAC (normally located at c:\windows\assembly) can’t be viewed or used as a normal DLL file. They can’t be directly referenced from VS project. Developers usually keep a copy of the original … Read more

Difference between LoadFile and LoadFrom with .NET Assemblies?

Does this clear it up? // path1 and path2 point to different copies of the same assembly on disk: Assembly assembly1 = Assembly.LoadFrom(path1); Assembly assembly2 = Assembly.LoadFrom(path2); // These both point to the assembly from path1, so this is true Console.WriteLine(assembly1.CodeBase == assembly2.CodeBase); assembly1 = Assembly.LoadFile(path1); assembly2 = Assembly.LoadFile(path2); // These point to different assemblies … Read more

How to add folder to assembly search path at runtime in .NET?

Sounds like you could use the AppDomain.AssemblyResolve event and manually load the dependencies from your DLL directory. Edit (from the comment): AppDomain currentDomain = AppDomain.CurrentDomain; currentDomain.AssemblyResolve += new ResolveEventHandler(LoadFromSameFolder); static Assembly LoadFromSameFolder(object sender, ResolveEventArgs args) { string folderPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string assemblyPath = Path.Combine(folderPath, new AssemblyName(args.Name).Name + “.dll”); if (!File.Exists(assemblyPath)) return null; Assembly assembly = … 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

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