G
Guest
Hi,
I have this constructor:
public CExcelDatabase(string host, string user, string password, string
database,
bool promptCredentials, int
findExcelInstance, bool readOnly)
{
//Some code comes here
}
Then I wrote an override like this:
public CExcelDatabase(string host, string user, string password, string
database,
bool promptCredentials, Excel.Application
excelApp,
bool readOnly)
{
if (excelApp == null)
{
//An error must be raised
}
else
{
this.ExcelApplication = excelApp;
//Note: PROVIDED_EXCEL_INSTANCE is a constant I defined
CExcelDatabase(host,user, password, database, promptCredentials,
PROVIDED_EXCEL_INSTANCE,readOnly);
}
}
I get an error:
....(360): 'EVA.CExcelDatabase' denotes a 'class' which is not valid in the
given context
Which I found is quite normal when doing things like that. I figured out
that you can avoid this error by doing:
public CExcelDatabase(string host, string user, string password,
string database, bool promptCredentials, Excel.Application excelApp,
bool readOnly):
this(host,user, password, database, promptCredentials,
PROVIDED_EXCEL_INSTANCE,readOnly)
{
//Some code comes here
}
But the override will be called before doing some checks I need to excecute:
1) First I need to check that I got an excelApp object (It isn't null),
2) then I need to initialize the private property "ExcelApplication"
3) finally call the override, which uses the value of ExcelApplication.
How can I do this?
Regards,
Josef
I have this constructor:
public CExcelDatabase(string host, string user, string password, string
database,
bool promptCredentials, int
findExcelInstance, bool readOnly)
{
//Some code comes here
}
Then I wrote an override like this:
public CExcelDatabase(string host, string user, string password, string
database,
bool promptCredentials, Excel.Application
excelApp,
bool readOnly)
{
if (excelApp == null)
{
//An error must be raised
}
else
{
this.ExcelApplication = excelApp;
//Note: PROVIDED_EXCEL_INSTANCE is a constant I defined
CExcelDatabase(host,user, password, database, promptCredentials,
PROVIDED_EXCEL_INSTANCE,readOnly);
}
}
I get an error:
....(360): 'EVA.CExcelDatabase' denotes a 'class' which is not valid in the
given context
Which I found is quite normal when doing things like that. I figured out
that you can avoid this error by doing:
public CExcelDatabase(string host, string user, string password,
string database, bool promptCredentials, Excel.Application excelApp,
bool readOnly):
this(host,user, password, database, promptCredentials,
PROVIDED_EXCEL_INSTANCE,readOnly)
{
//Some code comes here
}
But the override will be called before doing some checks I need to excecute:
1) First I need to check that I got an excelApp object (It isn't null),
2) then I need to initialize the private property "ExcelApplication"
3) finally call the override, which uses the value of ExcelApplication.
How can I do this?
Regards,
Josef