2

I am trying to access a file from network drive through C# using @boskop 's solution found here.

There's a part where we will have to import this windows dll

[DllImport("mrp.dll")]

And here's the error I get:

Unable to load DLL 'mrp.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

Any ideas on the cause of the error and its solution?

The solution is found... It was a type as Hans pointed and the .dll had to be put along side the assembly as rbm pointed ... I would like to leave the question unedited... it might help some other afflicted programmer like me.. :D

Community
  • 1
  • 1
Linda
  • 147
  • 2
  • 20
  • Is the mrp.dll located alongside your assembly or in the %PATH% ? – rbm Sep 11 '15 at 10:34
  • Good question... Thanks ... It is not found alongside assembly but in this location - C:\Windows\WinSxS\x86_microsoft-windows-mpr_31bf3856ad364e35_6.3.9600.16384_none_42758df9738ae6df .... But if copy and paste it in the assembly folder, will it create any problem? it seems to be a windows core dll.. I am a little worried to duplicate it... What do you suggest? @rbm – Linda Sep 11 '15 at 10:40
  • Slight case of dyslexia at work here, it is "mpr.dll", not "mrp.dll". You got it half-right in the question title. If you are prone to reversing letters, not an uncommon programmer affliction btw, then always put that at the top of the "why isn't it working" list of things to check. – Hans Passant Sep 11 '15 at 10:48
  • Woah... That was exactly what I had done ... Thanks much.. Now it works fine... :) **Not an uncommon programmer affliction** You nailed it! :D @HansPassant ... I had also put it along side the Assembly as rbm suggested .. – Linda Sep 11 '15 at 11:03
  • AFAIK, you shouldn't need to copy it to the directory if it's in `%PATH%`. Check https://msdn.microsoft.com/en-us/library/ms682586(VS.85).aspx – rbm Sep 11 '15 at 11:32
  • Never copy operating system DLLs. – Hans Passant Sep 11 '15 at 11:36

1 Answers1

0

Well you can copy the desired dll (mpr.dll) to your local assembly folder, then follow steps as shown in below image.

  1. In your solution explorer, right click at References, and pick Add Reference.
  2. It will open another window, from here, you can browse your DLL. Give the location and Add.
  3. Now write [DllImport("mpr.dll")]

enter image description here

Amnesh Goel
  • 2,617
  • 3
  • 28
  • 47