Questions tagged [assembly.load]

40 questions
49
votes
5 answers

C# Assembly.Load vs Assembly.ReflectionOnlyLoad

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…
Max Schilling
  • 2,891
  • 4
  • 25
  • 28
20
votes
4 answers

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…
Andrew Russell
  • 26,924
  • 7
  • 58
  • 104
18
votes
2 answers

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…
justin.m.chase
  • 13,061
  • 8
  • 52
  • 100
7
votes
4 answers

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…
Kirill Osenkov
  • 8,786
  • 2
  • 33
  • 37
6
votes
1 answer

Weird Assembly.Load error trying to load assembly compiled with C# code provider

I'm trying to compile an assembly from my code with C# code provider. When I access the compiled assembly with compilerResult.CompiledAssembly, everything works. However, when I instead do Assembly.Load(path), I get the following…
ChaseMedallion
  • 20,860
  • 17
  • 88
  • 152
5
votes
2 answers

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…
Hershi
  • 2,080
  • 2
  • 19
  • 24
4
votes
2 answers

Does Assembly.Load use cache?

I have a resource assembly which stores a lot of reusable scripts, styles and controls. I'm not sure if I should cache this assembly after loading it. Does Assembly.Load use internal cache within the same app-domain? Thank you!
Sergey Akopov
  • 1,130
  • 1
  • 11
  • 25
3
votes
5 answers

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…
Sakin
  • 3,367
  • 3
  • 23
  • 27
3
votes
2 answers

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…
Andy E
  • 338,112
  • 86
  • 474
  • 445
3
votes
2 answers

Testability versus Over-Design?

Here is the situation actually posed by a co-worker that pegged my interest: public DoSomething() { //Do Stuff var assembly = Assembly.LoadFrom("Path"); //Do More Stuff } So, in order to mock this you have two options Create an internal…
Justin Pihony
  • 66,056
  • 18
  • 147
  • 180
2
votes
1 answer

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…
Murtaza Mandvi
  • 10,708
  • 23
  • 74
  • 109
2
votes
1 answer

Load strongly-name assembly from specific path?

I have a strongly-named assembly, installed to a specific folder (and not the GAC). The name as shown in Reflector is: "Foo.Bar.TreeFrog, Version=1.2.1.0, Culture=neutral, PublicKeyToken=ac88c4a8b22089b4" and the path where it's installed…
Eric
  • 11,392
  • 13
  • 57
  • 100
2
votes
1 answer

Strange issue with Assembly.Load*

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…
IvanD
  • 29
  • 3
2
votes
1 answer

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…
Paulo Santos
  • 11,285
  • 4
  • 39
  • 65
2
votes
1 answer

Loading interdependent assemblies from C++/CLI

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…
Guillermo Prandi
  • 1,537
  • 1
  • 16
  • 31
1
2 3