如何将这个C#代码编译成DLL?

cmp*_*ger 1 c# compiler-construction dll visual-studio

在我正在运行的项目中,我需要将此代码编译为DLL:

// svgzHandler.cs 
using System; 
using System.Web;
namespace svgzHandler
{
    public class svgzHandler : IHttpHandler
    {
        #region IHttpHandler ????
        public bool IsReusable { get { return true; } }
        public void ProcessRequest(HttpContext context)
        {
            HttpResponse r = context.Response;
            r.ContentType = "image/svg+xml";
            r.AppendHeader("Content-Encoding", "gzip");
            r.WriteFile(context.Request.PhysicalPath);
        }
        #endregion
    }
}
Run Code Online (Sandbox Code Playgroud)

只有我不是程序员,没有任何想法,这一切都意味着什么.另外,日文字符应该被替换为什么?它是一个文件夹吗?一份文件?

我有Visual Studio 2010 Ultimate,所以我有编译器,但这是我曾经触及过的第一个C#代码.

谢谢您的帮助!

PS:我不知道这是否会有所帮助,但这是带有说明的网站(翻译自日语):http://www.microsofttranslator.com/bv.aspx? ref = Internal&from =&to = en&a = http:/ /blog.wonderrabbitproject.net/post/2009/06/13/svgze381aee3838fe383b3e38388e383a9e38292IIS75e381a6.aspx

Dar*_*rov 14

日语字符位于节名称内,编译器会忽略它.你可以完全摆脱线条#region,#endregion如果他们打扰你.组织代码是Visual Studio的事情,编译器不使用它们.因此,要编译到程序集,只需在类库的类型的Visual Studio中创建一个新项目,并将此类添加到它.您必须引用System.Web程序集才能成功编译,因为此处定义了此代码中使用的IHttpHandler接口.

所以实际的代码可能只是(svgzHandler.cs):

namespace svgzHandler 
{
    using System; 
    using System.Web; 

    public class svgzHandler : IHttpHandler
    {
        public bool IsReusable { get { return true; } }

        public void ProcessRequest(HttpContext context)
        {
            HttpResponse r = context.Response;
            r.ContentType = "image/svg+xml";
            r.AppendHeader("Content-Encoding", "gzip");
            r.WriteFile(context.Request.PhysicalPath);
        }
    } 
}
Run Code Online (Sandbox Code Playgroud)

顺便说一句,你甚至不需要Visual Studio来编译.您可以直接使用C#编译器:

c:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe /target:library svgzHandler.cs
Run Code Online (Sandbox Code Playgroud)

这会吐一个svgzHandler.dll集会.