Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am a beginner here. I am developing a GIS Desktop application using Arc Objects along with Arc Network Analyst extension in vb.net at .NET Framework.

it is such an app that takes data in the form of excel sheet and runs the program to generate output in the form of excel only. The application is running fine as long as I am using small amount of data example, say 100 records. But as soon as I am using larger data say 200 records then it is throwing me this exception:

"System.Runtime.InteropServices.InvalidCOMObjectException:COM object that has been seperated from its underlying RCW cannot be used."
I am getting my error in this line - Solver_Flag = naSolver.Solve(pNAContext, pGPMessagesC, Nothing)

Any form of help will be appreciated. Thank you.
Posted
Comments
Bernhard Hiller 31-Jan-14 3:00am    
Where is the naSolver variable instantiated, and where does it get cleaned up?
Is that variable already the variable for the COM object, or does it contain the COM object?
Is it a multithreading application?
Shdg_2014 31-Jan-14 4:31am    
yes it is a multi-threading app and naSolver is a COM object.
it is declared this way and instantiated
Dim naSolver As INASolver = Nothing
'Solve
naSolver = pNAContext.Solver
naSolver.Solve(pNAContext, pGPMessagesC, Nothing)
If Not naSolver Is Nothing Then Marshal.ReleaseComObject(naSolver)

'Later on again it's being called in a If-else condition

this way
naSolver = pNAContext.Solver
pGPMessagesC = New GPMessagesClass()
Solver_Flag = naSolver.Solve(pNAContext, pGPMessagesC, Nothing)

after the condition ends it(naSolver) is released
Shdg_2014 31-Jan-14 6:10am    
okay I resolved that issue as well. That was happening due the faulty code I had written, this was not an after effect of the RCW error. Now my application is running successfully and providing results for all records.

1 solution

the problem was that this thread being called within a thread multiple times. So each time it executed I had to release the COM objects before it being called again.

Yes the COM objects are initialized and instantiated properly. I am so sorry I couldn't post the entire code as it was too big to do so.

Although the system is running now without a RCW error but now another problem has developed. If I am trying to process 200 records together then it is showing results only for 149 records.

I am stuck with this as of now.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900