Please help me to fix this error:
Cannot implicitly convert type ‘object’ to ‘System.Reflection.Assembly’. An explicit conversion exists (are you missing a cast?)
Thank you!!!
CODE
var assemblyName = AssemblyName.GetAssemblyName(assemblyPath);
var ads = new AppDomainSetup
{
ApplicationBase = AppDomain.CurrentDomain.SetupInformation.ApplicationBase,
DisallowCodeDownload = true
};
AppDomain newDomainName = AppDomain.CreateDomain("newDomainName", null, ads);
Assembly testLibrary = newDomainName.CreateInstanceAndUnwrap(assemblyName.Name,
typeof(System.Windows.Controls.UserControl).Name); // Here the error occures
CreateInstanceAndUnwrap returns an instance of the created type (
System.Windows.Controls.UserControlin the code above), not anAssembly. The code should be: