[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Code to rerun an operation in the event of an error

Posted on 2007-08-10
7
Medium Priority
?
527 Views
Last Modified: 2008-01-09
In my code I have an operation that consistantly faily, but if I go in debug mode and just hit F8 again to rerun it, it works fine.  I am new to programming and am looking for a way that I can have this operation retry (up to 5 times) before it throws an exception.  The error is the last line of the code posted below where I pass the prompt value to the business objects report.

Thanks.




        Dim BusObjApp As New busobj.Application
        BusObjApp.LoginAs("jhaft", "jhaft", False)
        Dim BusObjDoc As New busobj.Document
        Dim promptName As String = ""
        Dim promptValue As String = ""
        Dim promptName2 As String = ""
        Dim promptValue2 As String = ""
        Dim PriorBusinessDayShort As String = ""
        Dim PriorBusinessDayLong As String = ""
        Dim LasyYearBusinessDayLong As String = ""

        PriorBusinessDayShort = "8/9/07"
        PriorBusinessDayLong = "8/9/2007"
        LasyYearBusinessDayLong = "8/10/2006"

        BusObjApp.Interactive = True
        BusObjApp.Visible = True

        BusObjDoc = BusObjApp.Documents.Open("M:\Corporate\Finance\Corporate Finance\Daily Reporting\NIFO\Daily NIFO Reports\Selected Styles Daily Sales Report Final.Rep", NoAutomaticRefresh:=True)

        promptName = "prior business date"
        promptValue = PriorBusinessDayLong
        Threading.Thread.Sleep(2000)
        BusObjApp.Variables.Item(promptName).Value = promptValue.ToString
0
Comment
Question by:collages
  • 4
  • 3
7 Comments
 
LVL 10

Accepted Solution

by:
Dxpert earned 2000 total points
ID: 19672063
before you do that, try adding Application.DoEvents right before that line:

Application.DoEvents()
Threading.Thread.Sleep(2000)
BusObjApp.Variables.Item(promptName).Value = promptValue.ToString

http://msdn2.microsoft.com/en-us/library/system.windows.forms.application.doevents.aspx
0
 
LVL 1

Author Comment

by:collages
ID: 19672132
Tried that, no luck.

When it hits that line where I pass the prompt values I SOMETIMES get this error:

Call was rejected by callee. (Exception from HRESULT: 0x80010001 (RPC_E_CALL_REJECTED))

When that happens it goes into debug mode....heres the strange part....if I wait, say 20 seconds, then resume the code, it works fine.  However, if I increase the sleep to as much as 1 monute it doesnt help....it needs to first get the error, then wait, then when I resume it, the thing works find.

Any ideas what might be going on here?

0
 
LVL 10

Expert Comment

by:Dxpert
ID: 19672346
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 1

Author Comment

by:collages
ID: 19672487
Ok....Im new to this and I read that article.  I dont understand what I need to do.

I added the COM reference and added:

Imports EnvDTE
Imports EnvDTE80

to my application.

Then I did this:

Dim MyTest As EnvDTE80.DTE2

What im stuck on is in the example (which is in C#) they do this:

dte = (EnvDTE80.DTE2)obj;

What is the equivalent in vb.net?
0
 
LVL 10

Expert Comment

by:Dxpert
ID: 19672569
Try:

SET dte = CType(obj, EnvDTE80.DTE2)

OR

SET dte = DirectCast(obj, EnvDTE80.DTE2)


I'm also not very good at C#... adapted from here:
http://www.codeproject.com/dotnet/CheatSheetCastingNET.asp
0
 
LVL 1

Author Comment

by:collages
ID: 19672632
Ok...I think im just in way over my head here...ill revisit this in a few months after ive learned a bit more.

thanks for your help
0
 
LVL 10

Expert Comment

by:Dxpert
ID: 19672684
np.! Thahnks, I'm glad I coud help ;-)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question