Hi Alan.. thanks for ur reply. what i have done so far is,
Registering the DLL by
[DllImport(@"C:\\Program Files\\Cognos\\TM1\\bin32\\tm1api.dll", EntryPoint = "TM1APIInitialize")]
public static extern void TM1APIInitialize();
[DllImport(@"C:\\Program Files\\Cognos\\TM1\\bin32\\tm1api.dll")]
public static extern int TM1SystemOpen();
[DllImport(@"C:\\Program Files\\Cognos\\TM1\\bin32\\tm1api.dll")]
public static extern void TM1SystemAdminHostSet(int hUser, [MarshalAs(UnmanagedType.LPStr)]string sAdminHost);
[DllImport(@"C:\\Program Files\\Cognos\\TM1\\bin32\\tm1api.dll")]
public static extern int TM1ValPoolCreate(int User);
[DllImport(@"C:\\Program Files\\Cognos\\TM1\\bin32\\tm1api.dll")]
public static extern int TM1ValString(int hPool, [MarshalAs(UnmanagedType.LPStr)]string st, int maxSize);
[DllImport(@"C:\\Program Files\\Cognos\\TM1\\bin32\\tm1api.dll")]
public static extern int TM1SystemServerConnect(int hPool, int sServerName, int sClientName, int sPassword);
[DllImport(@"C:\\Program Files\\Cognos\\TM1\\bin32\\tm1api.dll")]
public static extern int TM1ValType(int hUser, int vServerObject);
[DllImport(@"C:\\Program Files\\Cognos\\TM1\\bin32\\tm1api.dll")]
public static extern int TM1ValTypeObject();
[DllImport(@"C:\\Program Files\\Cognos\\TM1\\bin32\\tm1api.dll")]
public static extern int TM1ValTypeError();
[DllImport(@"C:\\Program Files\\Cognos\\TM1\\bin32\\tm1api.dll")]
public static extern int TM1ValErrorCode(int hUser, int vServerObject);
[DllImport(@"C:\\Program Files\\Cognos\\TM1\\bin32\\tm1api.dll")]
public static extern string TM1ValErrorString(int hUser, int vServerObject);
[DllImport(@"C:\\Program Files\\Cognos\\TM1\\bin32\\tm1api.dll")]
public static extern int TM1ProcessExecute(int hPool, int hProcess, int hParametersArray);
[DllImport(@"C:\\Program Files\\Cognos\\TM1\\bin32\\tm1api.dll")]
public static extern int TM1SystemServerConnectIntegratedLogin(int hPool, int vServerName);
[DllImport(@"C:\\Program Files\\Cognos\\TM1\\bin32\\tm1api.dll")]
public static extern void TM1APIFinalize();
[DllImport(@"C:\\Program Files\\Cognos\\TM1\\bin32\\tm1api.dll")]
public static extern int TM1ServerCubes();
[DllImport(@"C:\\Program Files\\Cognos\\TM1\\bin32\\tm1api.dll")]
public static extern int TM1ValIndex(int hPool, int i_CubesIdx);
[DllImport(@"C:\\Program Files\\Cognos\\TM1\\bin32\\tm1api.dll")]
public static extern int TM1ObjectListHandleByIndexGet(int hPool, int vServerObject, int TM1ServerC, int TM1ValI);
In the Button click i want to execute the process
protected void btnUpdate_Click(object sender, EventArgs e)
{
//TM1APIInitialize();
//int hUser = TM1SystemOpen();
//TM1SystemAdminHostSet(hUser, "INFPWH0040");
//int hPool = TM1ValPoolCreate(hUser);
//string strServerName = "INFPWH0040";
//int vServerName = TM1ValString(hPool, strServerName.Trim(), 0);
//int hServer = TM1SystemServerConnectIntegratedLogin(hPool, vServerName);
//if (TM1ValType(hUser, hServer) == TM1ValTypeObject())
//{
// TM1ProcessExecute(hPool, 2, 1);
//}
//if (TM1ValType(hUser, hServer) == TM1ValTypeError())
//{
// int nErrCode = TM1ValErrorCode(hUser, hServer);
// string szErrMsg = TM1ValErrorString(hUser, hServer);
// //Console.WriteLine(nErrCode + ": " + szErrMsg);
//}
//TM1APIFinalize();
//////////////////////////////////////////
TM1APIInitialize();
int hUser = TM1SystemOpen();
//string st = "
http://172.25.34.95/Tm1Web/";
string st = "INFPWH0040";
TM1SystemAdminHostSet(hUser, st);
int hPool1 = TM1ValPoolCreate(hUser);
int hPool2 = TM1ValPoolCreate(hUser);
string sUserName = "admin";
string sServerName = "revapps";
string sPassword = "";
//string sProcess = "fghy";
int vStringLength = 10;
//int vProcess = TM1ValString(hPool1, sProcess, vStringLength);
int vUserName = TM1ValString(hPool1, sUserName, vStringLength);
int vServerName = TM1ValString(hPool1, sServerName, vStringLength);
int vPassword = TM1ValString(hPool1, sPassword, vStringLength);
int vServerObject = TM1SystemServerConnect(hPool1, vServerName, vUserName, vPassword);
int TM1ServerC = TM1ServerCubes();
int TM1ValI = TM1ValIndex(hPool1, 0);
string name = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
if (TM1ValType(hUser, vServerObject) == TM1ValTypeError())
{
int nErrCode = TM1ValErrorCode(hUser, vServerObject);
string szErrMsg = TM1ValErrorString(hUser, vServerObject);
}
else
{
//vhCubes = TM1ObjectListCountGet(hPool, hServer, TM1ServerCubes());
int hCube = TM1ObjectListHandleByIndexGet(hPool1, vServerObject, TM1ServerC, TM1ValI);
int t = TM1ProcessExecute(hPool1, hCube, 5); }
}
Error : like Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Please advice me what is wrong and how to achieve this..
Thanks