Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)

3360
4
08-17-2010 09:57 AM
SamLuo
by
New Contributor
When I try to open a map from either my computer or from a shared folder on a server with IApplication, I got an error showed as "Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)" .
Here is what I did.
       private IApplication pParentApp; (Get this object from class constructor)
       Private String strPath = "C:\\Documents and Settings\My Documents\MyMap.mxd";
       pParentApp.pParentApp.OpenDocument(strPath);
It worked before but not now. 
I can manually open the mxd by click on the file name with no problem.  I think (or guess) when I manually open it, system sees me as my log_in name, but when the above codes running, it may see the user as ArcObject or something as suspicious user.
Our system security might changed recently thats why it worked before but not anymore (again my guess).
Any idea? any thought?
0 Kudos
4 Replies
JanDuske
New Contributor
If you use the code as you have posted it, you might want to escape the folder seperator "\". You did after the drive letter, but not for the subfolders.
0 Kudos
SamLuo
by
New Contributor
If you use the code as you have posted it, you might want to escape the folder seperator "\". You did after the drive letter, but not for the subfolders.


Thanks for your reply.  No, it is not an issue, in my code, i really use double backslash.  I think IApplication acts differently. after I did more test, I found something interesting.

I got IApplication on ICommand Create event as  a hook.  It is ok when use that hook (IApplication) to open a document, but failed if I pass it to a new function (which in in a different project) to open the same document.
0 Kudos
SamLuo
by
New Contributor
When I try to open a map from either my computer or from a shared folder on a server with IApplication, I got an error showed as "Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)" .
Here is what I did.
       private IApplication pParentApp; (Get this object from class constructor)
       Private String strPath = "C:\\Documents and Settings\My Documents\MyMap.mxd";
       pParentApp.pParentApp.OpenDocument(strPath);
It worked before but not now. 
I can manually open the mxd by click on the file name with no problem.  I think (or guess) when I manually open it, system sees me as my log_in name, but when the above codes running, it may see the user as ArcObject or something as suspicious user.
Our system security might changed recently thats why it worked before but not anymore (again my guess).
Any idea? any thought?


Problem solved.  It was because the form that opens map document is modal and IApplication was passed from parent.  Solution: open map document after the form is closed.
0 Kudos
HectorCervantes
New Contributor
Thank you, luosa55!  I had the same issue and your suggestion resolved it.  I changed the from from modal to non-modal and it worked!  Thanks again, your post pointed me to the correct solution.
0 Kudos