Don't know about you, but I can never remember the syntax of a fully qualified class. Here is a quick example of taking a normal web service and splitting up the code so that it can be referenced from the GAC. Often we will need to do this when the service is hosted in SharePoint.
Open the markup of a .asmx file. Right click -> View Markup
Change it from:
<%
@ WebService Language="C#" CodeBehind="Service1.asmx.cs" Class="WebService1.Service1" %>To:
<%
@ WebService Language="C#" Class="MyNamespace.MyClassName, MyAssemblyName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=XYZ" %>*There are many ways to get the public key token, easiest is probably to put the dll in the GAC then browse to %systemroot%\assembly
What this does
It allows you to put your .asmx file into a web site, such as the ISAPI folder in SharePoint, and when .Net handles the request the assembly resolver will get it out of the GAC.
Disadvantages
Once loaded from the GAC the assembly is cached, so changes won't show up until the app pools are recycled or you run IISRESET.
Also, you will need to put the DLL into the GAC each time you compile. This can be done less painfully by using a post build event or using WSPBuilder's "Copy to gac" function.
No comments:
Post a Comment