Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing ILMerge with log4net is causing "inaccessible due to protection level" error
    primarykey
    data
    text
    <p>I created a wrapper class for the initialization of my log4net logging objects in order to make it easier to establish custom properties in the ThreadContext. This occurs within a class library that I have established along with many other useful functions. To join all of the various libraries I have also added an AfterBuild target to ILMerge using the '/internalize' switch.</p> <p>All references to this initializer method <strong>within</strong> the library targeted by ILMerge seem to work just fine. However, when I reference this merged library in other places. My implementation throws protection level errors. I have tried adding various things to the optional exclude (/internalize:excludes.txt) file but this doesn't seem to work.</p> <p>Example excludes.txt:</p> <pre><code>log4net.Config log4net.ThreadContext log4net.LogManager </code></pre> <p>Has anyone else had this issue?</p> <p><strong>[EDIT]:</strong></p> <p>Here is the code:</p> <pre><code> [assembly: log4net.Config.XmlConfigurator(Watch = true)] namespace Logging { public static class Log4NetThreadContext { public static ILog Initialize(Type declaringType) { // Read from configuration XmlConfigurator.Configure(); // Set Properties ThreadContext.Properties["ID"] = ... ... ... ... if(System.Diagnostics.Debugger.IsAttached) { // Special debugging logger return LogManager.GetLogger("DEBUG_MODE"); } else { // Root logger return LogManager.GetLogger(declaringType); } } } } </code></pre> <p>I'm utilizing this code like so..</p> <pre><code>private static readonly Type declaringType = MethodBase.GetCurrentMethod().DeclaringType; private static readonly ILog log = Log4NetThreadContext.Initialize(declaringType); ... log.Info("Something useful"); </code></pre> <p><strong>[EDIT]:</strong></p> <p>This is my AfterBuild target</p> <pre><code>&lt;Target Name="AfterBuild"&gt; &lt;CreateItem Include="@(ReferenceCopyLocalPaths)" Condition="'%(Extension)'=='.dll'"&gt; &lt;Output ItemName="AssembliesToMerge" TaskParameter="Include" /&gt; &lt;/CreateItem&gt; &lt;Message Text="MERGING: @(AssembliesToMerge-&gt;'%(Filename)')" Importance="High" /&gt; &lt;Exec Command="&amp;quot;$(ProgramFiles)\Microsoft\Ilmerge\Ilmerge.exe&amp;quot; /targetplatform:v2 /log /internalize:&amp;quot;ilmerge.excludes.txt&amp;quot; /keyfile:$(AssemblyOriginatorKeyFile) /out:@(MainAssembly) &amp;quot;@(IntermediateAssembly)&amp;quot; @(AssembliesToMerge-&gt;'&amp;quot;%(FullPath)&amp;quot;', ' ')" /&gt; &lt;Delete Files="@(ReferenceCopyLocalPaths-&gt;'$(OutDir)%(DestinationSubDirectory)%(Filename)%(Extension)')" /&gt; </code></pre> <p></p> <p>Is there just a better way in general to debug protection level issues? </p> <pre><code>Log4NetThreadContext.Initialize(System.Type)' is inaccessible due to its protection level </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload