1

I am trying to import a .dll file which is written in C to Microsoft Visual C# Studio 2010?

Any ideas why I keep on getting this error?

Please make sure that the file is accessible and that it is a valid assembly prompt.

plinth
  • 48,267
  • 11
  • 78
  • 120
  • Try performing the step in this question: http://stackoverflow.com/questions/8647930/c-sharp-dll-run-time-error-builds-runs-but-throws-unhandled-exception-upon-t – Dor Cohen Feb 14 '12 at 14:25
  • @DorCohen That pre-supposes the existence of a managed assembly that wraps the native DLL – David Heffernan Feb 14 '12 at 14:31

2 Answers2

1

You cannot import a reference to a native DLL. Instead you need to use p/invoke to import each function one by one. This can be a rather laborious process if you have a lot of functions so sometimes a C++/CLI wrapper is more convenient.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
0

I suspect you're not using the DllImportAttribute correctly (or at all). See here: http://msdn.microsoft.com/en-us/library/aa984739(v=vs.71).aspx

Tim Rogers
  • 21,297
  • 6
  • 52
  • 68