Connect to network Resources with Marshal2.StringToHGlobalUni

Last post 05-09-2008 14:55 by JennyFaifel. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 05-08-2008 17:53

    Connect to network Resources with Marshal2.StringToHGlobalUni

     I am working on the application (Compact Framework 2.0, Windows CE 5.0) that needs to access file share. I came across this post on this web site:

    http://blog.opennetcf.org/ayakhnin/PermaLink.aspx?guid=44f7179b-502d-4ca9-9d4e-520e8d3b236a

     

    Now, the problem I am encountering with this is that the call to Marshal2.StringToHGlobalUni() ends up appending the letter B to the network resource string.

     

    Is this a bug? How can it be avoided?

    Thanks! 

  • 05-08-2008 22:32 In reply to

    • ctacke
    • OpenNETCF Staff
    • Top 10 Contributor
    • Joined on 07-27-2007
    • Indiana
    • Posts 1,889

    Re: Connect to network Resources with Marshal2.StringToHGlobalUni

    What version of the Smart Device Framework is your project referencing? 

  • 05-08-2008 23:41 In reply to

    Re: Connect to network Resources with Marshal2.StringToHGlobalUni

    version 2, community edition

     any thoughts?
     

     

     

  • 05-09-2008 12:09 In reply to

    Re: Connect to network Resources with Marshal2.StringToHGlobalUni

    I have bypassed a problem when I was getting random letters appended by  StringToHGlobalUni by appending "\0" to the parameters passed. Mapping works!!!!

     

    Now, the only question I have left is how do I pass the domain to the network login?

    After trying out this example, I still get the network logon prompt. (Which is what I am trying to get rid of by mapping programmatically).

     

  • 05-09-2008 12:30 In reply to

    • ctacke
    • OpenNETCF Staff
    • Top 10 Contributor
    • Joined on 07-27-2007
    • Indiana
    • Posts 1,889

    Re: Connect to network Resources with Marshal2.StringToHGlobalUni

    You're probably going to have to convert this mess to managed code.  It's been on my "list of things to do" for a long time, but obviously hasn't happend so far (and no idea when I might actually get around to it). 

  • 05-09-2008 12:36 In reply to

    • ctacke
    • OpenNETCF Staff
    • Top 10 Contributor
    • Joined on 07-27-2007
    • Indiana
    • Posts 1,889

    Re: Connect to network Resources with Marshal2.StringToHGlobalUni

    As for the initial problem, I looked at the code and it appears we make the assumption that Marshal.AllocHGlobal initializes its memory after allocation, but the behavior you're seeing suggests otherwise (the extra character was garbage in memory that simply didn't get cleared).  I've updated the SDF source so if you have purchased the Extensions you can send an email to support@opennetcf.com and request the code patch (it's really simple). 

  • 05-09-2008 14:55 In reply to

    Re: Connect to network Resources with Marshal2.StringToHGlobalUni

    ^^ Yes, I saw this link. Someone has referred me to it on the MSDN forums (you are popular):)

     

    A co-worker has recently come across this: (Credential Manager class)

    http://msdn.microsoft.com/en-us/library/aa922921.aspx

     

    I haven't tried these yet, but everyone I talk to, refers me to your C code. Have you had any exposure to this class (Credentials Manager) ?

Page 1 of 1 (7 items)