user1650004
user1650004

Reputation: 131

C# attributes not recognised

This must be a silly question: I am learning C# here, and I am trying to build a dll which has an iniFile class. the code is direct copy from Code source is here

This project fails to build with error "the type or namespace 'DllImportAttribute' could not be found (are you missing a using directive or an assembly reference?)". The error flags at

[DllImport("kernel32")]

If I comment the attributes out, the build goes well. It must be setting somewhere to resolve this. Any suggestion is welcome..thx

--update-- thanks!

Upvotes: 2

Views: 274

Answers (2)

Daniel A. White
Daniel A. White

Reputation: 190935

Ensure using System.Runtime.InteropServices; is at the top of your file.

Upvotes: 3

Arran
Arran

Reputation: 25056

Ensure you have a using for:

System.Runtime.InteropServices

Upvotes: 3

Related Questions