Feeds:
Posts
Comments

Archive for the ‘IIS’ Category

Sometimes it is a lot handier to just update one of the dll’s in the GAC rather than go through the pain of deploying an entire SharePoint solution. In fact it’s one of the key features that makes the CKSDEV Visual Studio plugin so valuable. Not best practice, to copy directly to the GAC, but very handy in a dev environment.

.NET 4.0 has a new gac location

Today, I wanted to quickly update a dll from a custom SharePoint solution. I was baffled when I could not find the dll in the assembly ( “c:\windows\assembly ” ) folder.

Turns out that starting from .NET 4.0 and up there is a new ‘GAC’ folder in town. It is now located in “c:\windows\microsoft.net\assembly“. You can simply browse to that directory with Windows Explorer and view all the folders.  The new GAC folder does not hide version information (=folders) anymore like the old one did.

assembly

They introduced this new folder to avoid issues between CLR 2.0 and CLR 4.0 , the GAC is now split into private GAC’s for each runtime.  The main change is that CLR v2.0 applications now cannot see CLR v4.0 assemblies in the GAC.

So keep in mind there are two folder now. One for .NET versions 2.0, 3.0, 3.5 and one for .NET versions 4.0 and up.

For more information on installing dlls in GAC
http://msdn.microsoft.com/en-us/library/dkkx7f79.aspx

More information about the GAC
http://msdn.microsoft.com/en-us/magazine/dd727509.aspx

Read Full Post »

Introduction

Sometimes I prefer logging to a simple log file instead of using the Event Log, Tracing or the SharePoint Logs. The ability to turn on and off these logs without having to update a dll or web.config is a great advantage in SharePoint as well.

I was a fan of Log4net project but the project is no longer being actively supported. It hasn’t been for years. Due to this lack of maintenance it is now missing support for recent .NET Frameworks like the 4.0, the Compact framework, etc…

On top of this I regularly experienced problems with getting Log4net to work in a SharePoint environment. The most common behavior was that log files were created correctly but remained empty. No log lines were written to the files.

So time to change? Welcome NLog.

Basic principles

The basic principles with NLog are the same as with Log4Net

  • You reference the dll in your project
  • Declare a logger object in your class/function.
  • Call the logging functions
  • Configure the logging behavior by configuration files.

The config files

First positive experience. NLog is very clear where it expects the configuration files to be. This may seem trivial but in a complex website hosting scenario it can be a nightmare to determine the correct location of the Log4Net config files.

The following locations will be searched when executing your program:

  • in the web.config
  • web.nlog located in the same directory as web.config
  • NLog.config in application’s directory
  • NLog.dll.nlog in a directory where NLog.dll is located

For detailed information see the NLog documentationhttp://nlog-project.org/wiki/Configuration_file

The project setup

Using NLog is very simple. It’s actually exactly the same as with log4net.

  • Reference the dll in your project
  • Add a “using NLog” statement to your class
  • Create a logger object
  • Call the correct functions of the log object

Note: logging exceptions is a bit different in NLog. If you want to log an exception you have to call the ‘LogException’ function. You can not pass the exception object as a parameter to the default logging functions.

The config file

One minor issue is that the default log file layout is not as clear as with log4net.

But after reading some documentation I got my log files in almost the same look and feel as in Log4Net.

Here is my configuration file.

   1:  <?xml version="1.0" encoding="utf-8" ?>
   2:  <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
   3:        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   4:        autoReload="true">
   5:    <targets>
   6:       <target name="logfile" xsi:type="File" fileName="C:\Logs\owstimer.txt" 
   7:  layout="${level:padding=-6} ${longdate}  ${logger:shortName=true} ${message}"/>
   8:     </targets>
   9:   
  10:    <rules>
  11:      <logger name="*" minlevel="Trace" writeTo="logfile" />
  12:     </rules>
  13:  </nlog>

Again for more detailed information see the documentation on the NLog project site : http://nlog-project.org/wiki/Configuration_file

Sharepoint specifics

To get it to work in SharePoint

  • Copy the NLog dll in the GAC
  • Copy the above configuration file in the same folder as your web.config file and name it ‘NLog.config’.
  • Deploy your customizations (web parts, eventhandlers, master pages, ….)
  • Do an iisreset (or Application Pool refresh)

And that’s it…

Note : For debugging my custom timer jobs I had to copy the same file in the \bin folder of my SharePoint hive.

Note : Don’t forget to start stop the SharePoint timer service so the service picks up the new version of your dll)
net stop “Windows SharePoint Services Timer”
net start “Windows SharePoint Services Timer”

Read Full Post »

I always get a little nervous when I see a “Service not found” on my development machine instead of the desired website.

Most of the time it can be resolved by doing:

or any combination of the above.
But today it turned out to be “Url reservation”. I probably changed my IIS7 settings a few months back when I was reading a book about WCF.

I finally found that the command “netsh http delete urlacl” did solve my issue and I got my website (on port 80800) working again.

More info about netsh command here , here and here

Read Full Post »

When trying to deploy my SharePoint 2010 solution via Visual Studio 2010 I got the following error.

Error occurred in deployment step ‘Recycle IIS Application Pool’: <nativehr>0×80070005</nativehr><nativestack></nativestack>

Turned out that I forgot to add my user to the “Site Collection Administrators”.

Go to “Site Actions” of the root site , add your user to the list Site Collection Administrators and problem solved.

Read Full Post »

Follow

Get every new post delivered to your Inbox.