KdgDev KdgDev - 10 days ago 10
C# Question

Adding C++ DLL's to a C# project

I'm trying to use the lame_enc.dll file from LAME in a C# project, but adding the thing seems impossible.

I keep getting an error that says that a reference could not be added and to please check if the is accessible, a valid assembly or COM component.

I have no C++ experience, though I would like to use the functionality. Right now I'm using

Process
from the .NET framework to call lame.exe and do stuff, but I'd like to know if there's another way.

Answer

You have to use P/Invoke to call unmanaged APIs from managed code.