Inherited form with DLLImport

  • Thread starter Thread starter mike
  • Start date Start date
M

mike

I have a form that uses a C++ dll through DLLImport.

Then I created a new project and had Form1 inherit the DLL
form.

I can run it without problem, but I cannot open the
derrived form in the form designer because I get a
message "An exception occurred while trying to create an
instance of DLLForm.ControlForm. The exception was "Unable
to load DLL (TestDLL.dll).".

Is there a way to keep it from trying to load the DLL in
design mode, or a way to embed the DLL in the DLLForm so
it can load it?

What is the best way to handle the error?

Thanks,
Mike
 
Is there a way to keep it from trying to load the DLL in
design mode,

It will not be loaded until you actually call one of its functions. So
if you can, avoid calling any of it's functions in design mode.

or a way to embed the DLL in the DLLForm so it can load it?

The runtime uses the LoadLibrary Win32 API function to load unmanaged
DLLs. If you read the MSDN docs for LoadLibrary it'll tell you where
the function looks to find the requested DLL.



Mattias
 
Back
Top