InternetGetCookie managed Code error - InfoPath Dev
in

InfoPath Dev

InternetGetCookie managed Code error

Last post 03-08-2006 03:04 PM by skully. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 03-07-2006 08:35 PM

    • skully
    • Not Ranked
    • Joined on 03-01-2006
    • Posts 8

    InternetGetCookie managed Code error

    Hello all,

    I've been trying to create a way to piggyback off of IE's cookie collection within Infopath managed code projects. I have several web service calls in the infopath form's code that require an authentication cookie. Rather than hard-coding the cookie or creating a winform to grab a username/password pair and creating a webrequest, I thought I'd let the infopath form use IE's cookie collection. Should be easy, right?

    In any case, I'm getting an error whenever I try calling the following managed code in an infopath project.

    "System.Security.Permissions.SecurityPermission"


    <DllImport("wininet.dll", CharSet:=CharSet.Auto, SetLastError:=True)> _
    Private Shared Function InternetGetCookie(ByVal url As String, ByVal name As String, ByVal data As StringBuilder, ByRef dataSize As Integer) As Boolean

    End Function

    This snippit of code works in other managed code projects(winforms), but not in an infopath project. Is there a work-around or is this insurmountable?

    I'm using visual studio 2005 for the managed code.

    Thanks for your time -- it's greatly appreciated!

  • 03-08-2006 12:32 AM In reply to

    Re: InternetGetCookie managed Code error

    Hi Skully,
    Go to Tools->Form Options->Security and set your form to be fully trusted and then try. If that doesn't work, check out chapter 8 of our book. Cheers!
    Patrick Halstead
    Project Manager at Qdabra
  • 03-08-2006 07:33 AM In reply to

    • skully
    • Not Ranked
    • Joined on 03-01-2006
    • Posts 8

    Re: InternetGetCookie managed Code error

    Hi Patrick,

    Thanks for the quick reply.

    Yep, it's already under full trust, so I'll have to re-read chapter 8 (I'm a big fan of your book -- definitely one of the best out there, especially for Web services freaks like me).
    OK. I'll keep you posted if this approach works. Basically, I MUST use cookies for this project, so piggy-backing on IE's own collection would be really helpful.

    Take care.
  • 03-08-2006 03:04 PM In reply to

    • skully
    • Not Ranked
    • Joined on 03-01-2006
    • Posts 8

    Re: InternetGetCookie managed Code error

    Hi Patrick (and others),

    I got it to work -- finally. It turns out that the managed code segment DOES run correctly when I publish as a fully-trusted form that's installed via an MSI. I guess it just wasn't allowed to run when VisualStudio 2005 was debugging or previewing the form's code, even when I had the form set to "Full trust."

    In any case, I've now got a solid routine to use IE cookies within a form's managed code during web service calls.

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