中道学友技术专栏

中庸之道, 平衡恰好. 向朋友们友学习, 做大家学习的朋友.
随笔 - 314, 文章 - 2, 评论 - 5, 引用 - 0
数据加载中……

2010年2月9日

通过Telnet来发送邮件

有些时候我们通过写代码来发送邮件. 有些时候, 代码可以正常工作. 然而, 在更多的时候, 我们需要弄清楚为什么它不能正常工作.

 

排查问题的最简单的方式就是让计算机模拟那些人类懒得做的事情(即计算机自动完成的动作), 有时这种模拟的方式能够帮助我们做那些计算机自己做不了的事情.

 

基于这个原因, 我们有时需要手动地使用telnet session来与远程的邮件服务器通信.

 

下面是一个简单的手动的与邮件服务器连接的telnet session.

 

这里的大写和小写并不重要.

 

You do/type this Server responds with
Telnet to hostname on port 25 220 (then identifies itself - possibly with several lines of 220 + text)
HELO your_domain_name or whatever 250 (followed by human readable message)
MAIL FROM:you@hostname.com (ie, your email address) 250 is syntactically correct (or similar)
RCPT TO:them@someplace_else.com (email address you want to send to) 250 is syntactically correct
DATA Tells you to send data then CRLF period CRLF at end
You type your message then CRLF period CRLF (ie, type a period on a line by itself then hit ENTER) 250
QUIT Signoff message

 

译自:

Send Email via Telnet

http://www.rdpslides.com/webresources/FAQ00035.htm

posted @ 2010-02-09 17:12 学友 阅读(5) | 评论 (0)编辑

2010年2月8日

在查看network traffic的时候, TCP Chimney offload的影响

你有没有曾经遇到一个问题, 在这个问题里你试图去trouble shoot网络连接的问题, 但是在抓取网络包的工具中仅仅只看到三次握手? 如果你使用Netmon 2.x, Netmon 3.x, Wireshark, Ethereal 和其他大多数的网络抓包工具的时候, 这都会出现.

 

这是一个相对的常识, 当TCP Chimney offload开启的时候这样的情况会发生, 但是通过注册表或者netsh关掉之后并总是会解决问题. TCP Chimney offload 允许TCP/IP的处理被转移到可以硬件处理TCP/IP的网络适配器上. TCP Chimney Offload的使用导致了网络通讯被转移到了我们使用的大多数的抓包工具监听的TCP/IP栈的更底层.

 

对这类问题初始的排错步骤就是通过Netsh关掉TCP Chimney Offload, 步骤如下, 这样做的好处是不需要重启机器.

 

使用Netsh.exe工具来关闭TCP Chimney by using the Netsh.exe tool:

  1. Click Start, click Run, type cmd, and then click OK.
  2. At the command prompt, type Netsh int ip set chimney DISABLED and then press ENTER.

然而, 这并不能改变在抓包工具中的显示的数据, 你应当继续, 关闭所有Scalable Network Pack 的特性, 详见Knowledge Base article 948496.

 

手动关闭RSS, NetDMA and TCP Offload, 步骤如下:

  1. Click Start , click Run , type regedit , and then click OK .
  2. Locate the following registry subkey: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
  3. Right-click EnableTCPChimney , and then click Modify.
  4. In the Value data box, type 0, and then click OK.
  5. Right-click EnableRSS, and then click Modify.
  6. In the Value data box, type 0, and then click OK.
  7. Right-click EnableTCPA, and then click Modify.
  8. In the Value data box, type 0, and then click OK.
  9. Exit Registry Editor, and then restart the computer.

Disabling Chimney with netsh and changed the registry values above will allow you to see all the traffic in most cases but not always. You may also need to look at the features related to TCP Chimney offload available on the Network card. To access these options, choose the configure button on the general tab of the adapters properties. This will bring up a Window similar to what is displayed below. The Advanced tab is where the changes will be made.

 

image_c1ccbabf-472b-426f-b882-d0984d540298[1]

 

The configurable options available vary depending on how the vendor implements the driver for Windows. Many network cards have features including Receive Side Scaling, TCP Checksum Offload and TCP Large Send Offload. Disabling the offload features of the network card will allow you to view all of the traffic in many cases where disabling the scalable network pack features in the OS doesn’t work. You should refer to the vendor’s documentation for specific steps on how to disable these features.

 

