Question

Problem Definition: I have a class library project named IRI.Ket.ShapefileFormat with some internal classes and structures. I introduced another project as a friend assembly to this class library. Then I was able to build my solution and run the program successfully. But while coding, intellisence dose not recognize those internal types and methods. And if I write them manually, they are not colored as expected.

I'm working on Visual Studio 2013 Ultimate edition.

enter image description here

Edit: In the picutre above why Shapefile (this is the internal class type that is defined in the class library and I'm using it in a friend assembly) is not colored like DataColumn? Is this a bug?

More Strange Issue: Every time the solution can be built successfully but after a while some errors appear in the error list and say e.g. Shapefile.Read is inaccessible due to its protection level! Here is a snapshot (all of these methods are internal). Its strange I didn't know projects with errors may be built successfully :)

enter image description here

Was it helpful?

Solution

I finally found what was going wrong. I had lots of class library project with the same public key. These libraries should be introduced as friend assembly.

[assembly: InternalsVisibleTo("Friend1, PublicKey=00240000048000009...")]
[assembly: InternalsVisibleTo("Friend2, PublicKey=00240000048000009...")]
[assembly: InternalsVisibleTo("Friend3, PublicKey=00240000048000009...")]
[assembly: InternalsVisibleTo("Friend4, PublicKey=00240000048000009...")]

So I thought it's a kind of hard coding to repeat the public key every time and I make a const string variable somewhere and use that in the attribute declaration. However in compile time the compiler was able to access it and build the project successfully but in the design time there was no idea how to resolve it.

//somewhere
const string key = "PublicKey=00240000048000009...";
//

And then I changed those lines like this:

[assembly: InternalsVisibleTo("Friend1, " + key)]
[assembly: InternalsVisibleTo("Friend2, " + key)]
[assembly: InternalsVisibleTo("Friend3, " + key)]
[assembly: InternalsVisibleTo("Friend4, " + key)]

So I changed these lines and used the hard code version and now IntelliSense and Syntax coloring are working.

OTHER TIPS

If you have access to the build of IRI.Ket.ShapefileFormat find the assembly.cs file and add the following:

[assembly: InternalsVisibleTo("name of assembly here")]

Put the name of your project that is assessing the Shapefile class between the string quotes above. Then your project can have access to IRI.Ket.ShapefileFormat's internal types.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top