sathish kumar

sathish kumar

  • NA
  • 13
  • 9.2k

Add reference to the Dll from Another Dll

Jan 21 2016 1:13 AM
Hi All...
Am developed C# application for creating dll for some functionality,am creating two dll's at a time,for example Dll A and Dll B.
This Dll A is reference of Dll B.
So how to call Dll A from Dll B.
Am using following code for this, but i got error message.

the Code is
 
public class Proxy : MarshalByRefObject
{
public Assembly GetAssembly(string assemblyPath)
{
try
{
return Assembly.LoadFile(assemblyPath);
}
catch (Exception)
{
return null;
// throw new InvalidOperationException(ex);
}
}
}
 
 
string dynamicClassPath = File Path;
AppDomain domains = AppDomain.CreateDomain("New domain name");
Type type = typeof(Proxy);
Proxy myObject = (Proxy)domains.CreateInstanceFromAndUnwrap(dynamicClassPath, type .FullName);
 
and the error is

Quote:
Could not load type 'FolderName.FileName+Proxy' from assembly 'Dynamic_id, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.

here
Dynamic_id
is a dll.
 
for deep explanation
 
Dll A and B both are created dynamically.
The Following code in Dll A
 
using System;
namespace ForTest
{
public class Dynamic_Val_001
{
private string _Prop_Name;
private string _Prop_Address;
public virtual string Prop_Name
{
get
{
return this._Prop_Name;
}
set
{
this._Prop_Name = value;
}
}
public virtual string Prop_Address
{
get
{
return this._Prop_Address;
}
set
{
this._Prop_Address = value;
}
}
}
}
the Dll B code is
using System;
namespace ForTest
{
public class Val_001
{
public virtual Tuple<bool, string> isValid(Dynamic_Val_001)
{
return new Tuple<bool, string>(false, "Success");
}
}
}
Now the Dll B have a one tuple bool function with one parameter, In that parameter is Dll A class name,so Dll B is depends on dll A.
So how to Call that Dll A class from Dll B.
so pls help me how to do this??
sorry my poor English. 

Answers (2)