Inherited form with DLLImport

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
 
M

Mattias Sjögren

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top