Problem calling DLL from webform application

  • Thread starter Thread starter James Radke
  • Start date Start date
J

James Radke

Hello,

I am using VB.NET to call an unmanaged DLL which contains some functions.
When I call the DLL from a windows application, it all works fine. When I
place the same code in a webform application, my call to the first
initialization routine simply hangs (i.e. in debugger it shows the code
starts executing, but control never comes back to the debugger).

This DLL uses the MFC42.DLL and MSVCRT.DLL which is in the WINNT/SYSTEM32
folder as well as two other DLLS in the DLL application folder. The system
I am trying to run this on is a Windows 2003 server.

I have both the WINNT\SYSTEM32 and the DLL Application folder in the path
statement.

Can someone explain to me why the call is working from a windows vb.net
application and not from an webform vb.net application? Or, can someone
point out what I should look into to try and correct this issue?

Thanks!

Jim
 
More than likely, the ASP.NET account on the server doesn't have sufficient
permission to execute the DLL.
 
Russell,

What permissions would it require? That the IUSR_<server> has read
permissions on BOTH the application, and SYSTEM32 directories which has the
files? Or are there some other type of permissions required?

Wouldn't my Try, Catch around my first call have returned some type of
permissions error if that is the case?

Thanks!

Jim
 
Hi james,

Which api are you calling?
Can you post your code for me to reproduce the problem?

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Peter,

Unfortunately I cannot post the code for me to reproduce as it needs some
external data files that you won't have. However, it is basically the same
DLL that I was having the problem with calling from VB.NET (i.e. the one
that you created yourself to help me figure out how to pass the data
correctly.) This DLL runs fine in a Windows executable application, but the
same exact code calling the DLL does NOT work from a vb.net webform
application?

If you use the same DLL you created in C++ to test my other issue, and call
it from a webform, you will most likely have the same issue.

Does that help?

Thanks!

Jim
 
Hi James,

The DLL I create is just used to test how to pass the structure.
I have also test that DLL, I can not reproduce the problem.

What exact error message do you get?

To isolate the problem, you may try the code below.
Public Declare Sub GetComputerName Lib "kernel32" _
Alias "GetComputerNameW" _
(<MarshalAs(UnmanagedType.LPWStr)> ByVal lpBuffer As StringBuilder, _
ByRef nSize As Integer)

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim len As Integer, s As StringBuilder = New StringBuilder(50)
len = s.MaxCapacity
GetComputerName(s, len)
Response.Write(s)
End Sub

This will work on my machine.
If this does not work for you, you may try to check the IIS setting.
1 Run inetmgr in the Run dialog and this will open the Internet
Information Services(IIS) Manager
2 Navigated to Internet Information Services/<Computer Name>/Web
Sites/Default Web Site/<WebApplication>, (This is the application name
that you indicated in the VS.NET IDE),
3 Right Click on the WebApplication5 and select Properties, this will
open the WebApplication5 Properties dialog.
4 Select Directory security and then select Authentication and access
control section click the Edit button. This will open the Authentication
methods dialog
5 Uncheck the Enable anonymous access and check the Integrated Windows
authentication. This will enable the browse use the log on user account to
access the aspx page, I assume the account have the permission to access
the NavigateTree.xml file.
6 You may have a try and let me know the result. If you have any related
question please feel free to let me know.


Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top