473,503 Members | 1,629 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Documentation error

Can
From the MSN documentation;

"By default, /CLRUNMANAGEDCODECHECK is in effect, which means
SuppressUnmanagedCodeSecurityAttribute is applied to linker-generated
PInvoke calls. Specify /CLRUNMANAGEDCODECHECK:NO to not apply this
attribute."

But it seems it's just the opposite (which sounds more logical). By default
no SuppressUnmanagedCodeSecurityAttribute is applied to the C++ interop
calls. And /CLRUNMANAGEDCODECHECK:NO must be specified to apply the
attribute.

There is also a "bug" in Visual Studio. If you specify
AllowPartiallyTrustedCallers attribute, you must explicitly set the
/CLRUNMANAGEDCODECHECK[:NO] switch, but there is no way to set it as
/CLRUNMANAGEDCODECHECK:NO.

Can
Feb 15 '07 #1
4 1751
Hi Can!
"By default, /CLRUNMANAGEDCODECHECK is in effect, which means
SuppressUnmanagedCodeSecurityAttribute is applied to linker-generated
PInvoke calls. Specify /CLRUNMANAGEDCODECHECK:NO to not apply this
attribute."
Yes, this seems to be a docu bug...
But it seems it's just the opposite (which sounds more logical). By default
no SuppressUnmanagedCodeSecurityAttribute is applied to the C++ interop
calls.
I can't confirm that...
If I specify *nothing* in the linker options it will generate the
following PInvoke declaration:

[MethodImpl(MethodImplOptions.Unmanaged,
MethodCodeType=MethodCodeType.Native),
SuppressUnmanagedCodeSecurity,
DllImport("", EntryPoint="",
CallingConvention=CallingConvention.StdCall,
SetLastError=true)]
public static extern unsafe int modopt(CallConvStdcall)
GetUserNameW(char*, uint modopt(IsLong)*);

=SuppressUnmanagedCodeSecurity is applied!

If I specify "/CLRUNMANAGEDCODECHECK", it will *not* apply the attribute:

[MethodImpl(MethodImplOptions.Unmanaged,
MethodCodeType=MethodCodeType.Native),
DllImport("", EntryPoint="", CallingConvention=CallingConvention.StdCall,
SetLastError=true)]
public static extern unsafe int modopt(CallConvStdcall)
GetUserNameW(char*, uint modopt(IsLong)*);
If I specify "/CLRUNMANAGEDCODECHECK:NO", it will *apply* the attribute:
[MethodImpl(MethodImplOptions.Unmanaged,
MethodCodeType=MethodCodeType.Native),
SuppressUnmanagedCodeSecurity,
DllImport("", EntryPoint="",
CallingConvention=CallingConvention.StdCall,
SetLastError=true)]
public static extern unsafe int modopt(CallConvStdcall)
GetUserNameW(char*, uint modopt(IsLong)*);
And /CLRUNMANAGEDCODECHECK:NO must be specified to apply the
attribute.
Or you do not apply this option at all.

In short:

No linker option: =SuppressUnmanagedCodeSecurity
/CLRUNMANAGEDCODECHECK =*no* SuppressUnmanagedCodeSecurity
/CLRUNMANAGEDCODECHECK:NO =SuppressUnmanagedCodeSecurity

Tested with VS2005-SP1 and the following code:
#include <windows.h>
#pragma comment(lib, "Advapi32.lib")

namespace Foo
{
ref class Bar
{
void Test()
{
TCHAR szStr[100];
DWORD dwSize = 100;
BOOL bRet = GetUserName(szStr, &dwSize);
DWORD dw = GetLastError();
}
};
}

int main()
{
}

Greetings
Jochen
Feb 15 '07 #2
Can
Thank you for your reply.
>I can't confirm that...
If I specify *nothing* in the linker options it will generate the
following PInvoke declaration:
I guess I made a mistake by the "no switch" test. Sorry for that.
>If I specify "/CLRUNMANAGEDCODECHECK:NO", it will *apply* the attribute:
How do you specify "/CLRUNMANAGEDCODECHECK:NO" in Visual Studio? Because
when I try to set it through the project properties dialog (by selecting
"No" for the "CLR unmanaged code check" field) , VS just removes the switch
from the command line instead of appending "/CLRUNMANAGEDCODECHECK:NO". If
you do not use the AllowPartiallyTrustedCallers attribute, it does not
matter, because the default is NO switch anyway. But otherwise the linker
gives me a warning.

Again from the MSDN doc;

"Note that if you use AllowPartiallyTrustedCallersAttribute in your code,
you should explicitly set /CLRUNMANAGEDCODECHECK:NO. It is potential
security vulnerability if an image contains both the
SuppressUnmanagedCodeSecurity and AllowPartiallyTrustedCallers attributes."

For now I manually append the switch.

Regards;
Can
Feb 15 '07 #3
Hi Can!
How do you specify "/CLRUNMANAGEDCODECHECK:NO" in Visual Studio?
I added it in
"Linker|Command Line|Additonal Options"
;-)

Greetings
Jochen
Feb 15 '07 #4
Can
Oh I see :)

Thank you very much...

Regards
Can

"Jochen Kalmbach [MVP]" <no********************@holzma.dewrote in message
news:OM**************@TK2MSFTNGP02.phx.gbl...
Hi Can!
>How do you specify "/CLRUNMANAGEDCODECHECK:NO" in Visual Studio?

I added it in
"Linker|Command Line|Additonal Options"
;-)

Greetings
Jochen

Feb 16 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2868
by: Brian Beck | last post by:
Hi. I'm having some problems with code based directly on the following httplib documentation code: http://www.zvon.org/other/python/doc21/lib/httplib-examples.html I've included the code and...
2
1488
by: Andy Fish | last post by:
Hi, I an trying to figure out how to use some browser objects like screen, window, parent, document, top etc. These are available as built-in global variables when programming the browser using...
4
1888
by: PaulThomas | last post by:
WHY does the .Net Documentation show http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebsessionstatehttpsessionstatememberstopic.asp .NET Framework Class...
1
4575
by: Kal | last post by:
Hello, System.Data.SqlClient.SqlException: General network error. Check your network documentation. What does this error means? My web app, suddenly started to show this error today in my...
4
1220
by: Peter | last post by:
I found a minor error in the Python documentation for 2.4 which I thought I would report. But after a while I gave up. I wonder if this sort of reporting which is less than a bug could be made...
40
2756
by: GTi | last post by:
Is there any source code documentation tools available for Visual Studio 2005 ? I have created a LIB that must be documented. Must I do it by hand or is it some kind of tools to pre document my...
1
2077
by: John Nagle | last post by:
If you try to open a password protected page with "urllib.urlopen()", you get "Enter username for EnterPassword at example.com:" on standard output, followed by a read for input! This seems to...
4
1271
by: Shatadal | last post by:
In the python documentation section 14.3.2.6 (http://docs.python.org/ lib/optparse-generating-help.html) in the last line it is written "options that have a default value can include %default in...
0
2158
by: johnkamal | last post by:
Hi, Some times while opening a page, I am getting the following error message, Please help me to rectify the problem. Server Error in '/' Application. General network error. Check your...
7
1410
by: Anita Kean | last post by:
Hello I just downloaded the new python2.6 documentation, full of hopes it would solve some basic mysteries for me. I'm new to python, so please forgive my ignorance. I've two questions. 1)...
0
7202
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7278
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5013
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3167
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1512
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
380
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.