Bugzilla – Bug 316141
Bad error message with DllImport when you don't use System.Runtime.InteropServices
Last modified: 2007-09-15 21:24:23 UTC
---- Reported by joeshaw@novell.com 2004-09-29 16:07:08 MST ---- Using Mono 1.0.1, if you have code similar to this: [DllImport ("libwnck-1")] extern static IntPtr wnck_screen_get_default (); and you don't have a "using System.Runtime.InteropServices;", mcs will give you the following error: ./FocusTracker.cs(19) error CS0626: Method, operator, or accessor 'Dashboard.WnckScreen.wnck_screen_get_default()' is marked external and has no attributes on it. Consider adding a DllImport attribute to specify the external implementation which is very confusing because I *do* have the DllImport statement there, and I get no error saying that DllImportAttribute couldn't be found. I spent maybe 20 minutes trying to figure out what was going on before it dawned on me to add the using statement. ---- Additional Comments From duncan@ximian.com 2004-09-29 16:25:17 MST ---- With csc 8.00.40607.42 (came with C# Express, should be the same as beta-1), the error shown is: c:\src\test.cs(5,3): error CS0246: The type or namespace name 'DllImport' could not be found (are you missing a using directive or an assembly reference?) ---- Additional Comments From jluke@cfl.rr.com 2004-09-29 17:05:44 MST ---- *** This bug has been marked as a duplicate of https://bugzilla.novell.com/show_bug.cgi?id=MONO60997 *** Unknown operating system unknown. Setting to default OS "Other". This bug was marked DUPLICATE in the database it was moved from. Changing resolution to "MOVED"