.NET experts pls read
Discussion
i'm trying to import a dll written in VC++ 6 into my web application (C#). The dll uses dynamic linking and writes an mdb file using DAO.
The Problem:
When run from an EXE all is OK (C++ exe), when run from a web app the dll throws an exception and when the dll is debugged its says "DAO failed to initialize etc".
I'm importing the dll using [DllImport(@"c:winntsystem32mydll.dll")]
does anyone know how I can fix this?
The Problem:
When run from an EXE all is OK (C++ exe), when run from a web app the dll throws an exception and when the dll is debugged its says "DAO failed to initialize etc".
I'm importing the dll using [DllImport(@"c:winntsystem32mydll.dll")]
does anyone know how I can fix this?
tim_s said:
i'm trying to import a dll written in VC++ 6 into my web application (C#). The dll uses dynamic linking and writes an mdb file using DAO.
The Problem:
When run from an EXE all is OK (C++ exe), when run from a web app the dll throws an exception and when the dll is debugged its says "DAO failed to initialize etc".
I'm importing the dll using [DllImport(@"c:winntsystem32mydll.dll")]
does anyone know how I can fix this?
First up, you should include the namespace System.Runtime.InteropServices for your project, but you probably already have that in there.
Additionally, you might want to grant read access to that DLL for the ASPNET account.
And lastly, does your "mydll.dll" depend on other existing DLL's and are permissions set properly on these? Check with dependency walker (depends.exe) or similar tools.
Good luck.
Wim
tim_s said:
hi,
yep i had included the interopservices namespace.
i too thought it could be permissions but after giving the ASPNET account full access to my hard drive i've decided it must be something else.
Have you tried to run it from a Winforms or console app? It might not necessarily be file permissions but could be account policies.
You also might want to add the SetLastError attribute, so:
[DllImport(@"c:winntsystem32mydll.dll"),SetLastError(true)]
After calling whatever method of your DLL, you can then retrieve the last Win32 error using:
System.Runtime.InteropServices.Marshal.GetLastWin32Error()
Not sure wheter that will give you more info, but it's worth a shot.
[DllImport(@"c:winntsystem32mydll.dll"),SetLastError(true)]
After calling whatever method of your DLL, you can then retrieve the last Win32 error using:
System.Runtime.InteropServices.Marshal.GetLastWin32Error()
Not sure wheter that will give you more info, but it's worth a shot.
wimdows said:
tim_s said:
hi,
yep i had included the interopservices namespace.
i too thought it could be permissions but after giving the ASPNET account full access to my hard drive i've decided it must be something else.
Have you tried to run it from a Winforms or console app? It might not necessarily be file permissions but could be account policies.
hey thanks for the responses so far!
yeah i've tried running it from a windows app and it works!?! how can I change account policies for the ASPNET account?
>> Edited by tim_s on Friday 5th September 11:24
You don't really want to change account policies for the ASPNET account, as this will effect all web apps.
Best thing is to use impersonation, and use the account that you are logged in as (since this doesn't seem to result in any conflict when running from a Winforms or Console app).
A search for "impersonation" and "ASP.NET" on Google will most certainly yield a good number of results.
Hope that helps.
Wim
Best thing is to use impersonation, and use the account that you are logged in as (since this doesn't seem to result in any conflict when running from a Winforms or Console app).
A search for "impersonation" and "ASP.NET" on Google will most certainly yield a good number of results.
Hope that helps.
Wim
Have you run this code in a service before? I have found that code that works perfectly well in user mode suddenly encounters a world of trouble once inside the IIS service...
Have you considered re-implementing the functionality to avoid the need to use the DLL entirely? Might be easier in the long run..
Have you considered re-implementing the functionality to avoid the need to use the DLL entirely? Might be easier in the long run..
Gassing Station | Computers, Gadgets & Stuff | Top of Page | What's New | My Stuff