locked
Problems while dynamically loading a dll RRS feed

  • Question

  • Hi, I am developing a WCF Web Service that needs to dynamically load a dll library.

    I am trying to use the LoadLibrary() function to load it, but when I run my program in the ASP.NET Development Server to test it, my Web Service doesn't seem to be able to find the dll.

    Where should I place this dll so that my Web Service can load it, in other words, what is the default path that is visible to the ASP.DET Development Server?

    Thanks,
    Komyg

    Monday, September 27, 2010 7:19 PM

Answers

  • It depends on the path that you use in the call LoadLibrary() method. See, if you have any absolute path then you have to place it accordingly. Otherwise the standard approach is that the compiler searches in the current directory (where the exe is existed) and in the System32 folders. Hence, ensure to have your dll copied to any of these locations.

    Let me know, if this is what you are looking for?


    akx Solutions

    Vote if helpful (or) Mark it Answered if answered your query.
    • Proposed as answer by Anand K Reddy Friday, October 1, 2010 7:38 PM
    • Marked as answer by Mike Dos Zhang Wednesday, October 6, 2010 3:31 AM
    Wednesday, September 29, 2010 6:11 AM
  • Hi Komyg,

    Welcome to MSDN Forums!

     

    I’m not an IIS expert, I don’t know if the following information is helpful for you.

     

    http://p2p.wrox.com/asp-net-1-x-2-0-application-design/21439-iis-cannot-find-images-relative-path.html

    planoie

    In .NET server controls, any time you wish to reference a server resource (image, user control, another page) you can make use of the "~" character to act as the "home" placeholder.

    This is only a section from the reply, so you can go to there to read the whole reply.

     

    Enable Parent Paths Is Disabled by Default in IIS 6.0

     

    And I found a thread in IIS forum.

    Thread: Relative path differences between production and development server

    You can read it, and make sure if this is helpful for you.

     

    If this information cannot help you, I think you need to create a new thread at IIS Forum, and there’re more experts researching on IIS topics. So you can get more and better response from there.

    And please don’t forget to close this thread when you leave this thread. Thanks for your understanding and cooperation.

     

    Best wishes,

    Mike

    -------------------------------------------------------------------

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to the others community members reading the thread.

     

    *****************************************************

    [All-In-One Code Framework]

    Sample world! You will get more from this world!

    Welcome to the new world!

    =================================================

    Third party disclaimer

     

    This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information is found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

    • Marked as answer by Mike Dos Zhang Wednesday, October 6, 2010 3:31 AM
    Thursday, September 30, 2010 2:55 AM

All replies

  • It depends on the path that you use in the call LoadLibrary() method. See, if you have any absolute path then you have to place it accordingly. Otherwise the standard approach is that the compiler searches in the current directory (where the exe is existed) and in the System32 folders. Hence, ensure to have your dll copied to any of these locations.

    Let me know, if this is what you are looking for?


    akx Solutions

    Vote if helpful (or) Mark it Answered if answered your query.
    • Proposed as answer by Anand K Reddy Friday, October 1, 2010 7:38 PM
    • Marked as answer by Mike Dos Zhang Wednesday, October 6, 2010 3:31 AM
    Wednesday, September 29, 2010 6:11 AM
  • Hi Komyg,

    Welcome to MSDN Forums!

     

    Dynamically calling an unmanaged dll from .NET (C#)

    IntPtr pDll = NativeMethods.LoadLibrary(@"PathToYourDll.DLL");

     

    This article will show you how to dynamic load and call a dll file in C# using LoadLibrary method. The path is what Anand K Reddy said. You can use absolute or the relative path to let the application can find the file through this path.

     

    If there’s anything unclear, please feel free to let me know.

     

    Have a nice day!

    Mike

    -------------------------------------------------------------------

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to the others community members reading the thread.

     

    *****************************************************

    [All-In-One Code Framework]

    Sample world! You will get more from this world!

    Welcome to the new world!

    Wednesday, September 29, 2010 8:40 AM
  • Hi everyone, thank you for the replies!

    I am aware that I can use a absolute path to load a dll, however I was wondering about the relative path. As Anand K Reddy said: in a normal executable file the relative path is the folder in which the executable is located, however when you start working with a WCF Web Service under IIS 6.0, the relative path ceases to be the folder in which the Web Service is contained. What I would like to know is where is this new path located, in other words if I try to dynamically load a dll using a relative path, where should I place this dll so that my Web Service can find it?

    Thanks,
    Komyg

    Wednesday, September 29, 2010 12:58 PM
  • Hi Komyg,

    Welcome to MSDN Forums!

     

    I’m not an IIS expert, I don’t know if the following information is helpful for you.

     

    http://p2p.wrox.com/asp-net-1-x-2-0-application-design/21439-iis-cannot-find-images-relative-path.html

    planoie

    In .NET server controls, any time you wish to reference a server resource (image, user control, another page) you can make use of the "~" character to act as the "home" placeholder.

    This is only a section from the reply, so you can go to there to read the whole reply.

     

    Enable Parent Paths Is Disabled by Default in IIS 6.0

     

    And I found a thread in IIS forum.

    Thread: Relative path differences between production and development server

    You can read it, and make sure if this is helpful for you.

     

    If this information cannot help you, I think you need to create a new thread at IIS Forum, and there’re more experts researching on IIS topics. So you can get more and better response from there.

    And please don’t forget to close this thread when you leave this thread. Thanks for your understanding and cooperation.

     

    Best wishes,

    Mike

    -------------------------------------------------------------------

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to the others community members reading the thread.

     

    *****************************************************

    [All-In-One Code Framework]

    Sample world! You will get more from this world!

    Welcome to the new world!

    =================================================

    Third party disclaimer

     

    This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information is found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

    • Marked as answer by Mike Dos Zhang Wednesday, October 6, 2010 3:31 AM
    Thursday, September 30, 2010 2:55 AM
  • Hi Komyg,

    Now, I close this thread with mark the reply. We have not seen your response so we cannot know if your issue has been solved by this reply. But I think the reply is helpful on this topic, and it can also help the other communities to solve their issue when they see this thread. Hope you can see this. And thanks for your understanding.

     

    But, please feel free to contact us if you have any response on this question.

     

    Have a nice day!

    Mike

    *****************************************************

    [All-In-One Code Framework]

    Sample world! You will get more from this world!

    Welcome to the new world!

    Wednesday, October 6, 2010 3:32 AM