Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
'identifier' : assembly access specifiers are only available in code compiled with a /clr option
Remarks
A type was declared or defined by using an access specifier, which is only permitted in code compiled by using /clr.
This error may result from a misplaced public, protected, or private keyword, or a missing colon (:) after an access specifier within a class or struct.
In C++/CLI, native types can be visible outside an assembly, but you can only specify assembly access for native types in a /clr compilation. For more information, see Type visibility and /clr (Common Language Runtime Compilation).
Example
The following example generates C3381. To fix it, first either remove the public specifier from the class A definition, or compile by using the /clr option. Next, add a colon after private to specify access for class B {} b;. That's because a nested class can't have an assembly access specifier as part of its declaration.
// C3381.cpp
// compile with: /c
public class A { // C3381
private class B {} b; // C3381
};