G
Guest
Hello,
I am getting the following error:
"An attribute argument must be a constant expression, typeof expression or
array creation expression"
with this line of code on my GetDLLName() that gets the DllName parameter
for the DllImport:
[DllImport(GetDLLName(), EntryPoint = "Logon", CallingConvention =
CallingConvention.StdCall, CharSet = CharSet.Auto, SetLastError = true)]
public static extern int Logon(ref LOGON_INFO rvLogon);
Here is the GetDLLName() function:
private static string GetDLLName()
{
string DLLName = string.Empty;
#if (DEBUG)
//Constant to store the value for the WIN32 DLL
supplied by Teledirect
//Assumes the DLL will reside in the
C:\WINNT\System32 directory
DLLName = "(''" +
@Environment.SystemDirectory.ToString() + @"\myDLL.dll" + "'')";
#else
//Constant to store the value for the WIN32 DLL
supplied by Teledirect
//Assumes the DLL will reside in the
C:\WINNT\System32 directory
DLLName = "(''" +
@Environment.SystemDirectory.ToString() + @"\myDLL.dll" + "'')";
#endif
return DLLName.ToString();
}
I have not used the DllImport Attribute before, but what I can see it takes
a String value for the DllName, and a set of NamedParameters that are
optional.
Can anyone tell me what I am doing wrong and how to correct it?
Thanks,
I am getting the following error:
"An attribute argument must be a constant expression, typeof expression or
array creation expression"
with this line of code on my GetDLLName() that gets the DllName parameter
for the DllImport:
[DllImport(GetDLLName(), EntryPoint = "Logon", CallingConvention =
CallingConvention.StdCall, CharSet = CharSet.Auto, SetLastError = true)]
public static extern int Logon(ref LOGON_INFO rvLogon);
Here is the GetDLLName() function:
private static string GetDLLName()
{
string DLLName = string.Empty;
#if (DEBUG)
//Constant to store the value for the WIN32 DLL
supplied by Teledirect
//Assumes the DLL will reside in the
C:\WINNT\System32 directory
DLLName = "(''" +
@Environment.SystemDirectory.ToString() + @"\myDLL.dll" + "'')";
#else
//Constant to store the value for the WIN32 DLL
supplied by Teledirect
//Assumes the DLL will reside in the
C:\WINNT\System32 directory
DLLName = "(''" +
@Environment.SystemDirectory.ToString() + @"\myDLL.dll" + "'')";
#endif
return DLLName.ToString();
}
I have not used the DllImport Attribute before, but what I can see it takes
a String value for the DllName, and a set of NamedParameters that are
optional.
Can anyone tell me what I am doing wrong and how to correct it?
Thanks,