Wednesday, August 22, 2012

Reading dll from database


Private void Button2_click(object sender,EventArgs e)
{
   Byte[] result = null;
String dsn = “”;
SqlConnection con = new SqlConnection(dsn);
Con.open();
Sqlcommand cmd= new SqlCommand(“select * from StoredDLL”,con);
cmd.CommandType = CommandType.Text;
SqlDataReader reader = cmd.ExecuteReader();
If(reader.HasRows)
{
  While(reader.Read())
{
    resullt = (Byte[])reader[0];
}
File.WriteAllBytes(@”D:\som\Test1.dll”,result);
Object results = ReadandAccessDLL();
Messagebox.show(result.tostring());
}
Else
{
Messagebox.show(“No Rows found”);
}
Reader.close();
Con.close();
}
Private object ReadandAccessDLL()
{
Assembly a=Assembly.LoadFile(@”D:\som\Test1.dll”);
Object result = null;
For each (Type type in a.GetTypes())
{
  If(type.IsClass== true)
{
   If( type.FullName.EndsWith(“.” + “class1”))
{
   Object obj = Activator.CreateInstance(type);
  Object[] args =  {56,86};
Result = type.InvokeMember(“sum”,
BindingFlags.Default|BindingFlags.InvokeMethod,null,obj,agrs);
}
}
}
Return result;
}

No comments:

How to identify the user that was used to change an object from AOT in AX2012

Get the object name for which we need to track these (user and date&time) information's. Login to SQL Server Management Studio an...