Muokkaa

Jaa


Compiler Error C2261

'string' : assembly reference is invalid and cannot be resolved

A value was not valid.

InternalsVisibleToAttribute is used to specify a friend assembly. For example, if a.dll wants to specify b.dll as a friend assembly, you would specify (in a.dll): InternalsVisibleTo("b"). The runtime then allows b.dll to access everything in a.dll (except private types).

For more on the correct syntax when specifying friend assemblies, see Friend Assemblies (C++).

Example

The following sample generates C2261.

// C2261.cpp
// compile with: /clr /c
using namespace System::Runtime::CompilerServices;
[assembly: InternalsVisibleTo("a,a,a")];   // C2261
[assembly: InternalsVisibleTo("a.a")];   // OK
[assembly: InternalsVisibleTo("a")];   // OK