internalsvisibleto

InternalsVisibleTo attribute isn't working

I am trying to use the InternalsVisibleTo assembly attribute to make my internal classes in a .NET class library visible to my unit test project. For some reason, I keep getting an error message that says: 'MyClassName' is inaccessible due to its protection level Both assemblies are signed and I have the correct key listed in the ...

Using "friend"-declarations for unit testing. Bad idea?

[Of course, the question is not restricted to a specific "friend" implementation, feel free though to point out implementation specifics if relevant] Reading through the unanswered questions, I stumbled upon the InternalsVisibleTo attribute: Specifies that types that are ordinarily visible only within the current assembly are vi...

InternalsVisibleTo not working for Managed C++

InternalsVisibleTo is not working for my managed C++ projects, but it is for my C# projects. Any help would be appreciated. Here is a simplified layout. Project A - C#, has an internal property I want to access from B/C. Project B - Managed C++. References A. Project C - C#, references A. All projects are signed with the same key. Lo...

XmlSerializer and InternalsVisibleTo attribute

Is it possible to make XmlSerializer serialize internal class members by using InternalsVisibleTo attribute? If it is, what assembly should I make my internals visible to. In other words, what assembly name and public key should I provide to the InternalsVisibleTo attribute. ...

Mocking internal classes with RhinoMocks

So I have a bunch of internal classes which I am trying to mock with RhinoMocks. I have added the following line to assemblyinfo.cs: [assembly:InternalsVisibleTo(RhinoMocks.StrongName)] However, this still does not allow me to mock internal classes; I get the following error message from NUnit: MyTests.SomeTest: System.TypeLoadE...

Non-code-generated forwarding shim for testing private methods

In general, I design classes in such a manner as to not require access to privates for testing purposes. An InternalsVisibleTo can also assist. However, I'm currently dealing with a codebase that has a few area which have become reliant on the private accessors mechanism in VSTS (i.e., using VSCodeGenAccessors to generate *_Accessor cl...

SGEN, InternalsVisibleTo and assembly signing

Hi, I'm trying to do something a bit unusual... I have this class Foo : public class Foo { public Foo(string name) { this.Name = name; } internal Foo() { } public string Name { get; internal set; } public int Age { get; set; } } Notice the internal setter for Name, and the internal default c...

InternalsVisibleTo causes CS0246 error: The Type or Namespace could not be found.

I am trying to enable one assembly to access another assembly's internal classes by adding [assembly:InternalsVisibleTo("assembly-name")] to the second assembly. However, this causes the following error: error CS0246: The type or namespace name 'InternalsVisibleTo' could not be found (are you missing a using directive or an assembly...

There is any way to access directly a dll internal classes without copyright infringment?

I need to use some of the Microsoft.SqlServer.Types library internal classes. This is a .NET dll, which is easily disassembled to the language of my choice. So far I could copy its code to my application, but this probably makes my application legally unsuitable for distribution (I haven't read the MS Sql Server 2008 licensing agreement...

Can't get the full public key for 4.0 beta 2 assemblies

I'm having an issue getting the public keys for some of the .net 4.0 beta 2 assemblies so I can make my internals visible to them (gross). Normally, I'd just pop into SN.EXE and poof I'd have them. But instead of getting what I'd normally expect I'm getting a bogus public key, and I'm not sure exactly why. I'm using the 64bit version ...

Silverlight security: giving a permission to access anonymous classes to a class library

I'm porting an existing class library to Silverlight. I used lambda expression compilation a lot and now I'm experiencing security problems because of it. In particular, if an anonymous class from a client SL app is participating in a lambda expression, I cannot compile it: I get a MethodAccessException with the following stack trace: ...

Can i make a library marked with InternalsVisibleTo available for ASP.net MVC application?

The problem is InternalsVisibleTo accepts the assembly name and the name for the asp.net will be randomly generated. How can i get past with this problem? ...

Hide public method used to help test a .NET assembly

I have a .NET assembly, to be released. Its release build includes: A public, documented API of methods which people are supposed to use A public but undocumented API of other methods, which exist only in order to help test the assembly, and which people are not supposed to use The assembly to be released is a custom control, not an ...

Setting Assembly Info for InternalsVisibleTo with MSBuild Community Tasks

I'm using MSBuild Community Tasks to automatically update my assembly version numbers according to my Subversion repository tag. I have added the following to my project file: This gives me a new AssemblyInfo.cs file: unfortunately I need to add the following to get my MStests to work properly: [assembly: System.Runtime.C...

When should [assembly: InternalsVisibleTo()] be used?

I understand that the InternalVisibleTo attribute is used to expose types and methods with the internal access modifier to a specified assembly. I have only ever used this for exposing internal methods to a separate assembly containing a suite of unit tests. I am struggling to think of another scenario when this should be used. Was this...

InternalsVisibleTo attribute isn't working

Before I go on I did go through this InternalsVisibleTo attribute ain’t workin'! Hence the title Okay so I had a working version of my project that was using something like the following. [assembly: InternalsVisibleTo("Stuff.Test.Support, PublicKey="0024000004800000940000000302000000240000525341310004000001000100d158cd56401c3d90b52ca...

InternalsVisibleTo - not working in ascx/aspx file.

I set the InternalsVisibleTo attribute for the friend assembly. In a controller, I can access the internal class, but if I try to do the same in the aspx/ascx file - "class is inaccessible due to its protection level" . Any way I could fix this ? EDIT I should have made things more clear and specify that the attribute was for resource...

referencing and storing the strong name externally for reuse

I have a lot of assemblies that have set the InternalsVisibleToAttribute pointing one specifc assembly within the same solution. Unfortunately the assembly that is being pointed to has a stong name, so I always have to put the same public key token over and over again into the AssemblyInfo.cs files. Since there is no precompiler in c#,...