Can not load projection file.

JerryLiaJerryLia Global Mapper UserPosts: 26
edited September 2008 in SDK
Mike,
Thanks for sending me the demo license.I save it in the same folder as the GlobalMapperInterface.dll file and a strange problem is coming:the demo license cause my program cannot load projection file to create a custom project system.when i delete the license,everything is OK!

IntPtr ptrPrj = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof (GM_Projection_t)));

//Error occurs
LastGMError = GlobalMapperDLL.GM_LoadProjectionFile(ps_prjFile, ptrPrj);


GM_Projection_t lt_Prj = (GM_Projection_t)Marshal.PtrToStructure(ptrPrj, typeof(GM_Projection_t));
Marshal.FreeCoTaskMem(ptrPrj);
return lt_Prj;

Comments

  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited September 2008
    What error code is being returned?

    As an aside, I think you may be over-complicating things with the dynamic allocation in this function. You should just be able to pass the GM_Projection_t parameter to the GM_LoadProjectionFile function ByRef (or however that is declared in C#) and then just allocate it on the stack rather than allocating a memory buffer and doing all of that marshalling and stuff.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • JerryLiaJerryLia Global Mapper User Posts: 26
    edited September 2008
    Mike,
    Following your advice,i rewrite my code,but the problem exist still。I search for it in internet and find that there is a method to solve it:under "Debug" menu----"Exceptions"----find "Managed Debugging Assistants" and uncheck "LoaderLock" 。
    Are you have another mehod to solve it?

    GM_Projection_t lt_Prj = new GM_Projection_t();
    LastGMError = GlobalMapperDLL.GM_LoadProjectionFile(ps_prjFile, ref lt_Prj);
    return lt_Prj;

    public static extern GM_Error_t32 GM_LoadProjectionFile(String aPrjFile, ref GM_Projection_t aPrj);
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited September 2008
    I have heard of this problem before. I believe it is related to calling unmangaged code (like the Global Mapper DLL) from managed code. I think the only way to get rid of this and still use unmanaged DLLs is to uncheck the "LoaderLock" option.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
Sign In or Register to comment.