I load a C++ DLL using DLLImport in my C# ASP.Net web application. The DLL basically reads some CSV files, and manipulates them and creates new files.
After I ran the method successfully, and run it again then I get C++ exception back.
I want to unload the C++ DLL from the website so a user can re- load the DLL and re run the method. Do you know how to either eliminate this error or get rid of this error message so the DLL can be unloaded after its run?
As far as I’m aware, there’s no way to do late binding with C#.
You can do it by creating a C++ DLL and using that, however. Assuming you know enough about C++ to do this, you would just need a single function exported by the DLL, which uses
LoadLibraryto load your CSV manipulation DLL,GetProcAddressto retrieve the address of the function you want to call, and thenFreeLibraryto release the library.An example would be something like:
This isn’t completely safe, though. If possible, it’s better to find out what the problem with your DLL function being called more than once is, and fixing it.