Log4net
  1. Log4net
  2. LOG4NET-233

Support .NET 4.0 including Client Profile

    Details

      Description

      Please add a release targeting .NET 4.0 (currently in Beta 2). In addition, to support the .NET 4.0 Client Profile, divide any server-side parts into a separate library set that can be optionally referenced/deployed..

      1. log4net-1.2.10-net-4.0.patch
        44 kB
        Markus Ewald
      2. 233b.patch
        7 kB
        Nathaniel Madura
      3. NET4.patch
        8 kB
        Andrzej Mierzwa

        Issue Links

          Activity

          Hide
          Simon Draht added a comment -

          Think both issues address the same problem, i.e. want to have Log4Net being compliant with the Client Profiles of .NET frameworks version 3.5 SP1 and 4.

          Show
          Simon Draht added a comment - Think both issues address the same problem, i.e. want to have Log4Net being compliant with the Client Profiles of .NET frameworks version 3.5 SP1 and 4.
          Hide
          Lars Corneliussen added a comment -

          Are there any plans to include this in future releases? Would be really great! I'm writing a console application that uses log4net and now I'd require my clients to have the full profile installed.

          Show
          Lars Corneliussen added a comment - Are there any plans to include this in future releases? Would be really great! I'm writing a console application that uses log4net and now I'd require my clients to have the full profile installed.
          Hide
          Andrzej Mierzwa added a comment -

          This patch fix runtime security exceptions as described in http://tseonet.blogspot.com/2010/07/making-log4net-run-on-net-40.html.

          NET_4_0 conditional compilation symbol introduced and must be specified in build settings.

          Client profile not supported due to code AspNetTraceAppender (HttpContext.Current is used).

          Show
          Andrzej Mierzwa added a comment - This patch fix runtime security exceptions as described in http://tseonet.blogspot.com/2010/07/making-log4net-run-on-net-40.html . NET_4_0 conditional compilation symbol introduced and must be specified in build settings. Client profile not supported due to code AspNetTraceAppender (HttpContext.Current is used).
          Hide
          Nathaniel Madura added a comment -

          The previous patch was done against some unknown version of the source, so I redid the patch to be against the HEAD of svn.
          To target .Net 4.0 define NET;NET_2_0;NET_4_0, To target .Net 4.0 Client profile append ;NET_CLIENT_PROFILE to the previous define.
          If Client Profile is specified ASPNetTraceAppender is essentially commented out.

          Show
          Nathaniel Madura added a comment - The previous patch was done against some unknown version of the source, so I redid the patch to be against the HEAD of svn. To target .Net 4.0 define NET;NET_2_0;NET_4_0, To target .Net 4.0 Client profile append ;NET_CLIENT_PROFILE to the previous define. If Client Profile is specified ASPNetTraceAppender is essentially commented out.
          Hide
          Nathaniel Madura added a comment -

          Patchfile targeted against SVN HEAD

          Show
          Nathaniel Madura added a comment - Patchfile targeted against SVN HEAD
          Hide
          Markus Ewald added a comment -

          Patch that adds .NET 4.0 Client Profile compatibility to the official log4net 1.2.10 release.

          Uses fine-grained security settings (SecurityCritical and SecuritySafeCritical) instead of skipping verification for the whole assembly.

          Show
          Markus Ewald added a comment - Patch that adds .NET 4.0 Client Profile compatibility to the official log4net 1.2.10 release. Uses fine-grained security settings (SecurityCritical and SecuritySafeCritical) instead of skipping verification for the whole assembly.
          Hide
          Markus Ewald added a comment -

          I have added a patch with the changes I've been using for about a year now, enabling a .NET 4.0 Client Profile build. Maybe it can help in some way. If not, just ignore it or kill it

          Show
          Markus Ewald added a comment - I have added a patch with the changes I've been using for about a year now, enabling a .NET 4.0 Client Profile build. Maybe it can help in some way. If not, just ignore it or kill it
          Hide
          Stefan Bodewig added a comment -

          4.0 should be ready in 1.2.11, client profile may gt pushed to a later release

          Show
          Stefan Bodewig added a comment - 4.0 should be ready in 1.2.11, client profile may gt pushed to a later release
          Hide
          Stefan Bodewig added a comment -

          Nathaniel and Markus, since both of you addressed the different security models in different ways, could you expand on why you did it the way you've chosen?

          Current trunk builds for .NET 4.0 and client profiles and we see some security related issues when using the version that targets 4.0 and are discussing what may be the best way forward on the dev list. See http://mail-archives.apache.org/mod_mbox/logging-log4net-dev/201108.mbox/%3C87zkj4y88u.fsf@v35516.1blu.de%3E for one thread.

          Show
          Stefan Bodewig added a comment - Nathaniel and Markus, since both of you addressed the different security models in different ways, could you expand on why you did it the way you've chosen? Current trunk builds for .NET 4.0 and client profiles and we see some security related issues when using the version that targets 4.0 and are discussing what may be the best way forward on the dev list. See http://mail-archives.apache.org/mod_mbox/logging-log4net-dev/201108.mbox/%3C87zkj4y88u.fsf@v35516.1blu.de%3E for one thread.
          Hide
          Stefan Bodewig added a comment -

          I think - apart from some tweaks that will inevitably become necessary - subversion revision should work for .NET 4.0 as well as Client Profiles of 3.5 and 4.0.

          https://svn.apache.org/viewvc?view=revision&revision=1165341

          Show
          Stefan Bodewig added a comment - I think - apart from some tweaks that will inevitably become necessary - subversion revision should work for .NET 4.0 as well as Client Profiles of 3.5 and 4.0. https://svn.apache.org/viewvc?view=revision&revision=1165341
          Hide
          NN added a comment -

          It is very easy to compile now for .Net 4.0 but vs2010.sln doesn't have the right defines. Fix it please.

          Also make sure it is pure .Net 4.0 build, without any reference to .Net 2.0.
          And verified by PEVerify.

          Show
          NN added a comment - It is very easy to compile now for .Net 4.0 but vs2010.sln doesn't have the right defines. Fix it please. Also make sure it is pure .Net 4.0 build, without any reference to .Net 2.0. And verified by PEVerify.
          Hide
          Stefan Bodewig added a comment -

          NN, which defines do you think are wrong? And where do we still have .NET 2.0 references?

          peverify says

          [IL]: Error: [C:\OSS\log4net\trunk\bin\net\4.0\debug\log4net.dll : log4net.Plugin.RemoteLoggingServerPlugin::Attach][offset 0x0000002C] Method is not visible.
          1 Error(s) Verifying bin\net\4.0\debug\log4net.dll

          I'm not exactly sure what it is trying to tell us - and I'm not sure it really is relevant. If so, please open a separate issue for it.

          Show
          Stefan Bodewig added a comment - NN, which defines do you think are wrong? And where do we still have .NET 2.0 references? peverify says [IL] : Error: [C:\OSS\log4net\trunk\bin\net\4.0\debug\log4net.dll : log4net.Plugin.RemoteLoggingServerPlugin::Attach] [offset 0x0000002C] Method is not visible. 1 Error(s) Verifying bin\net\4.0\debug\log4net.dll I'm not exactly sure what it is trying to tell us - and I'm not sure it really is relevant. If so, please open a separate issue for it.
          Hide
          Igor added a comment -

          I just downloaded the latest 1.2.11 binary version from the download page.
          And it seems the bug of .net 4 client profile is still there.
          If i reference a log4net dll in .net 4 clent profile project there is a "The type or namespace name 'log4net' could not be found (are you missing a using directive or an assembly reference?)" error.
          Maybe I'm missing something?

          Show
          Igor added a comment - I just downloaded the latest 1.2.11 binary version from the download page. And it seems the bug of .net 4 client profile is still there. If i reference a log4net dll in .net 4 clent profile project there is a "The type or namespace name 'log4net' could not be found (are you missing a using directive or an assembly reference?)" error. Maybe I'm missing something?
          Hide
          Stefan Bodewig added a comment -

          Igor, are you sure you are using the log4net.dll from the net-cp/4.0 folder and not one of the others?

          Show
          Stefan Bodewig added a comment - Igor, are you sure you are using the log4net.dll from the net-cp/4.0 folder and not one of the others?
          Hide
          Igor added a comment -

          Yes, you right. I mistakenly tried to use dll from net and not net-cp folder.
          Thanks and sorry.

          Show
          Igor added a comment - Yes, you right. I mistakenly tried to use dll from net and not net-cp folder. Thanks and sorry.
          Hide
          Rufus Buschart added a comment - - edited

          I just downloaded the TRUNK from the Subversion repository and it seems, that I have this Client Framework issue again. When I try to compile it with the .net Framework 4.0 Client Profile as a target I recieve the error message, that "The type or namespace name 'HttpContex' could not be found". Any idea how to fix ist?

          Show
          Rufus Buschart added a comment - - edited I just downloaded the TRUNK from the Subversion repository and it seems, that I have this Client Framework issue again. When I try to compile it with the .net Framework 4.0 Client Profile as a target I recieve the error message, that "The type or namespace name 'HttpContex' could not be found". Any idea how to fix ist?
          Hide
          Dominik Psenner added a comment - - edited

          HttpContext is part of the System.Web namespace, which itself is within the System.Web.dll. Unfortunately the .NET Framework 4.0 Client Profile does not include the System.Web.dll and thus it doesn't know about HttpContext. There are some steps you can take, I'm going to write down two of them:

          1) remove all references to System.Web (in which case you will have to remove log4net.Plugin.RemoteLoggingServerPlugin) to build it
          2) add conditionals that exclude all references when built against the Client Profile

          In case you do 2) please send us a patch together with the revision we can apply it to. The reason why we are able to build it is that we use a buildbot which builds it for us against a client profile with all modifications needed so that it works (I recall that Stefan did a lot of work there). Please someone correct me here if I'm wrong.

          Show
          Dominik Psenner added a comment - - edited HttpContext is part of the System.Web namespace, which itself is within the System.Web.dll. Unfortunately the .NET Framework 4.0 Client Profile does not include the System.Web.dll and thus it doesn't know about HttpContext. There are some steps you can take, I'm going to write down two of them: 1) remove all references to System.Web (in which case you will have to remove log4net.Plugin.RemoteLoggingServerPlugin) to build it 2) add conditionals that exclude all references when built against the Client Profile In case you do 2) please send us a patch together with the revision we can apply it to. The reason why we are able to build it is that we use a buildbot which builds it for us against a client profile with all modifications needed so that it works (I recall that Stefan did a lot of work there). Please someone correct me here if I'm wrong.
          Hide
          Stefan Bodewig added a comment -

          trunk should work without any modifications if you set the "correct" build defines. For the 4.0 Client Profile you have to define NET, NET_2_0, NET_4_0, CLIENT_PROFILE. With those all references to classes not part of the client profile will be hidden.

          The official build system of log4net is NAnt and this automatically sets those defines as needed.

          Show
          Stefan Bodewig added a comment - trunk should work without any modifications if you set the "correct" build defines. For the 4.0 Client Profile you have to define NET, NET_2_0, NET_4_0, CLIENT_PROFILE. With those all references to classes not part of the client profile will be hidden. The official build system of log4net is NAnt and this automatically sets those defines as needed.
          Hide
          Rufus Buschart added a comment -

          Thank you for your kind answere. Solution 1 is what i actually did last week to come around this problem, but solution 2 is what I prefer to do. Sadly I have no idea, where I can set this 'compiler constants' in Visual Studio. I understand, that NAnt does it automatically, but I believe, that a lot users are not using NAnt (like myself). Can you point me to the correct location for setting this constants?

          Show
          Rufus Buschart added a comment - Thank you for your kind answere. Solution 1 is what i actually did last week to come around this problem, but solution 2 is what I prefer to do. Sadly I have no idea, where I can set this 'compiler constants' in Visual Studio. I understand, that NAnt does it automatically, but I believe, that a lot users are not using NAnt (like myself). Can you point me to the correct location for setting this constants?
          Hide
          Dominik Psenner added a comment -
          Show
          Dominik Psenner added a comment - http://tinyurl.com/82mq7h8
          Hide
          Rufus Buschart added a comment -

          What a helpful comment... Problem is, I'm not able to find the constant CLIENT_PROFILE in the csproj-file and therefore I have no idea what to change.

          Show
          Rufus Buschart added a comment - What a helpful comment... Problem is, I'm not able to find the constant CLIENT_PROFILE in the csproj-file and therefore I have no idea what to change.
          Hide
          Dominik Psenner added a comment - - edited

          That's why you have to define it. Clicking on the link above and following one of the first 3 search results (at least those are the ones I have tried) shows you how to achieve that with visual studio. What you cannot do is building log4net from source and expecting that visual studio builds all different dll's for .net 3.5, 4.0, 4.0 client profile since visual studio does not allow you to change the target profile of a project at build-time. What are you trying to achieve that requires you to not use a precompiled log4net dll?

          Show
          Dominik Psenner added a comment - - edited That's why you have to define it. Clicking on the link above and following one of the first 3 search results (at least those are the ones I have tried) shows you how to achieve that with visual studio. What you cannot do is building log4net from source and expecting that visual studio builds all different dll's for .net 3.5, 4.0, 4.0 client profile since visual studio does not allow you to change the target profile of a project at build-time. What are you trying to achieve that requires you to not use a precompiled log4net dll?

            People

            • Assignee:
              Unassigned
              Reporter:
              Daniel McGloin
            • Votes:
              29 Vote for this issue
              Watchers:
              20 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 168h
                168h
                Remaining:
                Remaining Estimate - 168h
                168h
                Logged:
                Time Spent - Not Specified
                Not Specified

                  Development