Hello ,
Im trying to activate a certain method in COM+ application class on a remote server. iv been trying googleing alot about this problem but i found very few relevant information.
i developed this code snippet but it's not completely working.
the dynMethod parameter is staying NULL and i dont understand what am i doing wrong.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Reflection;
namespace DCOM
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void connectToDCOM()
{
try
{
string str = "";
ADODB.Recordset rs = new ADODB.Recordset();
MessageBox.Show("1");
Type srvtype = Type.GetTypeFromProgID("prjBL.clsBLRO", "190.1.0.2", false);
MessageBox.Show("Connected to object");
Object srvobject = Activator.CreateInstance(srvtype);
MessageBox.Show("Instance created");
MethodInfo dynMethod = srvtype.GetType().GetMethod("DB_GetSCEmpAgreements");
MessageBox.Show("Method invoked");
dynMethod.Invoke(srvobject,new object[] {rs,2,2,str});
MessageBox.Show("String: " + str);
}
catch (Exception ex1)
{
MessageBox.Show(ex1.ToString() + "\n" + ex1.Message.ToString());
}
}
private void button1_Click(object sender, EventArgs e)
{
connectToDCOM();
}
}
}
can anyone advise ?