Shared network, managed code error - InfoPath Dev
in

InfoPath Dev

Office365 Alert - Sandbox has been deprecated in SharePoint Online.
Read more here.

Having trouble finding a blog or post that answers your question? Check out our Custom Search Page

Shared network, managed code error

Last post 11-17-2016 02:22 PM by Hilary Stoupa. 35 replies.
Page 1 of 3 (36 items) 1 2 3 Next >
Sort Posts: Previous Next
  • 09-12-2016 10:20 AM

    Shared network, managed code error

     Hi !!

     As I always say, I'm a newbie with InfoPath but I managed to learn a lot! 

    I made a form that has a managed code where are these two very important codes: SetSaveAsDialogLocation and SetSaveAsDialogFilename. They work, wouhou! 

    They work on my computer, a Windows 8 and they work on my collegue's computer, also a Windows 8. But we also use what we call a 'Terminal Server', an emulator which allows us to use Windows when we are on Linux computers.On that platform, the form does not work! The error message is 'InfoPath cannot open the selected form because of an error in the form's code. Policy settings prevent opening Internet forms with managed code. To fix this problem, contact your system administrator.'

    So I researched that error and it lead me to https://support.microsoft.com/en-ca/kb-2827915
    The problem with their solution is that they publish it on SharePoint, what I do not do. I published the form on a shared repertory. So it is not a website that I can tell the computer to 'trust' ...

    As soon as I remove the code, everything works but there is not specified location for the saving and no predetermined name which is very important... Is there a way to configure those without coding? Or is there a solution to my problem?

     

    Also, I found this: www.infopathdev.com/forums/p/14722/52363.aspx where it says to put the dfs address... is that only for VB? Should I use dfs for the location path?

    That's my code: (I put blablabla for confidentiality)

     

    using Microsoft.Office.InfoPath;
    using System;
    using System.Windows.Forms;
    using System.Xml;
    using System.Xml.XPath;
    using mshtml;

    namespace _._._
    {
        public partial class FormCode
        {
            // Les variables membres ne sont pas prises en charge dans les formulaires activés pour le navigateur.
            // À la place, écrire et lire ces valeurs à partir de FormState
            // dictionnaire utilisant du code tel que le suivant :
            //
            // private object _memberVariable
            // {
            //     get
            //     {
            //         return FormState["_memberVariable"];
            //     }
            //     set
            //     {
            //         FormState["_memberVariable"] = value;
            //     }
            // }

            // REMARQUE : la procédure suivante est requise par Microsoft InfoPath.
            // Elle peut être modifiée à l’aide de Microsoft InfoPath.
            public void InternalStartup()
            {
                EventManager.FormEvents.Save += new SaveEventHandler(FormEvents_Save);
            }

            public void FormEvents_Save(object sender, SaveEventArgs e)
            {
                // Tapez ici le code à exécuter avant une opération « Enregistrer » ou « Enregistrer sous ».

                string day = MainDataSource.CreateNavigator().SelectSingleNode("/my:mesChamps/my:menu/my:datetime/my:day", NamespaceManager).Value;
                string month = MainDataSource.CreateNavigator().SelectSingleNode("/my:mesChamps/my:menu/my:datetime/my:month", NamespaceManager).Value;
                string year = MainDataSource.CreateNavigator().SelectSingleNode("/my:mesChamps/my:menu/my:datetime/my:year", NamespaceManager).Value;
                string hour = MainDataSource.CreateNavigator().SelectSingleNode("/my:mesChamps/my:menu/my:datetime/my:hour", NamespaceManager).Value;
                string minute = MainDataSource.CreateNavigator().SelectSingleNode("/my:mesChamps/my:menu/my:datetime/my:minute", NamespaceManager).Value;
                string type = MainDataSource.CreateNavigator().SelectSingleNode("/my:mesChamps/my:appel/my:info/my:degre", NamespaceManager).Value;
                string location = MainDataSource.CreateNavigator().SelectSingleNode("/my:mesChamps/my:appel/my:info/my:location_scroll", NamespaceManager).Value;


                this.SetSaveAsDialogLocation("\\blablabla\\shares\\s\\STL_COMMUN\\TVE\\TVE_2016\\formulaires");

                this.SetSaveAsDialogFilename(year + "-" + month + "-" + day + "-" + hour + minute + "Z" + "-" + location + "-" + type + ".xml");


                // La propriété Dirty sera définie sur false si l'enregistrement est réussi.
                e.PerformSaveOperation();

                // Tapez ici le code à exécuter après l'enregistrement.

                e.CancelableArgs.Cancel = false;
            }
        }
    }
     

  • 09-12-2016 02:21 PM In reply to

    Re: Shared network, managed code error

    Yeah, that KB directly is talking about issues w/ a SharePoint published form, not a network published form. You could set the form to full trust & sign it with a code signing cert. But you are publishing the form to the network location, not just copying the template file there?
    Hilary Stoupa

  • 09-16-2016 08:15 AM In reply to

    Re: Shared network, managed code error

     Yes I published it there but it won't work...

    I created the name of my access to this repertory on my personal computer and I chose Z: but the others can chose any letter they want... So how can I write an absolute path ?

  • 09-16-2016 09:12 AM In reply to

    Re: Shared network, managed code error

    Also the full trust, it asks me to create a certificate, which I don't know how...

  • 09-17-2016 07:13 AM In reply to

    Re: Shared network, managed code error

    Replying to "how can I write an absolute path" - see the attached screenshot. Use the full server path in this dialog, not "z:\shareddocs" or whatever but \\servername\shareddocs.
    Hilary Stoupa

  • 10-06-2016 07:08 AM In reply to

    Re: Shared network, managed code error

     Ok so now I have a new problem...

     This is my code:

      using Microsoft.Office.InfoPath;
    using System;
    using System.Windows.Forms;
    using System.Xml;
    using System.Xml.XPath;
    using mshtml;

    namespace _._._
    {
        public partial class FormCode
        {
            // Les variables membres ne sont pas prises en charge dans les formulaires activés pour le navigateur.
            // À la place, écrire et lire ces valeurs à partir de FormState
            // dictionnaire utilisant du code tel que le suivant :
            //
            // private object _memberVariable
            // {
            //     get
            //     {
            //         return FormState["_memberVariable"];
            //     }
            //     set
            //     {
            //         FormState["_memberVariable"] = value;
            //     }
            // }

            // REMARQUE : la procédure suivante est requise par Microsoft InfoPath.
            // Elle peut être modifiée à l’aide de Microsoft InfoPath.
            public void InternalStartup()
            {
                EventManager.FormEvents.Save += new SaveEventHandler(FormEvents_Save);
            }

            public void FormEvents_Save(object sender, SaveEventArgs e)
            {
                // Tapez ici le code à exécuter avant une opération « Enregistrer » ou « Enregistrer sous ».

                string day = MainDataSource.CreateNavigator().SelectSingleNode("/my:mesChamps/my:menu/my:datetime/my:day", NamespaceManager).Value;
                string month = MainDataSource.CreateNavigator().SelectSingleNode("/my:mesChamps/my:menu/my:datetime/my:month", NamespaceManager).Value;
                string year = MainDataSource.CreateNavigator().SelectSingleNode("/my:mesChamps/my:menu/my:datetime/my:year", NamespaceManager).Value;
                string hour = MainDataSource.CreateNavigator().SelectSingleNode("/my:mesChamps/my:menu/my:datetime/my:hour", NamespaceManager).Value;
                string minute = MainDataSource.CreateNavigator().SelectSingleNode("/my:mesChamps/my:menu/my:datetime/my:minute", NamespaceManager).Value;
                string type = MainDataSource.CreateNavigator().SelectSingleNode("/my:mesChamps/my:appel/my:info/my:degre", NamespaceManager).Value;
                string location = MainDataSource.CreateNavigator().SelectSingleNode("/my:mesChamps/my:appel/my:info/my:location_scroll", NamespaceManager).Value;


                this.SetSaveAsDialogLocation("Z:\\STL_COMMUN\\TVE\\TVE_2016\\formulaires");

                this.SetSaveAsDialogFilename(year + "-" + month + "-" + day + "-" + hour + minute + "Z" + "-" + location + "-" + type + ".xml");


                // La propriété Dirty sera définie sur false si l'enregistrement est réussi.
                e.PerformSaveOperation();

                // Tapez ici le code à exécuter après l'enregistrement.

                e.CancelableArgs.Cancel = false;
            }
        }
    }

     I got the error that  many names didn't exist in the actual context and that there are no definitions for certains words...how do I fix that? :'(

  • 10-06-2016 07:51 AM In reply to

    Re: Shared network, managed code error

    Perhaps you have your form compatibility set to browser instead of filler?
    Hilary Stoupa

  • 10-06-2016 07:55 AM In reply to

    Re: Shared network, managed code error

     Where do we find that?

  • 10-06-2016 08:03 AM In reply to

    Re: Shared network, managed code error

    Under Form Options > Compatibility
    Hilary Stoupa

  • 10-06-2016 08:29 AM In reply to

    Re: Shared network, managed code error

     It's in Filler mode!

  • 10-06-2016 08:31 AM In reply to

    Re: Shared network, managed code error

    Then I don't know why your code won't compile without more information. Maybe you can attach some screenshots of the issues under the Options tab.
    Hilary Stoupa

  • 10-06-2016 08:47 AM In reply to

    Re: Shared network, managed code error

    Ok it works now!


    New problem.

    The first way I published it was like this with the wizard:

    The first step in a x location:
    And the second step where x is.

    Error message: The form model associated to this form is unaccessible or has been moved. The model of the form on your computer has the same form ID as the model associated, but is in a different location.
    Location of the model associated: x
    Location of origin of the form model on your computer: x (exact same location!)
    Verify that you can access the location of the form model associated and try again to open the form if this solution doesn't work, ask the author of the form to update it.

     

    Then I tried this:

    Published in x:
    And then, published in a folder where x is:

    Error message: Impossible to open this form because it requires a security level of the domain while it only has a restricted autorisation. To solve this problem, open the form from the location where it has been published.

     What do I do :(

  • 10-06-2016 08:50 AM In reply to

    Re: Shared network, managed code error

    What was the issue? Also, your screenshots don't show for me. Can you attach them under the Options tab?
    Hilary Stoupa

  • 10-06-2016 09:07 AM In reply to

    Re: Shared network, managed code error

     I couldn't open the form in the filler mode because of the first error and then because of the second error. I feel like as soon as I put the code, they won't allow me to open it for security reasons?

     

    For the screenshot, I can't find how to put more than one image... But here's one. On the first way I did it, it was folder x, next step folder x

    and the second way I did it was folder x and next step was folder y which is in folder x

     


  • 10-06-2016 09:26 AM In reply to

    Re: Shared network, managed code error

    You code should only require domain trust, but it continues to sound to me as if you aren't publishing correctly, or aren't opening from the published location. If publishing to a network folder, in the second dialog, you should use the \\servername\folder etc. path, not including the mapped drive letter. Perhaps you have an incorrectly published version of the form in your cache? Open InfoPath Filler, go to New and right click and select "Remove" for any previously published versions of your form. You can also attach a copy of your template under the Options tab in a reply and I can test publish it to see if I have the same results.
    Hilary Stoupa

Page 1 of 3 (36 items) 1 2 3 Next >
Copyright © 2003-2017 Qdabra Software. All rights reserved.
View our Terms of Use.