@@ -42,7 +42,7 @@ protected override OpenNdc GetOpenNdcMethod()
4242 {
4343 var messageParam = Expression . Parameter ( typeof ( string ) , "message" ) ;
4444
45- var ndlcContextType = Type . GetType ( "NLog.NestedDiagnosticsLogicalContext, NLog" ) ;
45+ var ndlcContextType = FindType ( "NLog.NestedDiagnosticsLogicalContext" , " NLog") ;
4646 if ( ndlcContextType != null )
4747 {
4848 var pushObjectMethod = ndlcContextType . GetMethod ( "PushObject" , typeof ( object ) ) ;
@@ -53,7 +53,7 @@ protected override OpenNdc GetOpenNdcMethod()
5353 }
5454 }
5555
56- var ndcContextType = Type . GetType ( "NLog.NestedDiagnosticsContext, NLog" ) ;
56+ var ndcContextType = FindType ( "NLog.NestedDiagnosticsContext" , " NLog") ;
5757 var pushMethod = ndcContextType . GetMethod ( "Push" , typeof ( string ) ) ;
5858
5959 var pushMethodCall = Expression . Call ( null , pushMethod , messageParam ) ;
@@ -64,13 +64,13 @@ protected override OpenMdc GetOpenMdcMethod()
6464 {
6565 var keyParam = Expression . Parameter ( typeof ( string ) , "key" ) ;
6666
67- var ndlcContextType = Type . GetType ( "NLog.NestedDiagnosticsLogicalContext, NLog" ) ;
67+ var ndlcContextType = FindType ( "NLog.NestedDiagnosticsLogicalContext" , " NLog") ;
6868 if ( ndlcContextType != null )
6969 {
7070 var pushObjectMethod = ndlcContextType . GetMethod ( "PushObject" , typeof ( object ) ) ;
7171 if ( pushObjectMethod != null )
7272 {
73- var mdlcContextType = Type . GetType ( "NLog.MappedDiagnosticsLogicalContext, NLog" ) ;
73+ var mdlcContextType = FindType ( "NLog.MappedDiagnosticsLogicalContext" , " NLog") ;
7474 if ( mdlcContextType != null )
7575 {
7676 var setScopedMethod = mdlcContextType . GetMethod ( "SetScoped" , typeof ( string ) , typeof ( object ) ) ;
@@ -85,7 +85,7 @@ protected override OpenMdc GetOpenMdcMethod()
8585 }
8686 }
8787
88- var mdcContextType = Type . GetType ( "NLog.MappedDiagnosticsContext, NLog" ) ;
88+ var mdcContextType = FindType ( "NLog.MappedDiagnosticsContext" , " NLog") ;
8989 var setMethod = mdcContextType . GetMethod ( "Set" , typeof ( string ) , typeof ( string ) ) ;
9090 var removeMethod = mdcContextType . GetMethod ( "Remove" , typeof ( string ) ) ;
9191 var valueParam = Expression . Parameter ( typeof ( string ) , "value" ) ;
@@ -108,7 +108,7 @@ protected override OpenMdc GetOpenMdcMethod()
108108
109109 private static Type GetLogManagerType ( )
110110 {
111- return Type . GetType ( "NLog.LogManager, NLog" ) ;
111+ return FindType ( "NLog.LogManager" , " NLog") ;
112112 }
113113
114114 private static Func < string , object > GetGetLoggerMethodCall ( )
@@ -194,7 +194,7 @@ internal NLogLogger(object logger)
194194
195195 _nameDelegate = ( NameDelegate ) loggerType . GetProperty ( "Name" ) . GetGetMethod ( ) . CreateDelegate ( typeof ( NameDelegate ) , logger ) ;
196196
197- var logEventInfoType = Type . GetType ( "NLog.LogEventInfo, NLog" ) ;
197+ var logEventInfoType = FindType ( "NLog.LogEventInfo" , " NLog") ;
198198 _logEventDelegate = ( type , e ) => loggerType . GetMethod ( "Log" , new Type [ ] { typeof ( Type ) , logEventInfoType } ) . Invoke ( logger , new object [ ] { type , e } ) ;
199199
200200 _isTraceEnabledDelegate = GetIsEnabledDelegate ( logger , "IsTraceEnabled" ) ;
@@ -223,7 +223,7 @@ private static bool Initialize()
223223 {
224224 try
225225 {
226- var logEventLevelType = Type . GetType ( "NLog.LogLevel, NLog" ) ;
226+ var logEventLevelType = FindType ( "NLog.LogLevel" , " NLog") ;
227227 if ( logEventLevelType == null ) throw new LibLogException ( "Type NLog.LogLevel was not found." ) ;
228228
229229 var levelFields = logEventLevelType . GetFields ( ) . ToList ( ) ;
@@ -234,7 +234,7 @@ private static bool Initialize()
234234 s_levelError = levelFields . First ( x => x . Name == "Error" ) . GetValue ( null ) ;
235235 s_levelFatal = levelFields . First ( x => x . Name == "Fatal" ) . GetValue ( null ) ;
236236
237- var logEventInfoType = Type . GetType ( "NLog.LogEventInfo, NLog" ) ;
237+ var logEventInfoType = FindType ( "NLog.LogEventInfo" , " NLog") ;
238238 if ( logEventInfoType == null ) throw new LibLogException ( "Type NLog.LogEventInfo was not found." ) ;
239239
240240 var loggingEventConstructor =
@@ -474,7 +474,7 @@ private object TranslateLevel(LogLevel logLevel)
474474
475475 private static bool IsStructuredLoggingEnabled ( )
476476 {
477- var configFactoryType = Type . GetType ( "NLog.Config.ConfigurationItemFactory, NLog" ) ;
477+ var configFactoryType = FindType ( "NLog.Config.ConfigurationItemFactory" , " NLog") ;
478478 if ( configFactoryType != null )
479479 {
480480 var parseMessagesProperty = configFactoryType . GetProperty ( "ParseMessageTemplates" ) ;
0 commit comments