Hi,
I have an internal class, which an internal constructor. In the same
assembly as this class, I have a factory class which uses
Activator.Creat eInstance to create the instance. The code is as
follows:
ISubscriptionCh angeWatcher result;
string[] watcherConfig;
ObjectHandle handle;
if
( ConfigurationMa nager.AppSettin gs[ "SubscriptionWa tcher" ] == null )
{
throw new InvalidOperatio nException(
Properties.Reso urces.WatcherNo tConfigured
);
}
// This is like this string:
MedAssociates.T est.Subscriptio nManager.TestPr ocessor,MedSubs criptionManager .Business.Test
watcherConfig = ConfigurationMa nager.AppSettin gs[
"SubscriptionWa tcher" ].Split( ',' );
if ( watcherConfig.L ength != 2 ) {
throw new InvalidOperatio nException(
Properties.Reso urces.WatcherNo tConfigured
);
}
handle = Activator.Creat eInstance(
watcherConfig[ 1 ],
watcherConfig[ 0 ]
);
result = (ISubscriptionC hangeWatcher)ha ndle.Unwrap();
return result;
For some reason, everything works fine via NUnit tests, which are in a
seperate assembly. InternalsVisiab leTo allows the testing assembly to
see internals of the assembly with the above code.
In my application, I get a MissingMethodEx ception. I was under the
impression that Activator could call constructor code on any member
even if its not directly visible to it. Is this not the case? how is
this usually acomplished.. I know this method of specifing a type to
load via a config file is common.
Thanks
Andy
I have an internal class, which an internal constructor. In the same
assembly as this class, I have a factory class which uses
Activator.Creat eInstance to create the instance. The code is as
follows:
ISubscriptionCh angeWatcher result;
string[] watcherConfig;
ObjectHandle handle;
if
( ConfigurationMa nager.AppSettin gs[ "SubscriptionWa tcher" ] == null )
{
throw new InvalidOperatio nException(
Properties.Reso urces.WatcherNo tConfigured
);
}
// This is like this string:
MedAssociates.T est.Subscriptio nManager.TestPr ocessor,MedSubs criptionManager .Business.Test
watcherConfig = ConfigurationMa nager.AppSettin gs[
"SubscriptionWa tcher" ].Split( ',' );
if ( watcherConfig.L ength != 2 ) {
throw new InvalidOperatio nException(
Properties.Reso urces.WatcherNo tConfigured
);
}
handle = Activator.Creat eInstance(
watcherConfig[ 1 ],
watcherConfig[ 0 ]
);
result = (ISubscriptionC hangeWatcher)ha ndle.Unwrap();
return result;
For some reason, everything works fine via NUnit tests, which are in a
seperate assembly. InternalsVisiab leTo allows the testing assembly to
see internals of the assembly with the above code.
In my application, I get a MissingMethodEx ception. I was under the
impression that Activator could call constructor code on any member
even if its not directly visible to it. Is this not the case? how is
this usually acomplished.. I know this method of specifing a type to
load via a config file is common.
Thanks
Andy