As a last resort you may have to disable chimney from a hardware perspective. Refer to the vendor’s documentation for specific information on how to disable offload features. Possible ways to do this vary, and may include settings on the NIC, jumpers on the motherboard, and/or configuration in System BIOS.

 

 

The effect of TCP Chimney offload on viewing network traffic

http://blogs.technet.com/networking/archive/2008/11/14/the-effect-of-tcp-chimney-offload-on-viewing-network-traffic.aspx

posted @ 2010-02-08 23:35 学友 阅读(5) | 评论 (0)编辑

TCP Chimney

TCP Chimney Offload 概览

=========================

TCP Chimney Offload是一种在网络数据传输时, 能帮助从CPU上转移网络负载到网络适配器上的network技术. 在Windows Server 2008上, TCP Chimney Offload允许Windows网络子系统能转移对TCP/IP连接的处理到对TCP/IP offload处理有特殊支持的网络适配器上.

 

TCP Chimney Offload在所有版本的Windows Server 2008和Windows Vista上都可用. 如果网络适配器支持这个特性, 那么TCP/IPv4 和TCP/IPv6 的连接都可以被转移.

 

如何在Windows Server 2008上开启和关闭TCP Chimney Offload

========================

TCP Chimney Offload可以在下列两个地方开启或关闭

  • 操作系统
  • 网络适配器的高级属性页面

TCP Chimney Offload仅在上面两个地方全都开启的时候才会工作. 默认情况下TCP Chimney Offload在这两个地方都是被关掉的. 然而OEM版的安装有可能会开启这两个地方的选项.

 

如何在操作系统中配置TCP Chimney Offload

  • To enable TCP Chimney Offload, follow these steps:
    1. Use administrative credentials to open a command prompt.
    2. At the command prompt, type the following command, and then press ENTER:

      netsh int tcp set global chimney=enabled

  • To disable TCP Chimney Offload, follow these steps:
    1. Use administrative credentials to open a command prompt.
    2. At the command prompt, type the following command, and then press ENTER:

      netsh int tcp set global chimney=disabled

  • To determine the current status of TCP Chimney Offload, follow these steps:
    1. Use administrative credentials to open a command prompt.
    2. At the command prompt, type the following command, and then press ENTER:

      netsh int tcp show global

如何在网络适配器中配置TCP Chimney Offload

  • To enable or disable TCP Chimney Offload, follow these steps:
    1. Open Device Manager.
    2. Under Network Adapters, double-click the network adapter that you want.
    3. On the Advanced tab, click Enabled or Disabled in the box next to the TCP offload entry.
      Note Different manufacturers may use different terms to describe TCP Chimney Offload on the Advanced properties page of the network adapter.

下表列出了TCP Chimney与其他程序或network service的能否共存

Program or service

Works together with TCP Chimney Offload

Expected behavior when both the service and TCP Chimney Offload are enabled

Windows Firewall

Yes

If the firewall is configured to allow for a given TCP connection, the TCP/IP stack will offload that TCP connection to the network adapter.

Third-party firewall

Implementation-specific

Some firewall vendors have decided to implement their product in such a way that TCP Chimney Offload can be used while the firewall service is running. Refer to the firewall documentation to find out whether the product you are using supports TCP Chimney Offload.

Internet Protocol security (IPsec) policy

No

If the system has an IPsec policy applied, the TCP/IP stack will not try to offload any TCP connections. This lets the IPsec layer inspect every packet to provide the desired security.

Network Adapter teaming service (This service is also known as the Load Balancing and Failover service. It is usually provided by an OEM.)

Implementation-specific

Some OEMs have decided to implement their network adapter teaming solutions so that they coexist with TCP Chimney Offload. See the network adapter teaming service documentation to determine whether you can use TCP Chimney offload together with this service.

Windows Virtualization (Hyper-V technology)

No

If you are using the Microsoft Hyper-V technology to run virtual machines, no operating system will take advantage of TCP Chimney offload.

Network monitoring tools, such as Network Monitor and Wireshark

Implementation-specific

Some network monitoring tools may coexist with TCP Chimney but may not monitor offloaded connections.

