dotgnu-pnet
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pnet-developers] [bugs #5436] compiler error: using const string in Dll


From: Rhys Weatherley
Subject: [Pnet-developers] [bugs #5436] compiler error: using const string in DllImport
Date: Thu, 27 Nov 2003 01:59:27 -0500
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.1) Gecko/20020826

This mail is an automated notification from the bugs tracker
 of the project: DotGNU Portable.NET.

/**************************************************************************/
[bugs #5436] Latest Modifications:

Changes by: 
                Rhys Weatherley <address@hidden>
'Date: 
                Thu 11/27/2003 at 06:59 (GMT)

            What     | Removed                   | Added
---------------------------------------------------------------------------
          Resolution | None                      | Fixed
              Status | Open                      | Closed


------------------ Additional Follow-up Comments ----------------------------
Fix committed to CVS - 27 Nov 2003






/**************************************************************************/
[bugs #5436] Full Item Snapshot:

URL: <http://savannah.gnu.org/bugs/?func=detailitem&item_id=5436>
Project: DotGNU Portable.NET
Submitted by: 0
On: Fri 09/19/2003 at 16:12

Category:  None
Severity:  5 - Average
Item Group:  None
Resolution:  Fixed
Assigned to:  None
Status:  Closed


Summary:  compiler error: using const string in DllImport

Original Submission:  Hello, 

I've noticed that you cannot pass a const string to DllImport for the 
libraryname.

<code>
public const string LibName="MyLib";
[DllImport(LibName)] public static extern void Foo();
[DllImport(LibName)] public static extern void Bar();
</code>

this does compile with dotNET but not with dotGNU

cscc error : 'LibName' is not declared in the current scope

The current workaround is that you must pass a literal string to each interop 
entry like this: 

<code>
[DllImport("MyLib")] public static extern void Foo();
[DllImport("MyLib")] public static extern void Bar();
</code>

Unless the compiler optimizes out the duplicates, this will be extremely 
inefficient of memory.  Also, the potential for typing/copying errors 
increases.  If the library name ever changes, you'll need a good search/replace 
function.

Cheers, 

Oscar

Follow-up Comments
------------------


-------------------------------------------------------
Date: Thu 11/27/2003 at 06:59       By: rweather
Fix committed to CVS - 27 Nov 2003

-------------------------------------------------------
Date: Thu 10/09/2003 at 06:19       By: None
Read http://dotgnu.org/pipermail/pnet-developers/2003-May/000170.html

Which opens up a new can of worms. Does anyone have any idea what the priority 
of the stuff is ?.

type > namespace > member ?

Please verify and repost

-------------------------------------------------------
Date: Thu 10/09/2003 at 04:40       By: None
Please note that using XYZ.LibName (ie qualifying the class in which the const 
string is does work)












For detailed info, follow this link:
<http://savannah.gnu.org/bugs/?func=detailitem&item_id=5436>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]