none
Un Managed code Integartion with ASP.Net application. RRS feed

  • Question

  •  
    • Hi All,

      In my application I need to integrate the one Un Managed Dll in to my application.

      The Dll is third party software I don't have the source code of that Un Managed DLL.

      I need to call one method in the Dll. The method takes three parameters 

      The Dll name is : BatchProcess.dll


      The method syntax is look like below:
      extern "C" BOOL __stdcall BatchProcess(char* sXMLFile, char* sDefaultFile, char* sCodeFile)

      I written some wrapper Classes the wrapper class is look like below:

    [DllImport("BatchProcess.dll", EntryPoint = "BatchProcess", CharSet = CharSet.Auto, CallingConvention = CallingConvention.Cdecl)]

    public static extern unsafe bool GenerateIDCard([MarshalAs(UnmanagedType.LPStr)]StringBuilder sXMLLoadFile, [MarshalAs(UnmanagedType.LPStr)]StringBuilder sDefaultFile, [MarshalAs(UnmanagedType.LPStr)]StringBuilder sCodeFile);


    I need to pass the three file name paths to this method. First parameter is the XML file path. Second parameter is text file path and Third parameter is text file path.

    When I call this method, the method will read the XML file and process internally and generates the PDF file (The path and name of the PDF file we will specify in the XML file).


    When I call this method from the windows application to passing the required parameters, it is generating the PDF file in the specified path in the xml file.

    Same code I migrated into asp.net application and call this method it is executing with out any error. But the pdf file is not generated.

    What is the problem? How can I resolve this issue?

    Please help me on this.

    Regards
    Narayana Swamy

    • Changed type nobugzModerator Wednesday, February 18, 2009 11:44 AM it's a q
    Wednesday, February 18, 2009 5:37 AM

Answers

  • make sure the  IUSR_ComputerName account and the ASPNET account (or NetworkService accounts, for applications that run on IIS 6.0) have the needed (Create/read/write) NTFS permissions on the folders you are readingfrom/writing in.
    • Marked as answer by Zhi-Xin Ye Tuesday, February 24, 2009 6:57 AM
    Thursday, February 19, 2009 2:37 PM

All replies

  • Your declaration is wrong.  Change it to:

        [DllImport("BatchProcess.dll", EntryPoint = "BatchProcess", CharSet = CharSet.Ansi)]
        public static extern bool GenerateIDCard(string sXMLLoadFile, string sDefaultFile, string sCodeFile);


    Hans Passant.
    Wednesday, February 18, 2009 11:11 AM
    Moderator
  • Also realize that the asp.net service runs in a limited security context, make sure it has permission to read/write all files you feed your unmanaged dll.
    Wednesday, February 18, 2009 2:17 PM
  • Hi,

    As per suggestion I changed the Method declaration as specifed in your comment. Still it is not generating the PDF file.

    Is there any security settings are required? please specify those.

    Regards
    Narayana Swamy
    Thursday, February 19, 2009 11:56 AM
  • HIi,

    What are the Permission settings are required. Please give me more details.

    Regards

    Narayana Swamy

     

    Thursday, February 19, 2009 11:57 AM
  • make sure the  IUSR_ComputerName account and the ASPNET account (or NetworkService accounts, for applications that run on IIS 6.0) have the needed (Create/read/write) NTFS permissions on the folders you are readingfrom/writing in.
    • Marked as answer by Zhi-Xin Ye Tuesday, February 24, 2009 6:57 AM
    Thursday, February 19, 2009 2:37 PM
  • Wrong permissions do not cause AccessViolation.  Wrong P/Invoke declarations or poorly written unmanaged code does.
    Hans Passant.
    Thursday, February 19, 2009 3:47 PM
    Moderator
  • When the nativecode opens a file for reading/writing and doesn't check if its actually successfully at doing that it can.  Its relativly rare you need a different Pinvoke signature for a winforms app and a service.
    Thursday, February 19, 2009 3:53 PM