Network Load Balancing (NLB) service

No

If you configure the NLB service on a server, the TCP/IP stack does not offload TCP connections.

Cluster service

Yes

However, note that TCP connections using the Network Fault Tolerant driver (NetFT.sys) will not be offloaded. NetFT is used for fault-tolerant inter-node cluster communication.

Network Address Translation (NAT) service (also known as the Internet Connection Sharing service)

No

If this service is installed and running, the TCP/IP stack does not offload connections.

 

如何确定TCP Chimney Offload是否在工作

=================================

When TCP Chimney Offload is enabled in the operating system and in the network adapter, the TCP/IP stack tries to offload suitable TCP connections to the network adapter. To find out which of the currently established TCP connections on the system are offloaded, follow these steps:

当TCP Chimney Offload 在操作系统和网络适配器中开启的时候, TCP/IP栈会试图把合适的TCP连接转移到网络适配器上. 为了确定哪个当前建立了的TCP连接被转移了, 遵循下面的步骤:

1. 用管理员的权限打开一个命令行窗口.

2. 输入下面的命令, 然后按Enter

     netstat –t

 

你会收到像下面的结果

*********************************************

Active Connections

  Proto  Local Address          Foreign Address        State           Offload State

  TCP    127.0.0.1:52613        computer_name:52614       ESTABLISHED     InHost
  TCP    192.168.1.103:52614        computer_name:52613       ESTABLISHED     Offloaded

*********************************************

这里第二个连接被转移了.

 

摘译自:

Information about the TCP Chimney Offload, Receive Side Scaling, and Network Direct Memory Access features in Windows Server 2008

http://support.microsoft.com/kb/951037

posted @ 2010-02-08 23:18 学友 阅读(4) | 评论 (0)编辑

PowerShell Cheat Sheet 1.0

  2-8-2010 10-40-12 PM

 

 2-8-2010 10-43-57 PM

原版XPS格式:Cheat Sheet V1.00.xps

 

资料来源:

http://blogs.msdn.com/powershell/archive/2007/01/31/powershell-cheat-sheet-now-in-xps.aspx

posted @ 2010-02-08 22:43 学友 阅读(4) | 评论 (0)编辑

SynAttackProtect

注册表的位置:

HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters

 

Data type

Range

Default value

REG_DWORD

0 | 1

0

 

描述

============

指定TCP/IP的SYN Flooding攻击保护(SYN flooding accack protection)特性是否开启. SYN flooding attack protection在这个键值为1, 并且TcpMaxConnectResponseRetransmissions 键值至少是2的时候是开启的, 下详.

 

TCP的SYN flooding attack protection特性会检测到拒绝服务式攻击(denial-of-service attacks )的症状(也叫做SYN flooding), 然后通过减小服务器花费在它不认识的连接请求上面的时间来响应这种情况.

 

Value

Meaning

0

SYN flooding attack protection is not enabled.

1

SYN flooding attack protection is enabled.

 

注意

=============

  • 这个值仅在SYN-ACK retransmissions 看起来似乎要损害服务器的时候才被使用, 也就是说, 当TcpMaxConnectResponseRetransmissions 键值至少是2的时候.
  • Windows Server 2003 并没有把这个项添加到注册表中. 你可以通过regedit.exe来手动添加.

译自:

SynAttackProtect

http://technet.microsoft.com/en-us/library/cc781167(WS.10).aspx

posted @ 2010-02-08 22:26 学友 阅读(2) | 评论 (0)编辑

SharePoint 2007中的三类Cache

你可以使用Microsoft Office SharePoint Server 2007 (MOSS 2007) 的缓存选项来优化你的站点的性能. MOSS 2007使用ASP.NET 2.0的缓存选项, 还有我们称为由Office产品组为MOSS特别设计的缓存.

 

缓存话题描述了在MOSS2007中可以使用的缓存技术, 还有如何配置, 合适配置缓存选项来最大化性能和减小延迟. 你可以

  • 在页面等级自定义缓存, 方式是使用output cache.
  • 对Web Parts, navigation actions, 和site map的展现进行自定义缓存, 方式是使用Object cache
  • 控制你的站点是否使用基于磁盘的缓存(disk-based cache)来减小延迟和提高图片, 声音文件, 和自定义的代码(比如cascading style sheets, 和JavaScript)的渲染时间.

