ERROR on opening form - InfoPath Dev
in

InfoPath Dev

ERROR on opening form

Last post 04-30-2008 12:39 PM by Greg Collins. 9 replies.
Page 1 of 1 (10 items)
Sort Posts: Previous Next
  • 04-22-2008 08:38 AM

    ERROR on opening form

    This is my error:

    System.InvalidOperationException

    The _Startup or _Shutdown method in this form's code contains one or more calls to members of the Microsoft.Office.Interop.InfoPath.SemiTrust namespace. Calls to this namespace from these methods are not permitted.

       at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)

       at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)

       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)

       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)

       at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)

       at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, CultureInfo culture)

       at Microsoft.Office.Interop.InfoPath.SemiTrust.InfoPathOMHelper.Run(String assemblyFullPathName)

     

    and this is the code I think that is causing the problem:

     

    Public Sub _Startup(ByVal app As Application, ByVal doc As XDocument)

    thisXDocument = doc

    thisApplication = app

    If thisXDocument.DOM.selectSingleNode("/dfs:myFields/my:ApprovalSignatures/my:EmployeeSign").text <> "" Then

    Try

    Dim strCurrentUser As String = System.Environment.UserName

    thisXDocument.DOM.selectSingleNode("/dfs:myFields/my:Misc/my:CurrentUser").text = strCurrentUser

    Catch ex As Exception

    End Try

    End If

    End Sub

     

    The code works fine on my pc, I am using infopath 2007(coding vb.net backward compatible infopath 2003), I have the latest updates, IE 7, running MOSS 2007.

    The pc's that are having the issue are using InfoPath 2003, IE 6.  The pc's have .net framework 2.0 installed and office 2003 primary interop assemblies installed.

    Any suggestions or missing items that need to be installed?

     

  • 04-23-2008 09:46 AM In reply to

    You are confusing the _Startup method with the OnLoad method. They are not the same. You cannot write InfoPath code in the _Startup method. Please add the OnLoad event handler and move your code into there.

  • 04-24-2008 06:18 AM In reply to

    Thanks for the help, I did get the code to work.  I had two try catch statements, I deleted one and rewrote the first one, and left it in the startup.  My problem now is that it is not working on some pc's.  I mirrored internet explorer settings on a machine that was working, to one that was not working and that pc still isn't working.  All pc's have .net 2.0.  The only difference I can see now between the working and non working pc's are that the working pc is using Infopath 2007 and the non working computer is using infopath 2003.  I don't think this would cause the issue because Infopath says no problem in the compatibility checker.

     The problem is as if you add the sharepoint site to the trusted sites, and then the code just doesn't work.

    Greg, so do you think moving the code from _onStartup to _onLoad fix this?

  • 04-24-2008 08:41 AM In reply to

    service pack 2 is installed on office 2003

  • 04-24-2008 04:34 PM In reply to

    All the code that you showed before that you added to the _Startup method should be moved to the Loading method. It doesn't belong in _Startup. Do some reasearch into the Help system on the _Startup method and you will see why.

    As for the form not working on IP03: Is this a browser form? If so, then there shouldn't be an issue because in that case you don't even need InfoPath. If it is not a browser form, I'm not sure at this stage what is wrong. What kind of errors are you getting now?

     

  • 04-25-2008 06:13 AM In reply to

    As a side note, the code works the same in the startup and load events.  The reason I initially put the code in the startup was because I had it pull the username and then query sql database on load.  If i put the code in the onload it would not work, the query would return no values, but moving it to the startup it worked.

    But I have narrowed it down to possibly being service pack 1 on office 2007. Based off this: http://www.infopathdev.com/forums/t/7683.aspx  so I am going to have office 2007 installed without the service pack and go from there.  Hopefully I can get that done today, but I will report back with success or failures.

     The form is not browser based, it is published to MOSS 2007.

  • 04-25-2008 10:42 AM In reply to

    the problem was service pack 1 on ms office 2007.  I uninstalled, reinstalled office 2007, reinstalled with on service pack, republished the forms and all is well now.

     

    thanks for the help.

  • 04-28-2008 03:17 PM In reply to

    I'm glad to hear you got it working... but seriously, I'd look at getting that code out of the _Startup method if at all possible. It might work now, but cause you future headaches down the road. If you look back at your original error message you see:

    System.InvalidOperationException

    The _Startup or _Shutdown method in this form's code contains one or more calls to members of the Microsoft.Office.Interop.InfoPath.SemiTrust namespace. Calls to this namespace from these methods are not permitted.

  • 04-30-2008 07:34 AM In reply to

    I did take the code out of the startup and put it in the load event handler.  works flawless now.

  • 04-30-2008 12:39 PM In reply to

    That's great new! I'm glad you got it all working!

Page 1 of 1 (10 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.