Let me elaborate a bit:
I have three classes in the same assembly
Code:
namespace NS1
{
public Foo
{
private string[] _resourceCodes;
public Foo(ResObj ro)
{
RebindResourceCodes(ro.Keys);
}
private void RebindResourceCodes(string[] resourceKeys)
{
_resourceCodes = Bar.GetResourceCodes(resourceKeys);
}
}
}
namespace NS2
{
internal Bar
{
public static string[] GetResourceCodes(params string[] keys)
{
// Access a new session and return values from Baz
// Perform "select r.Code from Resource r where r.Key in (:resourceKeys)"
}
}
internal Resource {
public string Code { get; set; }
public string Key { get; set; }
}
}
In my very simple test-project I do the following (internals are visible to my test project BTW):
Code:
var codes = Bar.GetResourceCodes("a", "b", "c"); // Succeeds and returns correct results
var ro = new ResObj("a", "b", "c");
var foo = new Foo(ro); // Fails (exception outlined in the above post)
As far as I can see there should be no reason for the second test to fail. The exception is actually not really regarding the accessmodifiers, but changing the Resource class from internal to public solves the problem, but why???