下面的表格描述了在MOSS 2007中可用的缓存类型, 以及它们都做些什么.

 

Use this type of caching…

At the…

Notes

Output Caching and Cache Profiles

单独的页面的水平

包括使用

VaryByCustomString的扩展缓存.

Object Caching

单独的web part控件, field control, 和内容的水平

包括跨列表查询的缓存还有导航的缓存

Disk-based Caching for Binary Large Objects

单独的二进制大文件(BLOB), 还有缓存图片, 声音, 视频, 代码 的水平

支持GIF, JPG, JS, CSS, 还有其他图片, 声音, 代码文件等以二进制存储的对象.

 

通过创建cache-aware的控件, 为你的站点用适合的方式扩展缓存, 创建永远使用object cache的navigation providers, 创建使用Content By Query缓存的内容查询, 和为你的master page 和page layouts创建服务器控件来最小化数据库存取, 你可以剧烈地提高你的MOSS部署的性能.

 

开发者应该注意, MOSS为navigation节点和潜在的代价高昂的读取数据操作提供了专用的缓存, 比如说通过使用SPQuery对象进行标准WSS查询和使用SPSiteDataQuery对象进行跨站点查询.

 

注意: 尽管MOSS 2007不让你像在标准ASP.NET的页面中那样使用output cache的指令, 它毕竟提供给了你更加健壮的框架来保存ASP.NET标准页面中的缓存同样的结果.

 

译自:

Custom Caching Overview

http://msdn.microsoft.com/en-us/library/aa589700.aspx

posted @ 2010-02-08 22:12 学友 阅读(4) | 评论 (0)编辑

AD RMS与SharePoint 2007的集成的一些要点

1. 在Windows Server 2003中需要安装RMS Client, 而Windows Server 2008中已经包含了RMS client, 不需要安装.

 

2. 尽管用户可以将IRM-protected的文档上传到SharePoint中, 但是保护能力是内嵌在文档之内的, 不是在存储媒体中. 所以, 如果你与SharePoint集成使用IRM-Protected的文档, 在SharePoint服务器中将会有一些功能受损失. 因为受保护的文档不能被做标记(tagged), 也不能被制作索引. 因为文档的内容是被加密过的, 所以对于SharePoint的服务来说, 内容是不可访问的. 这种情况在AD RMS与SharePoint Server 2007的集成中不会出现, 因为Office SharePoint Server 2007 中的Office Protector component 允许在用户从SharePoint下载文档时, 自动地对文档应用针对用户的IRM policy.

 

3. 在MOSS中, IRM保护对于存储在文档库中的文档和作为列表项的附件存储的文件都是可用的. 当一个用户试图从文档库下载文件时, MOSS先检查这个用户是否对文档有权限, 然后颁布一个允许使用某种权限访问文件的use license. MOSS然后传给用户一个加了密的, 权限管理了的文件格式.

 

4. 开启了IRM的SharePoint 文档库, 可以包括如下的保护选项

  • 用户是否可以打印文档
  • 用户是否可以运行VBA或者其他文档中的自定义代码.
  • licence合法的天数. licence经过指定的天数之后, 会过期, 用户必须重新从文档库中下载文件.
  • 是否允许用户上传不支持IRM的格式.
  • 可选择的, 停止限制权限的日期, 日期到了之后, MOSS会从文档库中移出RMS.

5. 如下类型的文件可以收到sharepoint默认的保护.

  • Microsoft Office InfoPath 2007 表单
  • 97-2003 文档格式 Microsoft Word, Microsoft Excel, 和Microsoft PowerPoint
  • Office Open XML 格式 Microsoft Office Word 2007, Microsoft Office Excel 2007, 和Microsoft Office PowerPoint 2007
  • XML Paper Specification (XPS) 格式

6. 当IRM在文档库中被开启, 那么权限管理会被应用到文档库中的所有文件上. 当IRM在列表中开启, 那么所有列表项的附件会被rms保护起来, 而列表项本身不会被保护.

 

7. MOSS使用文档库的access control list(ACL)来确定用户下载文件时应用到文档上的权限. 也就是说, 如果一个用户有权限访问文档库, 当MOSS把文件传给用户的时候, 它将这个用户对文档库中所有文件的访问权限附着到这个文档中.

 

