dimanche 14 août 2016

dll running as usual only once, after that I have to reopen Visual Studio

I have a outlook contact lookup that I want to run from my web app on a button click. The following code is my dll class and method:

 public class AddressLookup
{
    public Contact getContact()
    {
        RDOSession session = new RDOSession();
        session.Logon(Type.Missing, Type.Missing, Type.Missing, true, Type.Missing, Type.Missing);
        bool loggedOn = session.LoggedOn;

        try
        {
            RDOAddressBook rAddressBook = session.AddressBook;
            RDORecipients rContacts = rAddressBook.ShowAddressBook(Title: "Outlook Lookup", OneAddress: true);

            RDORecipient rContact = rContacts.GetFirst();
            RDOAddressEntry aeContact = rContact.AddressEntry;

            return new Contact(aeContact.Name, aeContact.JobTitle, aeContact.CompanyName, aeContact.StreetAddress);
        }
        catch (Exception)
        {
            return new Contact("", "", "", "");

        }            
    }

The following code is when i ran when the button is clicked on the web app:

protected void btnBillHeaderDetailsOutlook_Click(object sender, EventArgs e)
{
    AddressLookup al = new AddressLookup();      

    var contact = al.getContact();
}

When open VS for the first time, the whole process runs as expected and the contact variable returns the right data. This issue is when I try to click the button again or run the whole web app again the process times out.

Unhandled exception at line 885, column 13 in http://localhost:27855/ScriptResource.axd?d=... 0x800a139e - JavaScript runtime error: Sys.WebForms.PageRequestManagerTimeoutException: The server request timed out.

I feel like I am missing something basic as I have yet to do this before. Many thanks for the help.

When I run it as a windows application is loads as expected (if that helps)

Aucun commentaire:

Enregistrer un commentaire