0
votes

HERE is the link to my project.

The error is on line 107: "context = FLAC__stream_encoder_new();" in file: FlacWriter.cs --> I didn't write that file. I got it from HERE

So I understand that libFLAC.dll is missing. So I tried all of the below approaches to solve the issue:

I downloaded libFLAC dll form rarewares.org/lossless.php#flac-dll-x64 I tried to add it as a reference, i get this ERROR: "A reference to C:\CodeProjects\WaveConverter\WaveConverter\Libraries\libFLC_dynamic.dll' could not be added. Please make sure that the file is accessible, and that it is valid assembly or COM component."

I tried something else: I added the dll file to bin/Debug, reopened my project. ran the project again. same error on line: " context = FLAC__stream_encoder_new();" ERROR:"Unable to load DLL 'LibFlac': The specified module could not be found. (Exception from HRESULT: 0x8007007E)"

I also tried 'importing' DLL in my code like this: I tried to add this line: "[DllImport("libFLAC.dll")]" under line 14 in my project file: Worker.cs I get this ERROR: "Duplicate 'DLLimport' attribute'

I also downloaded dependency-walker from dependencywalker.com Not sure how to operate it, but when it finished downloading, I clicked on OPEN icon and opened the libFLAC_dynamic.dll file I was trying to add to the project. And there were no errors. I'm not sure how to use this dependencyWalker though...

What else can I try? How do I fix this error?

1
Is this a case sensitivity issue? You call it 'libFLAC', but the github code calls it 'libFlac'.Laurence Adams
I tried changing line 12 in file: FlacWriter.cs from: LibFlac to LibFLAC. No difference, still get the same error.Awesome_girl
Files on Windows are not sensitive to case. This is a bad steer.David Heffernan

1 Answers

2
votes

You are p/invoking an unmanaged library names LibFlac.dll. You need that library and its dependencies to be in the DLL search path when you first call a function from the library. Typically that means doing the following:

  1. Placing LibFlac.dll in the same directory as your executable file, and
  2. Installing all dependencies that LibFlac.dll has. Typically this will be an MSVC C++ runtime. Read the documentation carefully to work out what dependencies the DLL has.

This is an unmanaged DLL. Don't attempt to add it as a reference. It also seems that the DLL you have is named libFLC_dynamic.dll which differs from the name that your code is expecting. Have you got the right DLL?