« Previous Next »

Answered Thread: DLLImport doesn't work with Web Service

Last post 10-26-2009 5:19 AM by Superkew. 3 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (4 items)

Sort Posts:

  • 10-06-2009, 5:44 AM

    • Superkew
    • Not Ranked
    • Joined on 10-06-2009, 3:53 AM
    • Posts 4

    DLLImport doesn't work with Web Service

    Hey

    I posted this on the asp.net forum, and they suggested to put it here. Sorry for the formatting.

    I really hope you can help me!

    http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/e3bcbf6f-c51a-4c53-89f2-8e083c5e8981

    I have been searching many sites and forums. I am developing on the same set of dlls as this post: http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/d5a92d8e-1c11-44af-b635-4f89471a3351

    The issue I have is that these are the new c++ dlls from the same source. There is one main dll (agproxy.dll), and 3 dependency dlls: utility.dll, sockets.dll, async.dll.

    When natively consuming the dlls in an application it works 100%. When I use the run debug on a web service in VS2008 (.NET 2.0) it works. (dlls get encapsulated in the wonderful MS exe that holds the debug env.)

    BUT as soon as I publish to IIS... fails.

    Unable to load DLL 'agproxy.dll': A dynamic link library (DLL) initialization routine failed. (Exception from HRESULT: 0x8007045A)

    Here is some information...

    We use an unsafe class, and pass some values by ref in the following manner:

    [WebMethod] public string OpenUsingLocal() { int blah; // This method will create a new transaction. try { ft2_open_transaction(0, &blah, 2); } catch (Exception ex) { return ex.Message; } return "Success"; } [DllImport("agproxy.dll")] public static extern int ft2_open_transaction(int invoicehandlex, int* transactionhandle, int timeout);

    I have also tried manually setting permission on the folder and dlls to full access for all IIS users and the Everyone account to just see if it works.

    Any help would be appreciated!

    I have a log from process monitor here. As you can see the search pattern and how it loads the files... I have only pasted from the IIS process w3wp.exe.

    w3wp.exe QueryOpen C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\nomadtest\e0b02f7d\7d2f67bb\assembly\dl3\5dcabd59\1c759893_4943ca01\agproxy.dll NAME NOT FOUND w3wp.exe QueryOpen C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\nomadtest\e0b02f7d\7d2f67bb\assembly\dl3\5dcabd59\1c759893_4943ca01\agproxy.dll NAME NOT FOUND w3wp.exe QueryOpen C:\WINDOWS\system32\inetsrv\agproxy.dll SUCCESS CreationTime: 10/5/2009 2:58:35 PM, LastAccessTime: 10/5/2009 5:06:33 PM, LastWriteTime: 8/26/2008 6:32:40 AM, ChangeTime: 10/5/2009 3:30:23 PM, AllocationSize: 155,648, EndOfFile: 155,648, FileAttributes: A w3wp.exe CreateFile C:\WINDOWS\system32\inetsrv\agproxy.dll SUCCESS Desired Access: Read Data/List Directory, Execute/Traverse, Synchronize, Disposition: Open, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: n/a, ShareMode: Read, Delete, AllocationSize: n/a, OpenResult: Opened w3wp.exe CreateFileMapping C:\WINDOWS\system32\inetsrv\agproxy.dll SUCCESS SyncType: SyncTypeCreateSection, PageProtection: PAGE_EXECUTE w3wp.exe QueryStandardInformationFile C:\WINDOWS\system32\inetsrv\agproxy.dll SUCCESS AllocationSize: 155,648, EndOfFile: 155,648, NumberOfLinks: 1, DeletePending: False, Directory: False w3wp.exe CreateFileMapping C:\WINDOWS\system32\inetsrv\agproxy.dll SUCCESS SyncType: SyncTypeOther w3wp.exe CreateFileMapping C:\WINDOWS\system32\inetsrv\agproxy.dll SUCCESS SyncType: SyncTypeOther w3wp.exe CloseFile C:\WINDOWS\system32\inetsrv\agproxy.dll SUCCESS w3wp.exe Load Image C:\WINDOWS\system32\inetsrv\agproxy.dll SUCCESS Image Base: 0x10950000, Image Size: 0x28000 w3wp.exe ReadFile C:\WINDOWS\system32\inetsrv\agproxy.dll SUCCESS Offset: 147,456, Length: 8,192, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O w3wp.exe ReadFile C:\WINDOWS\system32\inetsrv\agproxy.dll SUCCESS Offset: 4,096, Length: 32,768, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O w3wp.exe ReadFile C:\WINDOWS\system32\inetsrv\agproxy.dll SUCCESS Offset: 36,864, Length: 32,768, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O w3wp.exe ReadFile C:\WINDOWS\system32\inetsrv\agproxy.dll SUCCESS Offset: 69,632, Length: 32,768, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O w3wp.exe ReadFile C:\WINDOWS\system32\inetsrv\agproxy.dll SUCCESS Offset: 102,400, Length: 12,288, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O w3wp.exe ReadFile C:\WINDOWS\system32\inetsrv\agproxy.dll SUCCESS Offset: 114,688, Length: 16,384, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O w3wp.exe ReadFile C:\WINDOWS\system32\inetsrv\agproxy.dll SUCCESS Offset: 131,072, Length: 8,192, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O w3wp.exe ReadFile C:\WINDOWS\system32\inetsrv\agproxy.dll SUCCESS Offset: 139,264, Length: 8,192, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O w3wp.exe QueryOpen C:\WINDOWS\system32\inetsrv\utility.dll SUCCESS CreationTime: 10/2/2009 11:25:05 AM, LastAccessTime: 10/5/2009 5:06:33 PM, LastWriteTime: 8/26/2008 6:32:34 AM, ChangeTime: 10/5/2009 3:30:23 PM, AllocationSize: 176,128, EndOfFile: 176,128, FileAttributes: A w3wp.exe CreateFile C:\WINDOWS\system32\inetsrv\utility.dll SUCCESS Desired Access: Read Data/List Directory, Execute/Traverse, Synchronize, Disposition: Open, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: n/a, ShareMode: Read, Delete, AllocationSize: n/a, OpenResult: Opened w3wp.exe CreateFileMapping C:\WINDOWS\system32\inetsrv\utility.dll SUCCESS SyncType: SyncTypeCreateSection, PageProtection: PAGE_EXECUTE w3wp.exe QueryStandardInformationFile C:\WINDOWS\system32\inetsrv\utility.dll SUCCESS AllocationSize: 176,128, EndOfFile: 176,128, NumberOfLinks: 1, DeletePending: False, Directory: False w3wp.exe CreateFileMapping C:\WINDOWS\system32\inetsrv\utility.dll SUCCESS SyncType: SyncTypeOther w3wp.exe CreateFileMapping C:\WINDOWS\system32\inetsrv\utility.dll SUCCESS SyncType: SyncTypeOther w3wp.exe CloseFile C:\WINDOWS\system32\inetsrv\utility.dll SUCCESS w3wp.exe Load Image C:\WINDOWS\system32\inetsrv\utility.dll SUCCESS Image Base: 0x10eb0000, Image Size: 0x2d000 w3wp.exe ReadFile C:\WINDOWS\system32\inetsrv\utility.dll SUCCESS Offset: 163,840, Length: 12,288, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O w3wp.exe ReadFile C:\WINDOWS\system32\inetsrv\utility.dll SUCCESS Offset: 4,096, Length: 32,768, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O w3wp.exe ReadFile C:\WINDOWS\system32\inetsrv\utility.dll SUCCESS Offset: 36,864, Length: 32,768, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O w3wp.exe ReadFile C:\WINDOWS\system32\inetsrv\utility.dll SUCCESS Offset: 69,632, Length: 32,768, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O w3wp.exe ReadFile C:\WINDOWS\system32\inetsrv\utility.dll SUCCESS Offset: 102,400, Length: 16,384, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O w3wp.exe ReadFile C:\WINDOWS\system32\inetsrv\utility.dll SUCCESS Offset: 118,784, Length: 8,192, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O w3wp.exe ReadFile C:\WINDOWS\system32\inetsrv\utility.dll SUCCESS Offset: 126,976, Length: 16,384, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O w3wp.exe ReadFile C:\WINDOWS\system32\inetsrv\utility.dll SUCCESS Offset: 143,360, Length: 12,288, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O w3wp.exe ReadFile C:\WINDOWS\system32\inetsrv\utility.dll SUCCESS Offset: 155,648, Length: 8,192, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O w3wp.exe QueryOpen C:\WINDOWS\system32\inetsrv\async.dll SUCCESS CreationTime: 10/2/2009 11:25:05 AM, LastAccessTime: 10/5/2009 5:06:33 PM, LastWriteTime: 8/26/2008 6:32:40 AM, ChangeTime: 10/5/2009 3:30:23 PM, AllocationSize: 90,112, EndOfFile: 90,112, FileAttributes: A w3wp.exe CreateFile C:\WINDOWS\system32\inetsrv\async.dll SUCCESS Desired Access: Read Data/List Directory, Execute/Traverse, Synchronize, Disposition: Open, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: n/a, ShareMode: Read, Delete, AllocationSize: n/a, OpenResult: Opened w3wp.exe CreateFileMapping C:\WINDOWS\system32\inetsrv\async.dll SUCCESS SyncType: SyncTypeCreateSection, PageProtection: PAGE_EXECUTE w3wp.exe QueryStandardInformationFile C:\WINDOWS\system32\inetsrv\async.dll SUCCESS AllocationSize: 90,112, EndOfFile: 90,112, NumberOfLinks: 1, DeletePending: False, Directory: False w3wp.exe CreateFileMapping C:\WINDOWS\system32\inetsrv\async.dll SUCCESS SyncType: SyncTypeOther w3wp.exe CreateFileMapping C:\WINDOWS\system32\inetsrv\async.dll SUCCESS SyncType: SyncTypeOther w3wp.exe CloseFile C:\WINDOWS\system32\inetsrv\async.dll SUCCESS w3wp.exe Load Image C:\WINDOWS\system32\inetsrv\async.dll SUCCESS Image Base: 0x2460000, Image Size: 0x17000 w3wp.exe ReadFile C:\WINDOWS\system32\inetsrv\async.dll SUCCESS Offset: 81,920, Length: 8,192, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O w3wp.exe ReadFile C:\WINDOWS\system32\inetsrv\async.dll SUCCESS Offset: 4,096, Length: 32,768, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O w3wp.exe ReadFile C:\WINDOWS\system32\inetsrv\async.dll SUCCESS Offset: 36,864, Length: 12,288, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O w3wp.exe ReadFile C:\WINDOWS\system32\inetsrv\async.dll SUCCESS Offset: 49,152, Length: 8,192, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O w3wp.exe ReadFile C:\WINDOWS\system32\inetsrv\async.dll SUCCESS Offset: 57,344, Length: 16,384, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O w3wp.exe ReadFile C:\WINDOWS\system32\inetsrv\async.dll SUCCESS Offset: 73,728, Length: 8,192, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O w3wp.exe QueryOpen C:\WINDOWS\system32\inetsrv\sockets.dll SUCCESS CreationTime: 10/2/2009 11:25:05 AM, LastAccessTime: 10/5/2009 5:06:33 PM, LastWriteTime: 8/26/2008 6:32:40 AM, ChangeTime: 10/5/2009 3:30:23 PM, AllocationSize: 86,016, EndOfFile: 86,016, FileAttributes: A w3wp.exe CreateFile C:\WINDOWS\system32\inetsrv\sockets.dll SUCCESS Desired Access: Read Data/List Directory, Execute/Traverse, Synchronize, Disposition: Open, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: n/a, ShareMode: Read, Delete, AllocationSize: n/a, OpenResult: Opened w3wp.exe CreateFileMapping C:\WINDOWS\system32\inetsrv\sockets.dll SUCCESS SyncType: SyncTypeCreateSection, PageProtection: PAGE_EXECUTE w3wp.exe QueryStandardInformationFile C:\WINDOWS\system32\inetsrv\sockets.dll SUCCESS AllocationSize: 86,016, EndOfFile: 86,016, NumberOfLinks: 1, DeletePending: False, Directory: False w3wp.exe CreateFileMapping C:\WINDOWS\system32\inetsrv\sockets.dll SUCCESS SyncType: SyncTypeOther w3wp.exe CreateFileMapping C:\WINDOWS\system32\inetsrv\sockets.dll SUCCESS SyncType: SyncTypeOther w3wp.exe CloseFile C:\WINDOWS\system32\inetsrv\sockets.dll SUCCESS w3wp.exe Load Image C:\WINDOWS\system32\inetsrv\sockets.dll SUCCESS Image Base: 0x10ff0000, Image Size: 0x16000 w3wp.exe ReadFile C:\WINDOWS\system32\inetsrv\sockets.dll SUCCESS Offset: 77,824, Length: 8,192, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O w3wp.exe ReadFile C:\WINDOWS\system32\inetsrv\sockets.dll SUCCESS Offset: 4,096, Length: 32,768, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O w3wp.exe ReadFile C:\WINDOWS\system32\inetsrv\sockets.dll SUCCESS Offset: 36,864, Length: 8,192, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O w3wp.exe ReadFile C:\WINDOWS\system32\inetsrv\sockets.dll SUCCESS Offset: 45,056, Length: 8,192, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O w3wp.exe ReadFile C:\WINDOWS\system32\inetsrv\sockets.dll SUCCESS Offset: 53,248, Length: 16,384, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O w3wp.exe ReadFile C:\WINDOWS\system32\inetsrv\sockets.dll SUCCESS Offset: 69,632, Length: 8,192, I/O Flags: Non-cached, Paging I/O, Synchronous Paging I/O
  • 10-06-2009, 7:22 AM In reply to

    • lextm
    • Top 10 Contributor
    • Joined on 10-22-2008, 12:18 AM
    • Shanghai, PRC
    • Posts 1,430

    Re: DLLImport doesn't work with Web Service

    Where did you put agproxy.dll? Don't put it in ASP.NET web site bin folder as ASP.NET Framework hosted in w3wp.exe will not check native libraries there. Please bring it to system path such as %windir%\system32\ and test again.
    Lex Li
    Support Engineer at Microsoft
    ---------------------------
    This posting is provided "AS IS" with no warranties, and confers no rights.
  • 10-06-2009, 8:40 AM In reply to

    • Superkew
    • Not Ranked
    • Joined on 10-06-2009, 3:53 AM
    • Posts 4

    Re: DLLImport doesn't work with Web Service

    Hi

    It is in the IIS folder:

    C:\WINDOWS\system32\inetsrv\agproxy.dll SUCCESS SyncType: SyncTypeOther w3wp.exe CreateFileMapping

    I have tried in the following folders:

    bin, system32, windir, and the above windir\system32\intserv
  • 10-26-2009, 5:19 AM In reply to

    • Superkew
    • Not Ranked
    • Joined on 10-06-2009, 3:53 AM
    • Posts 4

    Answered Re: DLLImport doesn't work with Web Service

    I have come to a solution. In the end it was mostly a permissions issue. The 4 dlls also use a file called system.dna which seems to act as a config file, but more advanced. When the dlls load correctly the system doesn't access them at all, only the system.dna. I know this sounds strange.... but it seems as though the dlls get loaded into it. To solve this problem I first created a new application pool in IIS, and set it to the local sytem account. I set the website to run in the admin account of the machine and then presto! My website needs to access network resources, so I created a user account with in the following groups: Administrators, IIS_WPG, Users. Then I used that user for the app pool and the website. It all works now... I noticed that the user needs permission on some files in the TEMP dir, in the .NET cache dir and then also in the IIS folder in system32. I hope this helps anyone else who comes along this issue.
Page 1 of 1 (4 items)
Microsoft Communities