assembly.load

How to run NUnit programmatically

I have some assembly that references NUnit and creates a single test class with a single test method. I am able to get the file system path to this assembly (e.g. "C:...\test.dll"). I would like to programmatically use NUnit to run against this assembly. So far I have: var runner = new SimpleTestRunner(); runner.Load(path); var result ...

C# Assembly.Load vs Assembly.ReflectionOnlyLoad

Hi all, I'm trying to understand the differences between Assembly.Load and Assembly.ReflectionOnlyLoad. In the code below I am attempting to find all of the objects in a given assembly that inherit from a given interface: var myTypes = new List<Type>(); var assembly = Assembly.Load("MyProject.Components"); foreach (var type in asse...

C# assembly.load from a byte[] issues

I have an EXE loaded into a byte array, and I am trying to load it into an assembly object using Assembly.Load. I am getting errors trying to load. Here is the code that is causing the exception: Assembly a = Assembly.Load(bin); bin is my byte array, loaded from the EXE. Here is the exception I am getting: Could not load file o...

Assembly binding problems in .NET

I am writing a .NET library that for various reasons cannot be registered in the GAC. This dll (let's call it SDK.dll) depends on other DLLs in order to be loaded. When writing a program that uses this SDK.dll, I noticed that my program failed loading the dll with a FileNotFoundException thrown. This happens because although I was able ...

How can I prevent loading a native dll from a .NET app?

Background: My C# application includes a plugin framework and generic plugin loader. The plugin loader enumerates the application directory in order to identify plugin dlls (essentially it searches for *.dll at this time). Within the same application directory is a native (Windows, non-.net) dll, which, indirectly, one of the plugin ...

Loading Assembly only once

I'm loading an assembly at runtime and the question that arises everytime I call the code is that should I be checking if that particular assembly has loaded already? or does .Net take care of this and one assembly (same version) can only be loaded once? The basic question here is do i have to iterate through a list of loaded assemblies ...

Weird behaviour when mixing loading of assemblies using Assembly.LoadFrom and Assembly.Load

Weird behavior when mixing loading of assemblies using Assembly.LoadFrom and Assembly.Load I have encountered a weird behavior when loading assemblies with Assembly.LoadFrom and later on with Assembly.Load. I am loading an assembly using Assembly.LoadFrom, where the assembly is located in a folder which is not the execution folder. La...

How do I load an assembly that references a Win32 DLL?

I am developing a .NET application that uses reflection to load plugins. My plugins are C# class libraries. The trouble is that some of my plugins reference conventional Win32 DLLs, and C# is blindly attempting to load the dependencies as if they were .NET DLLs. Here is how I load a plugin: string fileName = "plugin.dll"; Assembly.Lo...

Recompile C# while running, without AppDomains

Let’s say that I have two C# applications - game.exe (XNA, needs to support Xbox 360) and editor.exe (XNA hosted in WinForms) - they both share an engine.dll assembly that does the vast majority of the work. Now let’s say that I want to add some kind of C#-based scripting (it’s not quite "scripting" but I’ll call it that). Each level ge...

How to provide a fallback assembly instead of the one that can't be loaded?

At runtime, if a referenced assembly fails to load with e.g. "Strong name validation failed" (because it's test-signed), is there a way to provide a substitution assembly from another path that is real-signed? I tried subscribing to AppDomain.CurrentDomain.AssemblyResolve, but it doesn't get fired, because the "bad" assembly technically...

Dynamically loading assemblies and their dependents using XCOPY deployment

Hi, I have an application loader that dynamically loads applications. An application is an assembly with all of its dependents in a single folder. Using XCOPY deployment I can add/remove applications by copying/deleting a folder. To facilitate standard .NET assembly binding I copy the application folders under the bin of the loader. I s...

Assembly.Load(Byte[]) and Assembly.Location/Assembly.Codebase

I'm trying to load an assembly without locking the file. These assemblies could be third party assemblies so we don't necessarily have access to the code and one or two of them make use of Assembly.Location to read files from their directory, files they might depend on. I'm aware you can do this via Shadow Copying but it's a real pain ...

Tests under TestDriven.NET not picking up updated fuslogvw settings

If there's a dup of this, I'll be upvoting it but until someone finds it for me.... This is a Things I've Learned Today [that nobody seems to have blogged about] entry... With TestDriven.NET, I was continually getting the following output from an Assembly.Load : WRN: Assembly binding logging is turned OFF. To enable assembly b...

Loading interdependent assemblies from C++/CLI

Hi. I want to load two assemblies from C++/CLI; assembly A depends on assembly B, and both are VB.Net projects (3.5). I want them to load from a byte array, so I use Assembly::Load(), but when I try to instantiate a class from assembly A, the framework ignores the previously loaded assembly B and attempts to load it again, which fails be...

How to solve Assembly.Load performance hit?

I'm refactoring some code and I've been hit with a dilemma. Let's say we have the following scenario: A Core Assembly that contains many common interfaces and classes A Library Assembly that contains more specialized classes. The Library Assembly references the Core Assembly. So far so good. Due the fact that I'm refactoring this, ...

Strange problem with Assembly.Load*

Hi, dear community! I have strange problem with loading assembly from file and unfortunately I can't reproduce it with simple easy-to-share code. I describe what I'm doing right below. I have 4 applications: "Complex Invoker" - the foreign(not mine) open source application, which is the computer game actually, for which I'm writing a...

Evaluating static methods (with parameters) using MDbg

How do you evaluate a static method that takes parameters using MDbg on the command-line? To call Assembly.GetCallingAssembly(), this works: mdbg> funceval System.Reflection.Assembly.GetCallingAssembly How would you call the Assembly.Load method? eg. Assembly.Load("Foo.Bar") ...

ASP.NET load assembly from parent application

Hi, i have a website and in it is an application with website administration. It is possible to load an assembly from website in administration application? E.G: WebAdmin project (web application) : in default.aspx i want to load assembly ClassLibrary1.dll and create instance of type ImportProvider. WebAdmin doesn't have reference t...

How can I load assembly dynamically thru internet?

Is there a way or a library that can help me load assembly in memory (dll for example) located on my webpage. I'm trying to figure out a nice crack protection ...

SecurityException from Activator.CreateInstance(), How to grant permissons to Assembly?

I have been loading an assembly via Assembly.LoadFrom(@"path"); and then doing Type t = asm.GetType("Test.Test"); test = Activator.CreateInstance(t, new Object[] { ... }); and it was working fine, but now I moved the dll I am getting the following System.Reflection.TargetInvocationException: Exception has been thrown by the target o...