Can I load an Assembly without knowing the dll filename, where I only know the namespace name
In general this is not possible to do. There is no inherent relationship between a DLL and a namespace. It's possible for multiple DLL's to contain the same namespace and a single DLL to contain multiple different root namespaces. So there is not guaranteed to be a 1-1 mapping here.
However you could create a table in your application between a given namespace and the set of DLLs which do contain it. Then for a namespace try and load all of those DLL's in sequence. That will get you close to the effect you are looking for (but only for a limited set of available DLLs)
How to load Assembly at runtime and create class instance?
If your assembly is in GAC or bin use the assembly name at the end of type name instead of Assembly.Load()
.
object obj = Activator.CreateInstance(Type.GetType("DALL.LoadClass, DALL", true));
AssemblyLoadContext, dynamically load an assembly, instantiate an object and cast to a shared interface
AssemblyLoadContext to support dynamic code loading and unloading, it creates an isolated context for loading code and its dependencies in their own AssemblyLoadContext instance.
The problem was that in the ExecutionAssemblyLoadContext implementation, the dependencies was resolved and isolated. Using the default implementation, siggested by the documentation of AssemblyLoadContext the shared types will not be isolated. Following the correct implementation to use to share the interface.
public class ExecutionAssemblyLoadContext : AssemblyLoadContext
{
public ExecutionAssemblyLoadContext() : base(isCollectible: true)
{
}
protected override Assembly Load(AssemblyName name)
{
return null;
}
}
How to load a type from the type's name and the assembly's name
Type.GetType(string.Concat(typeName, ", ", assemblyName))
http://msdn.microsoft.com/en-us/library/w3f99sx1.aspx
http://msdn.microsoft.com/en-us/library/system.type.assemblyqualifiedname.aspx
Related Topics
Deserializing Json Data to C# Using Json.Net
If Async-Await Doesn't Create Any Additional Threads, Then How Does It Make Applications Responsive
How to Increase the Max Upload File Size in Asp.Net
Difference Between Shadowing and Overriding in C#
Find Control by Name from Windows Forms Controls
.Net Global Exception Handler in Console Application
How to Update an Observablecollection Via a Worker Thread
How to Load Image to Wpf in Runtime
Why Is Dictionary Preferred Over Hashtable in C#
How to Split CSV Whose Columns May Contain ,
C# Data Connections Best Practice
How to Check For Internet Connectivity Using .Net
Why Use the 'Ref' Keyword When Passing an Object