Results 1 to 8 of 8

Thread: DLL cannot be accessed

  1. #1

    Thread Starter
    New Member At--o's Avatar
    Join Date
    Aug 2011
    Posts
    9

    Smile DLL cannot be accessed

    Precedents:
    Using visual basic express 2010 on windows 7 pro 64b.
    Solution one CLB is a class library with multiple projects.
    Solution two WFA is a windows form application with a reference to one of the CLB projects .dll located in the bin release folder (not the debug folder).
    Problem:
    When CLB gets modified and build, the WFA shows for the class on the .dll:
    “Type “MyClass” is not defined”
    and at description:
    “Unable to load referenced library “MyLibraryDllPath”. The process cannot access the file because it is being used by another process”
    Bad solutions:
    This problem gets solved by either deleting and adding again the reference or by closing the WFA in which case when reopen the reference is good again.
    I know that:
    When referencing the .dll on the bin debug folder doesn’t present this problem after the . dll builds again.
    Solutions with multiple projects don’t create a .dll on the debug folder just on the release one.
    Questions:
    How do I fix this problem?
    Why a reference to the .dll on the debug folder doesn’t generate this problem after the .dll buids again and references to the release folder do?
    Why multiproject solutions doesn’t create a .dll on the debug and single project solutions do?
    Why do I get the message “…cannot access the file because because it is being used by another process”?
    What is that other process using it?

  2. #2
    Fanatic Member proneal's Avatar
    Join Date
    May 2011
    Posts
    762

    Re: DLL cannot be accessed

    IDK, hold on...

    Why does it have to be in the Bin Release folder?
    Why not the Debug folder and to always copy for it's properties?

  3. #3

    Thread Starter
    New Member At--o's Avatar
    Join Date
    Aug 2011
    Posts
    9

    Re: DLL cannot be accessed

    Solutions with multiple projects don’t create a .dll on the debug folder just on the release one.

  4. #4
    Fanatic Member proneal's Avatar
    Join Date
    May 2011
    Posts
    762

    Re: DLL cannot be accessed

    Quote Originally Posted by At--o View Post
    Solutions with multiple projects don’t create a .dll on the debug folder just on the release one.
    So if you copy a DLL from Windows System or other location -other than your Solution folders, it will still build and copy to the Release folder?

    is your Project set in Properties to build and run from Release?

    Or is this a User Control- custom-DLL -and so it gets copied to Release folder on Build?

    It is just that I think that DLL can be in any folder under Solutions -and therefore DLL does not have to be in release or even Debug -because they ARE being used during runtime.

    IDK.
    I think IMHO, you are not correct.

    I always ask many questions because I need to know the answers especially if it 'appears' to be mal informed.

    Show me the link that states DLL must only be in release folder if multiple projects involved within same solution.

    please -

  5. #5
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: DLL cannot be accessed

    Quote Originally Posted by At--o View Post
    Solutions with multiple projects don’t create a .dll on the debug folder just on the release one.
    Yes they do. If all your projects in the solution is set to debug mode in the Configuration Manager it will build them into the Debug folder.

    Whenever you get that error you don't need to close and reopen the project you can simply click on the Clean Solution on the build menu and then build it again.

  6. #6
    Fanatic Member proneal's Avatar
    Join Date
    May 2011
    Posts
    762

    Re: DLL cannot be accessed

    Thank you Mr. Andersson(hmmm fragments of The Matrix come to mind).
    I knew he was incorrect in his assumptions, but I lack the confidence to set things straight because I have been away from programming .NET for several years.

    Hey OP.
    It's all good.
    We all learn these things as we go...

    Good Luck!

  7. #7
    Code Monkey wild_bill's Avatar
    Join Date
    Mar 2005
    Location
    Montana
    Posts
    2,993

    Re: DLL cannot be accessed

    I tried the clean solution approach, no go. Other than closing my solution, I have not found a way to get around this. It is very annoying I might add.
    That is the very essence of human beings and our very unique capability to perform complex reasoning and actually use our perception to further our understanding of things. We like to solve problems. -Kleinma

    Does your code in post #46 look like my code in #45? No, it doesn't. Therefore, wrong is how it looks. - jmcilhinney

  8. #8
    Lively Member elielCT's Avatar
    Join Date
    Jun 2011
    Posts
    89

    Re: DLL cannot be accessed

    this might be a long shot but, did you check task manager to see if there's still something running?
    Sometimes when i'm working on my database I get a similar error that the file is in use. Sure enough, when I stopped/closed my app sql process was not closed. After I end task to the process, re-run it works fine.

    Also compiling a dll causes exposed member names to get "mangled". Might this be one of the culprits? There are ways around this so the exposed member names either stay the same or get set to an alias of your choosing.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width