"unable to load dll" in IDE but fine to run

I have a UserControl which references a managed C++ assembly M, and M has PInvoke functions from unmanaged Dll U. All work fine in VS .Net 2003.

In VS 2005, it can still run well, but when I open the Form Designer for a form containing that UserControl, it shows "Unable to load DLL U: The specified module could not be found."

Those dlls are in the same directory, and the project can run without a problem. Just the form designer cannot find the Dll U.

Any clue



Answer this question

"unable to load dll" in IDE but fine to run

  • Murthyan

    Hi Sergey!

    Thanks for your reply.
    In the case of an abstract class I in fact understood why designer failed. The problem in our case was that the reference worked at some point and then stopped working..

    Could you elaborate the DesignMode property or link me to a ressource, please We'd really like to make our components more safe regarding this issue, if that's possible (crashing the whole VS is not fun ). A quick msdn search got me to the ISite interface, but I don't know how that could help me.

    Kraymer

  • moleman

    Hey Sergey, that was quick!

    I'll have a look into these things at work tomorrow, particularly the parts "Respect xy", it seems I have to learn about these for future development..
    Thanks again for your helpful posts!

    Kraymer

  • CreepyMonkey

    Hi qrli,

    it's not a bug, even if it seems so - designer compile code and run it from temporary folders, so your U.DLL simply not there. Try move it to System32 folder for development time, this should help.



  • Bernd Burger

    Just tried to put the dll in system32, and the IDE can find it now.

    But now the IDE says "Method not found: MyXXXClass.MyXXXMethod()"

    This is crazy...


  • Pranav Sanghadia

    It's not a new method. The project can run well. Just the IDE has trouble with it. And the dll U is a third party library.

    I find a similiar(but different) bug report by googling, which suggest that restarting the IDE may help in some cases. So I restarted the IDE, and now the IDE can find the method with no problem.

    Sigh...


  • Apolon

    Hi Sergey,

    But it works fine in VS 2003. I don't see any reason to break this in VS 2005.

    If it's sure that it won't work properly in VS 2005, well, I take the ugly/inconvenient walkaround...


  • cacosta

    Hi Kraymer,

    Can you describe what makes your VS crash How it happens

    If you think you find a bug, it's best thing to report it - go to Community/Feedback menu and fill new bug.



  • venkks

    Hi Kraymer!

    Glad that you solved that problems.

    Designer create form's base class (Form in typical case or your base class), then it instantiate there all child controls. All this done from temporary assembly and referenced assemblies. This is why designer can't work with abstract base classes or generic base classes - it just can't create object of that type. This is also the problem when controls or base class code reference some static classes or resources, assume that they working in normal environment (not checking DesignMode property).



  • Trisha W

    I'm not sure, but VS2003 may have somehow this file in it's search path. Windows use many ways to find DLL when it's required: application folder, system32 folder, windows folder, folders from PATH environment variable, some registry & VS stuff...

  • Roger Hernandez

    Hello Sergey!

    Sorry for not replying sooner. I've found the reason for the crash, and even found a solution.

    Maybe I elaborate what our problem was:
    We have an mdi application that loads forms of a certain type. We use a baseclass which is inherited from Form and which implements an interface. When creating the form, designer works fine. I can't say when exactly it happend, but at some point it didn't any more. There were cases when inheriting the form from Form instead of inheriting it from our self-created baseclass (also a Form), the problem was gone. Last time (when I posted in this thread) that didn't help either. We were really lost..

    The problem was that one reference link was a wrapper class that depended on several other DLLs. These DLLs weren't found when the Designer tried to compile the form in order to display it. I used a tool called FileMon and monitored VS accesses. I found a section where a DLL wasn't found, after VS had been looking for it in very many locations. I put the necessary DLLs to where the solution file was, and everything went well.

    What I still don't understand is why the designer worked at the beginning But the steps I just described solved the problem for me and a colleague of mine.

    A little OT, but speaking about crashes, I just mention it: Another similar VS designer issue happens if you inherit a form from an abstract class. Compilation must fail of course, but why not skipping the abstract step

    Greetz,

    Kraymer

  • safewithyou247

    Hello qrli!

    I'm not completely sure that we both are experiencing the same problem, but I have a problem as well with the form designer. Other than in your case, it happens with managed DLLs as well.

    So far, I've not been able to perfectly reproduce this bug (I'm very sure it is a bug). In my case, the whole VS2005 app crashes.

    I suppose that is not very useful information for you, but.. it's a fresh thread, maybe we'll get a hint from someone else.

    Kraymer


  • Ilya I. Malyavskiy

    I wish all problems can be explained by abstract class, but designer really fails from time to time while it rebuilds things .

    I know that DataGridView is not designer friendly control, I created it, add few columns and then assign binding source - it append with generated columns (which I don't need at all) and they duplicate my hand added columns. Arrrghh...

    So, primary thing about DesignMode is to keep in mind that your component may be instantiated not inside your app, but inside designer. Here is some things I think may help:

    • Try to create "less coupled" components, i.e. minimize dependency on other components.
    • Be ready for absence of resources or files
    • Configuration options may not be in place
    • Isolated storage may be different in IDE
    • Respect Component.DesignMode property
    • Respect Browsable, DefaultValue, DesignTimeSerialization attributes
    • Respect ShouldSerialize*() and Reset*() methods


  • SQLirrel

    This is new class/method or it existed before Who create U.DLL

  • "unable to load dll" in IDE but fine to run