« Previous Next »

Thread: Asp.net and third party unmanaged dll

Last post 12-20-2008 4:59 AM by jabbari. 11 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (12 items)

Sort Posts:

  • 02-04-2008, 5:45 AM

    • nrussa
    • Not Ranked
    • Joined on 01-30-2008, 6:31 PM
    • Posts 5

    Asp.net and third party unmanaged dll

    Greetings,

    I have an asp.net/C# application that uses third party dll to get some system information (get a unique machine id).

    It works well on XP, 2000 and 2003, but when tried on Vista, IIS hangs when accessing dll methods (IIS Worker Process stopped working and was closed).

    I tried different approaches to solve this problem but I'm stuck without anymore ideas to try.

    I know asp.net is finding the dll (if I rename it, it shows an error of file not found), so I think it has to do with security.

    I tried to impersonate (in web.config file), giving full access on file properties to IIS_IUSRS group, .NET Trust level to full, moving project to inetpub\wwwroot folder and some other tries.

    If I use the dll on a winform application, it works great.

    I've done a little dll on vc6 and it also works great on aspnet.
     

    Checking event viewer, on Application tab, I can see this error about IIS process crash:
    "Faulting application w3wp.exe, version 7.0.6000.16386, time stamp 0x4549b5f8, faulting module ntdll.dll, version 6.0.6000.16386, time stamp 0x4549bdc9, exception code 0xc0000374, fault offset 0x000af1c9, process id 0x1614, application start time 0x01c867115fc5d8a0."

    On System tab:
    "A process serving application pool 'DefaultAppPool' suffered a fatal communication error with the Windows Process Activation Service. The process id was '3832'. The data field contains the error number."
     

    Hope someone can shed some light on this subject, since I must be missing something very basic.

    Thanks,
    Nelson R 

  • 02-04-2008, 12:59 PM In reply to

    • anilr
    • Top 10 Contributor
    • Joined on 05-23-2006, 6:13 PM
    • Redmond, WA
    • Posts 2,247

    Re: Asp.net and third party unmanaged dll

    Use debugdiag or debugger tools for windows to collect crash dump for the problem - it may already be available if you go to control panel -> report problems and solutions - the crash dump will give more idea on what is the problem here.

    Anil Ruia
    Senior Software Design Engineer
    IIS Core Server
  • 02-04-2008, 1:46 PM In reply to

    • nrussa
    • Not Ranked
    • Joined on 01-30-2008, 6:31 PM
    • Posts 5

    Re: Asp.net and third party unmanaged dll

    Hi anilr,
    thanks for your response.

    I've tried using DebugDiag but couldn't find the source of the problem. Ill try checking it again.

    On "Problem Reports and Solutions" there are lots of errors on IIS Worker Process.

    For the latest one (can't get any useful information from it):

    Problem signature
    Problem Event Name: APPCRASH
    Application Name: w3wp.exe
    Application Version: 7.0.6000.16386
    Application Timestamp: 4549b5f8
    Fault Module Name: StackHash_97ff
    Fault Module Version: 6.0.6000.16386
    Fault Module Timestamp: 4549bdc9
    Exception Code: c0000374
    Exception Offset: 000af1c9
    OS Version: 6.0.6000.2.0.0.256.6
    Locale ID: 2070
    Additional Information 1: 97ff
    Additional Information 2: 6c327e2c6eabfed95d5a52c2fb78e173
    Additional Information 3: 5935
    Additional Information 4: 6542d178cca9e73635c31368e00b0030

    Extra information about the problem
    Bucket ID: 640949741

    Is there anything special we must do when using an unmanaged third party dll on aspnet? Any option that I maybe missing?

    Thanks,
      Nelson R.

  • 02-04-2008, 2:04 PM In reply to

    • anilr
    • Top 10 Contributor
    • Joined on 05-23-2006, 6:13 PM
    • Redmond, WA
    • Posts 2,247

    Re: Asp.net and third party unmanaged dll

    That status code is STATUS_HEAP_CORRUPTION - you will need to debug through the heap usage in your code - using appverifier's pageheap option can help you with debugging heap related bugs.

    Anil Ruia
    Senior Software Design Engineer
    IIS Core Server
  • 02-06-2008, 4:39 AM In reply to

    • nrussa
    • Not Ranked
    • Joined on 01-30-2008, 6:31 PM
    • Posts 5

    Re: Asp.net and third party unmanaged dll

    Hi anilr,

    using DebugDiag 1.1 (x86), I run it and select the default values:

    Rule type: crash
    Target Type: All IIS/COM+ related processes
    Advanced Configuration: (just pressing next)
    Select dump location...: (just pressing next)
    Rule completed: Activate the rule now
    Finish

    Then I open my webpage and it crashes when accessing the third party dll method (as usual).
    I check on DebugDiag rule "Userdump Count" and its 0.
     

     
    My website isn't doing anything special, it just uses dllimport to define a method and calls that method.

    I'm using a third party dll, so I don't think it has anything to do with code. I still think its related with security accessing unmanaged dll methods.

    Using the exactly same code with the same dll's works on winforms (and it works on other versions of IIS). 

     

     -- EDIT --
    I've noticed a news today "IIS7 is finished", on 4 Feb. Does that means Vista is using an unfinished version of IIS 7?
    On IIS Help/About I'm using version 7.0.6000.16386.

     

    Thanks once again,
       Nelson R. 

     

  • 02-14-2008, 9:59 AM In reply to

    • nrussa
    • Not Ranked
    • Joined on 01-30-2008, 6:31 PM
    • Posts 5

    Re: Asp.net and third party unmanaged dll

    Greetings,

     still trying to solve this problem.

    Can somebody point me to some kind of steps needed to use third party DLLs in asp.net with IIS7?

    Where to configure on IIS, what kind of user must have access or any other information that may help...

    I've checked lot of different places, but none solve it. Maybe I'm missing some kind of configuration. 

    Should I wait for Vista SP1?

     

    Nelson R.

     

  • 09-17-2008, 5:29 AM In reply to

    • hbaradi
    • Not Ranked
    • Joined on 09-17-2008, 9:25 AM
    • Posts 2

    Re: Asp.net and third party unmanaged dll

     HI gays,

    I have the some problem.

     did you found a solution ?

     

    Thanks

     

    Baradi

  • 09-17-2008, 6:59 AM In reply to

    • nrussa
    • Not Ranked
    • Joined on 01-30-2008, 6:31 PM
    • Posts 5

    Re: Asp.net and third party unmanaged dll

    Hi hbaradi,

    nope, unfortunally didn't find any solution.

    Its probably related with third party dll code that's hanging.

    We decided not to go to Vista with current application version and we have on our development task to do ourself one component in .net that do the same as that third party.

     

    Best regards,

    Nelson R  

  • 09-17-2008, 9:02 AM In reply to

    • hbaradi
    • Not Ranked
    • Joined on 09-17-2008, 9:25 AM
    • Posts 2

    Re: Asp.net and third party unmanaged dll

    Hi Nelson,

    Thanks for your answer.

    We decide to produre an other dll using c++ marshalling, and i think it will usabale directly in .net code.

     

    Best regards,

    Baradi

  • 12-04-2008, 9:12 AM In reply to

    • HFadeel
    • Not Ranked
    • Joined on 12-04-2008, 2:08 PM
    • Posts 1

    Re: Asp.net and third party unmanaged dll

     I have also the same problem, I try to use unmanage dll. and the IIS terminated in same cases.

    When the dll function try to return string (heap beasd type - Reference type ) but it work if I call function that return int.

     With me the IIS terminated without any news, and it write almost the same in the Event Log.

     

    Can Anyone tell me Where is the problem and how I can fix it?

  • 12-04-2008, 4:31 PM In reply to

    • anilr
    • Top 10 Contributor
    • Joined on 05-23-2006, 6:13 PM
    • Redmond, WA
    • Posts 2,247

    Re: Asp.net and third party unmanaged dll

    Are you calling the native functions using PInvoke/DllImport or using COM interop - you have probably not attributed the string parameters for the native functions correctly and CLR is probably treating them as BSTRs rather than PCWSTR (or vice-versa) - in any case, this has nothing to do with IIS and is really a .Net framework question - see this link for more documentation on how to call native functions from managed code.

    Anil Ruia
    Senior Software Design Engineer
    IIS Core Server
  • 12-20-2008, 4:59 AM In reply to

    • jabbari
    • Not Ranked
    • Joined on 12-19-2008, 2:08 AM
    • Posts 3

    Re: Asp.net and third party unmanaged dll

     Hello Mr.Nelson I have same problem. I want to import a dll in asp.net, and I have a major problem

     

    First i want to say that this dll works fine in a windows application written in C#, and It works fine when I use the ASP.NET development server (Local machine).

    But when I run the this code in Local host ( I upload it to my webserver ) ,asp.net know its Functions, but dont return anything or return wrong output adn return true output for sometimes.

     Can it be something with the security rights the IIS has? or Web.config? or my way to Import?

    ----------------------------------------------

    for Example this Function code is:

    [DllImport("mydll.dll")]

    public static extern int GetTotal();

    and when i call that ( in localhost )...

    Response.Write( GetTotal().ToString() );

    Output is: "-1" But when i use the ASP.NET development server (Local machine) It works fine, and Output is: "67"

    ----------------------------------------------------

    this Function works true in both ( Localhost and LocalMachine ):

     [DllImport("mydll.dll")]

    public static extern string ErrorDescription(int errorcode);

    and when i call that ...

    Response.Write( ErrorDescription(3) );

    output in Localhost and Localmachine is : "invalid Account" !! therefore it works file in both.

     --------------------------------------------------------

    this Function don't return anything in local host :

    [DllImport("mydll.dll")]

    public static extern string ServerGet(int index);

    and when i call that ...

    Response.Write( ServerGet(1) );

    output in Localhost is empty! but in local machine output is : "219.39.43.34:244"

    -------------------------------------------------------

    i sure that Asp.net know this DLL well, and if its not so Asp.net show error for me but dont work fine! but don't work true. do you know any solution for me?

    Can it be something with the IIS permissions?

Page 1 of 1 (12 items)