Search The ForumSearch   RegisterRegister  LoginLogin

MailBee.NET Objects

 AfterLogic Forum : MailBee.NET Objects
Subject Topic: forms authentication problem Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
crg1970
Newbie
Newbie


Joined: 27 August 2008
Location: Panama
Online Status: Offline
Posts: 4
Posted: 27 August 2008 at 12:30pm | IP Logged Quote crg1970

I have a Windows Service that reads EML files using the MIME classes. It reads the file no problem, but when it tries to write the file (it needs to output it to another folder) I get an exception.

The problem is that the destination folder is inside an IIS application that has FORMS AUTHENTICATION configured. The error I get is thrown by ASP.NET "Forms authentication failed for the request. Reason: The ticket supplied is Invalid. ". I don't have an authenticaton ticket, because the service should be running outside IIS and it is accessing the folder using a full path rather than a URL.

Has anyone ever seen a problem like this? The actual Mailbee exception is a mailbeeioexcption.
Back to Top View crg1970's Profile Search for other posts by crg1970
 
Andrew
AfterLogic Support
AfterLogic Support


Joined: 28 April 2006
Location: United States
Online Status: Offline
Posts: 1189
Posted: 28 August 2008 at 1:34am | IP Logged Quote Andrew

We're not sure that clearly understood you. You said a Windows Service writes the file, but the exception is thrown in an ASP.NET application. Are you sure the issue happens because the file is written by the Windows Service?

Best regards,
Andrew
Back to Top View Andrew's Profile Search for other posts by Andrew
 
crg1970
Newbie
Newbie


Joined: 27 August 2008
Location: Panama
Online Status: Offline
Posts: 4
Posted: 29 August 2008 at 2:05pm | IP Logged Quote crg1970

Quite sure. The error has gone away since I removed the Forms authentication from that FOLDER. However, now I have the following error (again, running a Windows Service that uses the Mailbee.MIME.mailmessage object to read an .EML file from the c:\inetpub\mailroot\drop folder):

1.0.0.0
48b85a36
mailbee.net
4.0.2.105
48a1794e
f78
6b
mailbee.mailbeeioexception
NIL

Element not found

The thing is that as far as I can tell the Mailbee object is not supposed to be doing anything at that moment. Can you tell me more about what this error could mean?
Back to Top View crg1970's Profile Search for other posts by crg1970
 
Igor
AfterLogic Support
AfterLogic Support


Joined: 24 June 2008
Location: United States
Online Status: Offline
Posts: 6092
Posted: 01 September 2008 at 1:33am | IP Logged Quote Igor

MailBee I/O Exception message usually means some access related issue, for example the application was unable to read from or write into a file.

Could you please provide us with detailed exception information including stack trace?

Please also try to debug your application to find out what exactly your application tries to do when the exception is thrown.

Regards,
Igor
Back to Top View Igor's Profile Search for other posts by Igor
 
crg1970
Newbie
Newbie


Joined: 27 August 2008
Location: Panama
Online Status: Offline
Posts: 4
Posted: 01 September 2008 at 11:04am | IP Logged Quote crg1970

Thanks for all your help, but I continue to have problems. How can I provide you with a full stack trace???

I have been debugging as much as I can with the service. I use the fileSystemWatcher class to monitor when a file is put in the MAILROOT\drop folder. When I try to read the file after the event is raised, SOMETIMES I get this error. I don't understand why sometimes it can read the file fine, others it can't.

THERE is nothing else trying to read the file, and supposedly when the CREATED event is fired for the FSW, the IIS process should be done with it right? Anyone have any experience with anything similar?
Back to Top View crg1970's Profile Search for other posts by crg1970
 
Andrew
AfterLogic Support
AfterLogic Support


Joined: 28 April 2006
Location: United States
Online Status: Offline
Posts: 1189
Posted: 02 September 2008 at 2:09am | IP Logged Quote Andrew

Quote:
How can I provide you with a full stack trace???


Just add try/catch block and implement writing exception.ToString() to a file in the catch block.

Are you sure the FSW event means "file has been created, written and closed"? Perhaps, it just means "file has been created and is being written, but not closed yet". So, if your application tries to access that file while it's locked, the exception may be thrown. Try to add a delay (second or two) into your FSW event handler, so the file wouldn't be accessed immediately and the writing process would have time to complete writing. Does it help?

The "SOMETIMES" may depend on file size (i.e. time required to write the file) and filesytem load (additional lags).

Best regards,
Andrew
Back to Top View Andrew's Profile Search for other posts by Andrew
 
crg1970
Newbie
Newbie


Joined: 27 August 2008
Location: Panama
Online Status: Offline
Posts: 4
Posted: 02 September 2008 at 2:45pm | IP Logged Quote crg1970

Sure enough, it is a problem with the fact that the FSW triggers the CREATED event, before IIS has finished writing the file.

I had to use a loop with a try/catch inside to get this to work. Anyone else ever written a Mail Reader program to read from the IIS MailRoot\drop folder??? Was this the RIGHT or only solution???
Back to Top View crg1970's Profile Search for other posts by crg1970
 
Andrew
AfterLogic Support
AfterLogic Support


Joined: 28 April 2006
Location: United States
Online Status: Offline
Posts: 1189
Posted: 03 September 2008 at 1:25am | IP Logged Quote Andrew

What if to start waiting for "Changed" event right after "Created" event? Try to add "Changed" event handler where your application should check if the file is still locked, once it gets unlocked, you should process it.

This solution is similar to the loop with a try/catch inside you implemented, but looping without a delay consumes more CPU time than waiting for event.

Best regards,
Andrew
Back to Top View Andrew's Profile Search for other posts by Andrew
 
Andrew
AfterLogic Support
AfterLogic Support


Joined: 28 April 2006
Location: United States
Online Status: Offline
Posts: 1189
Posted: 03 September 2008 at 4:19am | IP Logged Quote Andrew

We found additional info which should be useful for you.

Also, pay your attention to the comments, especially to:

Quote:
I have seem similar situations being handled in a different manner.

Lets say you have a folder where files are being dropped from a remote location at regular intervals. You would like to be notified of new files being available, to do further processing on them.

In this scenario, instead of using the NotifyFilters.FileName property, use the NotifyFilters.LastWrite Property to trigger the event handler. This will prevent a double callback and make sure that the file is completely transfered before triggering the change event.


Best regards,
Andrew
Back to Top View Andrew's Profile Search for other posts by Andrew
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump

Powered by Web Wiz Forums version 7.9
Copyright ©2001-2004 Web Wiz Guide