8. MOSS与AD RMS保护集成的典型流.

  1. 内容作者post了一个office文档到开启了AD RMS的sharepoint文档库.
  2. MOSS把文档保存到SharePoint数据库中, 没有加密, 没有保护, 这样才能确保这个文档可以被索引和搜索到.
  3. 另一个拥有权限访问文档库的用户(文档消费者)从SharePoint服务器请求文档.
  4. 服务器从数据库中取回文件.
  5. 服务器根据文档库赋予用户的权限, 将权限附着在文档上.
  6. 受保护的文档被发送给用户. 用户使用Office应用程序在AD RMS客户端的帮助下打开文档. Office 应用程序强制执行由policy定义的权限.

9. 注意:

If the user used IRM or another means to encrypt the document before uploading it to the database, the encryption is not removed when the document is stored in the database. Consequently, the document cannot be searched or indexed while in the database. Unless there is a need for additional protection beyond what is provided by Office SharePoint Server with AD RMS protection, documents should not be IRM protected or otherwise encrypted before being uploaded to the SharePoint document library or list.

 

10. 把SharePoint服务器加到AD RMS的certification pipeline的步骤

ee259515.5304e8d0-b795-4578-82b9-fb4911126fc8(en-us,WS.10)

  1. Log on to the AD RMS server (ADRMS-SRV) as a local administrator.

  2. Click Start, and then click Computer.

  3. Navigate to C:\Inetpub\wwwroot\_wmcs\Certification.

  4. Right-click ServerCertification.asmx, click Properties, and then click the Security tab.

  5. Click Advanced, click Edit, select the Include inheritable permissions from this object's parent check box, and then click OK two times.

  6. Click Edit, and then click Add.

  7. Click Object Types, select the Computers check box, and then click OK.

  8. Type the name of the SharePoint server (CPANDL\SPS-SRV$), and then click OK twice.

  9. Click Add, type the name of the AD RMS server service group (ADRMS-SRV\AD RMS Service Group), and then click OK twice.

  10. Click OK to close the ServerCertification.asmx Properties sheet. By default the Read & Execute and the Read permissions are configured for the computer account object and all other accounts inherited from the parent folder.

  11. Click Start, right-click Command Prompt, click Run as administrator, and then click Continue. Type iisreset, and then press ENTER.

11. 分析MOSS与AD RMS集成中问题的一般步骤.

  1. 使用任意一个域账号登录一台域中安装了RMS client的机器, 仅用Office客户端程序来对文档加密. 看是否能够成功.
  2. 使用MOSS管理中心站点IIS app pool账号登录一台域中安装了RMS client的机器, 仅用Office客户端程序来对文档加密. 看是否能够成功.
  3. 检查MOSS管理中心站点IIS app pool账号是否具有邮件地址.
  4. 检查RMS的trust domain配置, 看是否有添加"仅信任某个域的邮件地址"
  5. 检查RMS的C:\Inetpub\wwwroot\_wmcs\Certification文件的属性, 看是否添加了MOSS机器和AD RMS Service Group.
  6. IISRESET
  7. 抓Network Monitor包, 分析服务器之间的通信. 如果是使用的HTTPS, 那么要分析通信就需要RMS trace了.

参考资料:

Event Review: RMS in Windows Server 2008 (Session ITPROADD-401)

http://technet.microsoft.com/en-us/bb899740.aspx 

AD RMS Client Requirements

http://technet.microsoft.com/en-us/library/dd772753%28WS.10%29.aspx

AD RMS Step-by-Step Guide

http://technet.microsoft.com/en-us/library/cc753531%28WS.10%29.aspx

Deploying Windows Rights Management Services with Microsoft Office SharePoint Server 2007 Step-By-Step Guide

http://www.microsoft.com/downloads/details.aspx?FamilyID=7bab2321-71e6-4cf2-8bcd-0880e0d1cda3&DisplayLang=en  

Deploying Active Directory Rights Management Services at Microsoft

http://technet.microsoft.com/en-us/library/ee156482.aspx

Integrating AD RMS and SharePoint Server 2007(经典实用)

http://technet.microsoft.com/en-us/library/ee259515%28WS.10%29.aspx

