Close + NewFromSolution = Permission Denied - InfoPath Dev
in

InfoPath Dev

Close + NewFromSolution = Permission Denied

Last post 05-03-2006 07:59 AM by klrosenberg. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 05-02-2006 07:26 PM

    Close + NewFromSolution = Permission Denied

    Via script, I'm trying to close the current form and reopen it, so I can quickly clear all data values (this is a multi-view form). Also, this is a fully-trusted form.

    On my development laptop the script works like a champ - on all other machines it fails on the NewFromSolution line with a "permission denied" script error.

    (I've isolated this problem down to some simple code). Here it is:

    1. Create a TestForm.xsn with one Button - btnCloseAndReopen. Add the script below on the button's OnClick event.

    function btnCloseAndReopen::OnClick(eventObj)
    {
    var oActiveDoc = Application.ActiveWindow.XDocument;
    var ActiveURI = oActiveDoc.URI;
    var sURI = XDocument.Solution.URI;
    XDocument.UI.Alert("About to close Active Document...");
    Application.XDocuments.Close(oActiveDoc);
    // or XDocument.View.Window.Close(true);
    // or Application.XDocuments.Close(0);
    Application.XDocuments.NewFromSolution(sURI);
    }

    2. Use regform to fully trust the form (/T Yes).

    3. Run it by double-clicking TestForm.xsn

    ---

    On my Development machine, it works like a champ. On everyone else's machine in the world, it fails on the NewFromSolution line, producing the message box: "A runtime error has occurred. Do you wish to debug? The following error occurred: permission denied ...

    I can understand why it may not work (perhaps it's lost context, but why does it work on my machine). By the way, for each test, I recreated the .XSN from scratch on each individual machine.

    If I remove the "Application Close" line, the form works on all machines, but obviously keeps creating more and more XDocuments. I don't want this.

    What am I doing right (on my machine), and wrong (on others). Is this a timing problem? MDI. Or Dumb user error. I've used regmon, filemon, compared internet advanced settings to no avail.

    Any ideas?

    Thanks,

  • 05-03-2006 06:51 AM In reply to

    Re: Close + NewFromSolution = Permission Denied

    Hello Kenneth and welcome to the forum!

    It sounds like you have already checked descrpancies, but this is all I can think of:

    1. Did you run the MSI or .js file created by regform on each of the client machines?
    2. Different versions of InfoPath?
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 05-03-2006 07:59 AM In reply to

    Re: Close + NewFromSolution = Permission Denied

    >> 1. Did you run the MSI or .js file created by regform on each of the client machines?

    I wrote two quick batch files which secure and unsecure the .XSN files(which you are all welcome to use). Here is what they look like:

    @echo off
    REM ****************************************************
    REM SecureForm.BAT
    REM
    REM Secure InfoPath .XSN form specified in parameter 1
    REM (only enter the form name, not "XSN"
    REM ****************************************************
    if %1 == "" goto error
    REM
    set javafile=%1%.js
    set bakfile=%1%.bak
    set form=%1%.xsn
    set regform="C:\Program Files\Microsoft Office 2003 Developer Resources\Microsoft Office InfoPath 2003 SDK\Tools\regform.exe"
    REM
    REM ' Delete any former intermediate files
    REM
    echo Deleting former security files...
    if exist "%javafile%" del "%javafile%"
    if exist "%bakfile%" del "%bakfile%"
    REM
    REM ' Fully trust the form
    REM
    regform "%form%" /T Yes
    REM
    REM ' Now secure the InfoPath form, using the .js file
    REM
    if exist "%javafile%" cscript "%javafile%"
    goto END

    :ERROR
    echo "You need to supply the InfoPath file name"
    goto END

    :END
    PAUSE




    echo off
    REM ****************************************************
    REM UnsecureForm.BAT
    REM
    REM Unsecure InfoPath .XSN form specified in parameter 1
    REM (only enter the form name, not "XSN"
    REM ****************************************************
    if %1 == "" goto error
    REM
    set javafile=%1%.js
    set bakfile=%1%.bak
    set form=%1%.xsn
    set regform="C:\Program Files\Microsoft Office 2003 Developer Resources\Microsoft Office InfoPath 2003 SDK\Tools\regform.exe"
    REM
    REM ' Delete any former intermediate files
    REM
    echo Deleting former security files...
    if exist "%javafile%" del "%javafile%"
    if exist "%bakfile%" del "%bakfile%"
    regform "%form%"
    REM
    REM ' Now secure the InfoPath form, using the .js file
    REM
    if exist "%javafile%" cscript "%javafile%" /uninstall
    goto END

    :ERROR
    echo "You need to supply the InfoPath file name"
    goto END

    :END
    PAUSE

    >> 2. Different versions of InfoPath?

    No, same versions. Also, I noticed on my laptop that sometimes I get errors like: "Invalid Context for OM call", where other PC's don't when calling: "Application.XDocuments.Close(oActiveDoc);" although this is happening after being involved in things like fileSystemObjects or ADO queries. Or could it be timing issues (I have a very fast laptop). Or scripting language differences? I looked at InfoPath settings and other then MDI, came up with very little that could be changed. Maybe Winscript?

    Thanks for your assistance.
Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.