Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dynamic => NullReferenceException' in ReflectSoftware.Insight.Extensions.NLog.dll #1

Open
Gdocal opened this issue Jan 27, 2018 · 10 comments

Comments

@Gdocal
Copy link

Gdocal commented Jan 27, 2018

Exception thrown: 'System.NullReferenceException' in ReflectSoftware.Insight.Extensions.NLog.dll
at ReflectSoftware.Insight.Extensions.NLog.NLogTarget.SendMessage(ActiveStates states, MessageType mType, LogEventInfo logEvent)
and after this exception another exception occur:
Exception thrown: 'System.Security.SecurityException' in mscorlib.dll
Additional information: Requested registry access is not allowed.

Code to reproduce:

  private readonly Logger _logger = LogManager.GetCurrentClassLogger();

    dynamic t = JObject.Parse(@"{
  ""price"": 11190.0,
  ""amount"": 0.43422189,
  ""datetime"": ""1517049417"",
  ""id"": 844079167,
  ""order_type"": 0
}");
                _logger.Trace(t);

Libraries used:
Nlog 4.4.12
Newtonsoft.Json 10.0.0.3
ReflectSoftware.Insight.Extensions.NLog 5.7.1

@Gdocal Gdocal changed the title NullReferenceException' in ReflectSoftware.Insight.Extensions.NLog.dll dynamic => NullReferenceException' in ReflectSoftware.Insight.Extensions.NLog.dll Jan 27, 2018
@calloncampbell
Copy link
Member

Thanks, let me take a look and try to reproduce.

@calloncampbell
Copy link
Member

Are you able to reproduce with the ReflectInsight NLog sample?

@Gdocal
Copy link
Author

Gdocal commented Jan 27, 2018

yes, but let me clarify, these errors doesn't throws up to caller code. I just noticed issue in ReflectInsight Live Viewer and in VS output. In viewer instead of seeing expected data I seeing "Internal Exception:[NullReferenceException->Object reference not set to an instance of an object.]"

So to see more information about errors I enabled 'Break When Throw' in VS (Exception settings) for NullReferenceException and SecurityException exceptions.

@calloncampbell
Copy link
Member

Thanks for clarification. What version of ReflectInsight viewer are you using?

@calloncampbell
Copy link
Member

I'm not seeing the same issue. I'm running the above code inside the ReflectInsight NLog sample app and I updated to the same NuGet package versions listed above:

image

Can you provide me a screenshot, which version of Visual Studio and ReflectInsight you're using.

@Gdocal
Copy link
Author

Gdocal commented Jan 27, 2018

hm.
VS 2015
Live Viewer 5.7.0

ok here is my Config files
App.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="insightSettings" type="ReflectSoftware.Insight.ConfigurationHandler,ReflectSoftware.Insight" />
    <!--<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" />-->
  </configSections>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
    </startup>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="ReflectSoftware.Insight" publicKeyToken="c78ddbdaf1f32b08" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.7.1.1706" newVersion="5.7.1.1706" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="PostSharp" publicKeyToken="b13fd38b8f9c99d7" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.0.44.0" newVersion="5.0.44.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>


  
  <insightSettings>
    <baseSettings>
      <configChange enabled="true" />
      <propagateException enabled="false" />
      <exceptionEventTracker time="20" />
      <debugMessageProcess enabled="true" />
    </baseSettings>

    <listenerGroups active="Debug">
      <group name="Debug" enabled="true" maskIdentities="false">
        <destinations>
          <destination name="Viewer" enabled="true" filter="" details="Viewer" />
        </destinations>
      </group>
    </listenerGroups>

    <logManager>
      <instance name="nlogInstance1" category="NLog" />
      <instance name="fields" />
      <instance name="General" category="General" />
      <instance name="serviceClass" category="ServiceLayer" />
      <instance name="businessClass" category="BusinessLayer" />
      <instance name="dataAccessClass" category="DataAccessLayer" />
    </logManager>

    <extensions>
      <extension name="tracer.fields" instance="fields" />
      <extension name="tracer.General" instance="General" properties="MethodName|Parameters" />
      <extension name="tracer.service" instance="serviceClass" properties="MethodName" />
      <extension name="tracer.business" instance="businessClass" properties="Parameters" />
      <extension name="tracer.dataAccess" instance="dataAccessClass" properties="HashedParameters" />
    </extensions>
  </insightSettings>

</configuration>

NLog.config


<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <!-- In order to recieve location information, you must ensure the layout has the parameter ${callsite} and all its properties set accordantly. -->
  <extensions>
    <add assembly="ReflectSoftware.Insight.Extensions.NLog"/>
  </extensions>
  <targets>
    <target name="ReflectInsight"
            xsi:type="ReflectInsight"
            instanceName="nlogInstance1"
            displayLevel="true"
            displayLocation="true"
            layout="${callsite:className=true:fileName=true:includeSourcePath=true:methodName=true}" />
    <target name="Console" xsi:type="Console" layout="${message}"/>
  </targets>
  <rules>
    <logger name="*" minlevel="TRACE" writeTo="ReflectInsight"  />
   <logger name="*" minlevel="TRACE" writeTo="Console" />
  </rules>
</nlog>


image

I don't know why exception didn't appear in output window. Maybe because I use 'Break When Throw' option

@calloncampbell
Copy link
Member

Thanks, ok let me work with this.

@calloncampbell
Copy link
Member

I quickly just noticed in your app.config the NLog section is commented out. Could be culprit.

When I get home I'll debug with your configs and see whats up.

@Gdocal
Copy link
Author

Gdocal commented Jan 27, 2018

Thanks.
Code works fine everywhere in my project. I noticed issue only in one function which use dynamic variable. So probably it is something specific to dynamic

@calloncampbell
Copy link
Member

No luck. I've modified the sample NLog application with your code and configuration and ran it on another machine which has VS 2015 and ReflectInsight Viewer 5.7.0. App runs and logs without issues.

  1. Can you send me the full exception stacktrace that you see in the ReflectInsight log.
  2. Can you tell me where on your computer (folder path) your code is running.
  3. Can you try running the NLog sample I have in repos "reflectinsight-samples" and use branch "testing-dynamic-content" and let me know what results you have.
  4. Are you able to try your app on another machine?

Thanks
Callon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants