c# - is there a better way to handle RPC_E_CALL_REJECTED exceptions when doing visual studio automation? -
This is what I am currently doing:
Protected Zero Setup project () {Bool LbDone = false; Int liCount = 0; While (! LbDone & amp; amp; amp; liCount & lt; pmaxRetries) {try {pproject.ProjectItems.Item ("Class1.cs") Remove (); LbDone = true; } Catch (System. Runtime interrupts services .COMException loE) {liCount ++; If ((uint) loE.ErrorCode == 0x80010001) {// RPC_E_CALL_REJECTED - sleep half-second then try System.Threading.Thread.Sleep (pDelayBetweenRetry); }}}} Now I have to try to hold around the most calls for anvdte stuff, and it works well enough i have a problem when i Looping through the collection and doing something in each item once.
Sometimes I get an exception in the foreach (Project eTem PI.Project.ProjectItems) Line Since I do not want to start an advanced loop on receiving the RPC_E_CALL_REJECTED exception, I'm not sure what I can do. To answer the comment, edit: Yes, I am automating VS with any other program and yes, I usually use VS for something else at the same time. We have an application that reads the XML file, generates about 50 VS solutions based on the XML file. It usually takes a few hours, so I am doing this, while trying to do other things.
First of all, Swan does not want to say so, but the best answer is "how to do" "Do not do this" just use different examples of Visual Studio for your automation and your other work, if all is possible . You should take out the statement of your problem, you can handle the error somewhere, you can use it in the integer index instead of foreach.
// You may also need to try / hold this! Int cProjectItems = pProject.ProjectItems.Length; (IProject ITEM = 0; IProject item cProjectItems; iProject ITEM ++) {Bull BisSwied = False; While (!!) (Try!) {Try {ProjectItem pi = pProject.ProjectItems [iProjectItem]; // something with pi b succeeded = true; } Catch (System. Runtime interrupts services .COMException loE) {liCount ++; If ((uint) loE.ErrorCode == 0x80010001) {// RPC_E_CALL_REJECTED - sleep half-second then try System.Threading.Thread.Sleep (pDelayBetweenRetry); }}}}
Comments
Post a Comment