|
Hi to all,
I'm using the dll iTextSharp to fill a PDF file.
My question is how can i select an item in a combobox in the PDF file ?
Best regards and thanks in advance
Fady Sayegh
|
|
|
|
|
Hey!
I got a problem with a class of mine inheriting from xmldocument. When I have an actual xmldocument I can´t cast it to my class, I get System.InvalidCastException. Why is this? I have done the same with for instance another class inheriting from UriBuilder.
|
|
|
|
|
livez wrote: When I have an actual xmldocument I can´t cast it to my class, I get System.InvalidCastException. Why is this?
Because the instance you are trying to cast is obviously not of your inherited type!
|
|
|
|
|
This is what I tried:
class test : XmlDocument
{
public test()
{
}
public void testing ()
{
test t = new test();
XmlDocument doc = new XmlDocument();
t = (test)doc;
}
}
|
|
|
|
|
|
Didnt work
|
|
|
|
|
try leppies solution bellow
|
|
|
|
|
Why was the message deleted? Because the OP said the proposed solution didn't work? That's not a very good reason as now no one else who runs into the same (or similar) problem will know not to try that approach.
Scott.
—In just two days, tomorrow will be yesterday.
—Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai
[ Forum Guidelines] [ Articles] [ Blog]
|
|
|
|
|
livez wrote: XmlDocument doc = new XmlDocument();
t = (test)doc;
XmlDocument doc = new test();
test t = (test) doc;
I am not saying any more.
|
|
|
|
|
So I can´t cast to a more advanced type, but casting to a less advanced is okay.
|
|
|
|
|
I think you need to study inheritance and polymorphism a bit more. It takes a while to get to understand it, but once you do, it all seems natural.
|
|
|
|
|
Thanks for your help, though u could work on your manners a bit.
|
|
|
|
|
My manners are irrelevant. I do not like to spoon-feed people.
|
|
|
|
|
leppie wrote: My manners are irrelevant.
Well said, Seven!
|
|
|
|
|
|
livez wrote: work on your manners a bit
His responses appeared to be quite polite. Curt, for sure, but polite.
|
|
|
|
|
Yes you´re quite right. My apologies Leppie.
|
|
|
|
|
in general these kinds of casts will only work towards the base class. ie a test is an XmlDocument but an XmlDocument is Not necessarily a test.
you could use the "as" operator
t = doc as test;
this will return t == null if doc is not of type test.
If you know how to convert an XmlDocument into a test then you could create a cast for it
public static explicit operator Test(XmlDocument doc)
{
//your conversion algorithm here
}
HTH
Russ
|
|
|
|
|
I have created a windows service to send email on daily basis. It has a timer object that fires an event after 24 hours,
private System.Timers.Timer timer = new System.Timers.Timer (86400000);
In timer event I do my working i.e. I send my emails, something like this:
private void OnTimedEvent(object source, System.Timers.ElapsedEventArgs e)
{
eventLog1.WriteEntry("Calling web service for Sending Reminders on " + DateTime.Now.ToLongDateString());
if (EmailObj.SendReminder())
{
eventLog1.WriteEntry("The operation was successfully completed on " + DateTime.Now.ToLongDateString());;
}
else
{
eventLog1.WriteEntry("There was some error, the operation failed on " + DateTime.Now.ToLongDateString());;
}
if (DateTime.Today.Day == 1)
{
}
}
The problem is, I have installed the service on Windows server 2003, but the service starts and stops immediately with the message
“The MyServiceName service on Local Computer started and then stopped. Some services stop automatically if they have no work to do, for example, the Performance Logs and Alerts service”
I can see the event log entries that I did on OnStart event of the service; also the service is working fine on Windows XP.
Please help me I have to run this service on MS Windows server 2003 forever to send emails on daily basis,
cout << "\0";
// its backSlashZero
|
|
|
|
|
What is there in your OnStart() method ? Is your timer enabled ?
backSlashZero wrote: private System.Timers.Timer timer = new System.Timers.Timer (86400000);
You are keeping the thread sleeping for such a long time. Better method to do this is to write a console application which sends mail and exits automatically. Use windows scheduler to schedule this exe to run at required time. So you are not keeping any threads sleeping for long time. Windows service should be used, if it has to do processing all time when it runs, not for scheduling like this, AFAIK.
|
|
|
|
|
N a v a n e e t h wrote: Better method to do this is to write a console application which sends mail and exits automatically. Use windows scheduler to schedule this exe to run at required time.
Thanks I am going to do this now
cout << "\0";
// its backSlashZero
|
|
|
|
|
Add a keep-alive thread that doesn't do anything but sleeps for 4.5 seconds.
protected void KeepAliveThread()
{
ServiceController controller = new ServiceController(this.ServiceName);
while (true)
{
if (controller.Status == ServiceControllerStatus.Running)
{
Thread.Sleep(4500);
}
}
}
In your OnStart() method, do this:
Thread thread = new Thread(new ThreadStart(KeepAliveThread));
thread.Start();
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Thanks! I tried it out but problem is still there
cout << "\0";
// its backSlashZero
|
|
|
|
|
Are you doing the following in OnStart()?
timer.Enabled = true;
timer.Start();
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Yes i did!
protected override void OnStart(string[] args)
{
eventLog1.WriteEntry("In OnStart: Calling web service for Sending Reminders on "
+ DateTime.Now.ToLongDateString());
EmailObj.SendReminder(); \\send reminders if any!
timer.Enabled = true;
timer.Start();
}
cout << "\0";
// its backSlashZero
|
|
|
|