posted @ 2010-02-08 16:06 学友 阅读(4) | 评论 (0)编辑

2010年2月7日

ASP.NET的页面中对其他文件的引用

先来看看ASP风格的

===============

你可以把一个ASP页面的内容在服务器执行之前添加到另外一个ASP页面中, 方式是使用#include命令.

 

#include命令被用来创建函数, headers, footers, 或者将要被多个页面重用的部分.

 

如何使用?

这是"mypage.asp"

<html>
<body>
    <h3>
        Words of Wisdom:</h3>
    <p>
        <!--#include file="wisdom.inc"-->
    </p>
    <h3>
        The time is:</h3>
    <p>
        <!--#include file="time.inc"-->
    </p>
</body>
</html>

 

这是"wisdom.inc"文件

"One should never increase, beyond what is necessary,
the number of entities required to explain anything."

 

这是"time.inc"文件

<%
Response.Write(Time)
%>

 

如果你在浏览器里查看源代码, 你会看到这样:

<html>
    <body>
        <h3>
            Words of Wisdom:</h3>
        <p>
            "One should never increase, beyond what is necessary, the number of entities required
            to explain anything."</p>
        <h3>
            The time is:</h3>
        <p>
            11:33:42 AM</p>
    </body>
</html>

 

语法

<!--#include virtual="somefilename"-->
这里的virtual表明地址是起自一个虚拟路径. 比如说, 一个名叫header.inc的文件存在于一个叫做/html的虚拟目录下, 那么下面的一段命令会插入header.inc的内容

<!-- #include virtual ="/html/header.inc" -->


<!--#include file ="somefilename"-->

这里的file表明路径是一个相对路径. 如果有一个文件在html文件夹下, 并且header.inc文件存在于html\headers中, 那么下面的代码会插入header.inc文件的内容

<!-- #include file ="headers\header.inc" -->

 

 

在ASP.NET页面中动态包括HTML文件和客户段脚本文件

===========================

