I have a problem with using tm1api.dll in C# application: when I check if the connection to the server was successful TM1ValType(hUser, vServerObject) == TM1ValTypeObject() I always get false(TM1ValType returns TM1ValTypeError). It is kinda urgent, so I will be very grateful if someone helps.
Here is the code:
Code: Select all
TM1APIInitialize();
int hUser = TM1SystemOpen();
string st = "COMP"; // the name of the computer
TM1SystemAdminHostSet(hUser, st);
int hPool1 = TM1ValPoolCreate(hUser);
int hPool2 = TM1ValPoolCreate(hUser);
string sUserName = "admin"; //!!!!! I "start local server" via TM1 Architect and use default names and password
string sServerName = "local"; //!!!!! Is it OK?
string sPassword = "";
int vStringLength = 0; //!!!!! in C++ examples it is given as 10 and in VB as 0
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);
if (TM1ValType(hUser, vServerObject) == TM1ValTypeObject()){
Console.WriteLine("Success");
}
if (TM1ValType(hUser, vServerObject) == TM1ValTypeError()){
Console.WriteLine("DAMN!!!"); // !!!!! I get this
}
Code: Select all
[DllImport(@"tm1api.dll")]
public static extern void TM1APIInitialize();
[DllImport(@"tm1api.dll")]
public static extern int TM1SystemOpen();
[DllImport(@"tm1api.dll")]
public static extern void TM1SystemAdminHostSet(int hUser, [MarshalAs(UnmanagedType.LPStr)]string sAdminHost);
[DllImport(@"tm1api.dll")]
public static extern int TM1ValPoolCreate(int User);
[DllImport(@"tm1api.dll")]
public static extern int TM1ValString(int hPool, [MarshalAs(UnmanagedType.LPStr)]string st, int maxSize);
[DllImport(@"tm1api.dll")]
public static extern int TM1SystemServerConnect(int hPool, int sServerName, int sClientName, int sPassword);
[DllImport(@"tm1api.dll")]
public static extern int TM1ValType(int hUser, int vServerObject);
[DllImport(@"tm1api.dll")]
public static extern int TM1ValTypeObject();
[DllImport(@"tm1api.dll")]
public static extern int TM1ValTypeError();
Please reply if you see my mistakes or if you have sample C# code using tm1api.dll
Thanks in advance!