Simplified classes are below. Every namespace is in seperate .cproj. I have “B is defined in an assembly that is not referenced” problem when building z.exe.
I added ctor A(string s) because I don’t want to include y.dll in every z (I have a lot of z). How to make this work with no mess?
One way is to add another argument in A(B b) or A(string s) so that they have different number of arguments but this is not nice to me.
//namespace x
using y;
public class A
{
public A(string s)
public A(B b)
}
//namespace y
public class B
{
public static explicit operator B(string s)
}
//namesapce z
using x;
public class C
{
void M()
{
string s = "";
A(s);
}
}
The only way I know to achieve this is to make the second A constructor internal:
If you have other assemblies that need to use this constructor; you could consider using
InternalsVisibleToattribute.