因为ASP.NET应用程序在发送给客户端之前要经过编译, 运行的, 所以在服务器端include文件的时候, 你不能使用变量来替代文件名(比如说:<!-- #include PathType = FileName –>" ). 然而, 你可以使用Response或者StreamReader对象来向HTML流中写入被include的文件.

 

举例:

   <%@ Page Language="vb" AutoEventWireup="false"%>
   <html>
   <body>
        <%           
          Response.WriteFile ("Yourfile.inc")
        %>
   </body>
   </html>

 

 

在ASP.NET页面中插入指定文件的内容, 包括Web pages(.aspx文件), user control files(.ascs文件), 还有Global.asax文件

============================

语法, 与ASP风格的include 相同.

<!-- #include file|virtual="filename" -->

 

Remarks

赋予File或者Virtual属性的值必须被双引号括起来(""). 被included的文件会在任何动态代码执行前被处理. Include文件能被用来包含从静态文本(比如说普通的页面header或者公司地址), 到包含土工的服务器端代码(server-side code), 控件(control), 或者开发者想要插入到其他页面中的HTML标签块.

 

尽管你也可以使用这个#include 的方式来重用代码, 在ASP.NET中通常的更好的方式是使用Web user controls. 因为user control提供了面向对象的编程模型, 而且比服务器端的include功能更加强大.

 

#include标签必须被HTML或XML的注释边界符括起来, 来避免它被解释成为字面上的文本.

 

举例:

<html>
   <body>
      <!-- #Include virtual="/include/header.inc" -->
        Here is the main body of the .aspx file.
      <!-- #Include virtual="/include/footer.inc" -->
   </body>
</html>

 

参考资料:

How To Dynamically Include Files in ASP.NET

http://support.microsoft.com/kb/306575

Server-Side Include Directive Syntax

http://msdn.microsoft.com/en-us/library/3207d0e3.aspx

ASP Including Files

http://www.w3schools.com/asp/asp_incfiles.asp

posted @ 2010-02-07 22:51 学友 阅读(7) | 评论 (0)编辑

如何创建强命名程序集, 如何查看强命名程序集的PublicKeyToken

如何创建强命名程序集

===================

1. 在Visual Studio中的class library工程上点右键, 选择properties.

2.  选择左边的Signing选项卡.

3. 勾选Sign the assembly复选框. 在下拉列表中选择<New...>.

2-7-2010 9-09-21 PM

4. 在弹出的对话框中给snk文件起一个名字. 按OK.

2-7-2010 9-10-23 PM

5. 程序集强命名完成.

2-7-2010 9-12-32 PM

 

如何查看强命名程序集的public key token

=========================

有时候你需要在web.config文件中或者其他地方引用自己写的强命名程序集, 你需要写入像下面这样的fully qualified name:

MyNamespace.MyAssembly, version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

 

前面三个部分比较容易获得, 因为是你自己写的, 你当然知道assembly的名字, 版本, 还有culture信息. 比较麻烦的部分是如何获得自己签名的程序集的public key token. 一种平常的方法是使用Reflector来打开自己的程序集, 然后获得token(实际上, Reflector会给你如同上面例子那样的完整信息). 但是这有的时候还是显得有点未免杀鸡用牛刀了. 如果你已经打开了Visual Studio, 那么仅仅是在VS的菜单里点一个菜单项就能获得答案不是更好么? 下面就是步骤.

 

1. 在Visual Studio中, 打开Tools菜单, 然后点击External Tools这个菜单项.

2. 在弹出的External Tools对话框中, 点击Add按钮.

3. 按照下图进行配置. sn.exe这个工具在不同版本的VS下处于不同的文件夹中. 最简单的找到它的方式是在VS Command Prompt中输入"where sn.exe". 在参数框里写入"-T $(TargetPath)". 然后勾选"Use Output Window". 这样的话, 结果就会在VS的output window. 然后点击OK,

2-7-2010 9-27-57 PM

4. 结果如图.

2-7-2010 9-33-28 PM

5. 在输出窗口可以看到结果. 这在你的solution里有多个project的时候也是可以正常工作的. 只需要点击一下Solution Explorer中的Project, 然后点击我们的菜单项就可以了.

2-7-2010 9-35-31 PM

 

资料来源:

http://blogs.msdn.com/miah/archive/2008/02/19/visual-studio-tip-get-public-key-token-for-a-stong-named-assembly.aspx

posted @ 2010-02-07 21:36 学友 阅读(5) | 评论 (0)编辑

SharePoint中的EventReceiver 之四 为Content Type编写Event Handler

在前面的部分, 我们创建了CompanyItemEventReceiver类来在Company names中使用大写来保持数据完整性. 作为这个Event Receiver的系列的最后部分, 我们现在希望展现一下如何把event receiver类中的event handler绑定到Company这个Content Types上. 这是通过在content type的definition中使用一个inner XmlDocument节点, 下面进行了举例. 你可以看到, 每一个event handler都必须被单独地使用相同地信息来绑定.

 

<ContentType ID="0x0100E71A2716C18B4e96A9B0461156806FFA" Name="Company" >
  <!-- FieldRefs element omitted for clarity -->
  <!-- event handlers added to content type using XmlDocument element -->
  <XmlDocuments>
    <XmlDocument NamespaceURI="http://schemas.microsoft.com/sharepoint/events">
      <spe:Receivers xmlns:spe="http://schemas.microsoft.com/sharepoint/events">
        <spe:Receiver>
          <spe:Name>ItemAddedReceiver</spe:Name>
          <spe:Type>ItemAdded</spe:Type>
          <spe:Assembly>LitwareTypes, [full 4-part assembly name] </spe:Assembly>
          <spe:Class>LitwareTypes.CompanyItemEventReceiver</spe:Class>
        </spe:Receiver>
        <spe:Receiver>
          <spe:Name>ItemUpdatedReceiver</spe:Name>
          <spe:Type>ItemUpdated</spe:Type>
          <spe:Assembly>LitwareTypes, [full 4-part assembly name] </spe:Assembly>
          <spe:Class>LitwareTypes.CompanyItemEventReceiver</spe:Class>
        </spe:Receiver>
      </spe:Receivers>
    </XmlDocument>
  </XmlDocuments>
</ContentType>

 

译自:

Inside Microsoft Windows SharePoint Services 3.0

posted @ 2010-02-07 13:52 学友 阅读(6) | 评论 (0)编辑

技术追求准确,态度积极向上