随笔 - 78, 文章 - 0, 评论 - 16, 引用 - 6
数据加载中……

.NET技术-.NET开发日记-.NET开发笔记


Visual Studio 

(1)重装Team Edition for Database Pros Add-on for Team Suite时, 要卸载下面的两个后再重装才能确保工程模版好用:
Microsoft Visual Stuido ProjectAggregator2
Microsoft Visual Studio 2005 Team Edition for Database Professionals - Trial - ENU

(2)用VS2005创建Infopath项目时候提示下面的错误:
英文的:
Package Load Failure.
Package 'ReportDesignerPackage' has failed to load properly (GUID={11B8C903-8FFD-4DFC-87CE-F6A82D77AF6B}).
Package 'DataWarehouse VSIntegration layer' has failed to load properly.
Package 'Microsoft Data Transformation Services Designer' has failed to load properly.

中文的:
包加载失败
未能正确加载包"ReportDesignerPackage"(GUID={11B8C903-8FFD-4DFC-87CE-F6A82D77AF6B})。请与包供应商联系以获得帮助。由于可能会发生环境损坏,建议重新启动应用程序。要禁止将来加载此包吗?可以使用"devenv/resetskippkgs"重新启用包加载。

原因可能是在VS2005中的Business Intelligence Projects模版丢失导致。
卸载并重装SQL Server 2005即可解决。

 

C# 
(1)C#:

using System;
using System.Collections.Generic;
using System.Text;

namespace ClassLibrary1
{
    
public class Class1
    {
        
void fun()
        {
            
//一维数组的定义
            int[] a1;
            a1 
= new int[10];
            
//二维且每行元素个数相同的数组
            int[,] a2 = new int[23];
            
//二维且每行元素个数不相同的数组
            int[][] a3 = new int[2][];
            a3[
0= new int[5];
            a3[
1= new int[2];
        }
    }
}


(2)
改.aspx文件时记住改.cs文件的类名和命名空间的名字,此时相应的.aspx文件中<%@ Page~~%>中的Inherits的值会相应改变,同时要改变此文件中Codebehind的值。<%@ Page Codebehind="Country.aspx.cs" %>是告诉asp.net引擎这个页面有个某某后置代码需要动态编译。
改Global.asax文件的命名空间名<%@ Page language="c#" Codebehind="MoveInConfirm.aspx.cs" AutoEventWireup="false" Inherits="Olympic.MaterialManage.Category1.MoveInConfirm" %><%@ Page language="c#" Codebehind="MoveInConfirm.aspx.cs" AutoEventWireup="false" Inherits="Olympic.MaterialManage.Category1.MoveInConfirm" %><%@ Page language="c#" Codebehind="MoveInConfirm.aspx.cs" AutoEventWireup="false" Inherits="Olympic.MaterialManage.Category1.MoveInConfirm" %><%@ Page language="c#" Codebehind="MoveInConfirm.aspx.cs" AutoEventWireup="false" Inherits="Olympic.MaterialManage.Category1.MoveInConfirm" %><%@ Page language="c#" Codebehind="MoveInConfirm.aspx.cs" AutoEventWireup="false" Inherits="Olympic.MaterialManage.Category1.MoveInConfirm" %>。
改web应用程序所在的目录名时,要右键Project名-Properties:General中的Assembly Name,Default Namespace,Web Settings中的Path值,其中Default Namespace对于VB.NET来说是根名字空间,对于C#是default namespace即如果没有命名空间就用默认的,有则就用已有的。
删掉.sln文件,打开.webinfo文件,将URLPath值改成.csproj文件的本地URL路径,打开.csproj文件-右键Solution选Rebuild生成.sln文件。
如有“CS1595: 已在多处定义~~”的错误,一般是因重命名了虚拟目录的名称和文件夹而造成的,则有2种方法:1.改掉所有命名空间名称2.删掉“C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files”目录下的此工程对应的文件(此时应进入任务管理器结束aspnet_wp.exe进程,才可以删掉此文件)再Rebuild再执行,如果还有错误就再删掉C:\Inetpub\wwwroot\OBFM\下的bin文件夹再Rebuild再执行,如果还有错误就再删掉c:\documents and settings\(username)\vswebcache

(3)aa/bb.xml路径是相对于上个页面的网站Virtual路径。
/aa/bb.xml是相对于webserver根的virtual path。
C:\Inetpub\wwwroot\aa\bb.xml是物理路径。

(4)服务器根目录要用“~/”

(5)将某个目录设成Virtual Directory时,其下面应该有.csproj等文件,不能在此目录下的子目录里。

(6)将某个目录设成Virtual Directory时,如用VS2003而又装了Framework2.0时,在Interent Information Services管理工具里右键其选properties-将其中的ASP.NET项下的Vertion值选对(VS2003选1.1.4322)。

(7)任何不在工程内的文件如图片文件,都可以通过拖动其到VS2003中来实现加入到工程里。

(8)对于VS2003中的.aspx文件中的表格等,不要在VS2003中拖动改变其大小,否则控制其大小的Width等属性会以style="width:30px"这种形式,如此时再在Dreamweaver中设置其值则造成重复,则页面不是你想要的。
当在VS2003中保存某个页面时,最好在Dreamweaver中使其页面处于激活状态,可避免使其在Dreamweaver中变成修改状态。

(9)将剪贴板上的字粘贴到.aspx文件里时,最好右键用Paste as HTML粘贴,这样得到的字是纯的前后不带样式标签的。

(10)在VS2003中的Solution Explorer视窗中点击“Show All Files”按钮会把后面的文件显示出来,再点一下又不显示。
(11)if(!IsPostBack)的IsPostBack的意义是“是否是第二次请求”。
(12)<%=Request.QueryString["~"] %>
Response.Write(Request.QueryString.Get("~"));
(13)在一个Project里使用另一个Project里的类时,要在References里通过Add Reference对话框里的Project栏里加此Project的bin\Debug里的.dll文件。

(14)Pet Shop4.0的安装只要象装软件一样装完就不用再按照它的Read me文件里说的手动安装了。选择完全安装时,会帮你自动建出4个数据库。
(15)C#编码规范:私有成员前加m,类和函数的注释用///,函数内部注释用//。
(16)如在写代码时候无智能提示则是因为在References里没有引入此组件即.dll的引用。

(17)当website项目没有.sln文件时候,可在VS2005里选file-open-web site之后选此项目的总文件夹就可以打开了。之后可以在file下拉菜单中保存一个.sln文件。

(18)启动用户实例的进程时出错

问题:
使用ASP.NET 2.0 + SQL2005 + aspnetdb(MemberShip等功能)时出现这个问题:
“由于启动用户实例的进程时出错,导致无法生成 SQL Server 的用户实例。该连接将关闭。”
英文是:“Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed.”

问题原因:
这是微软的bug,并且微软已经承认,详情如下:http://support.microsoft.com/?id=896613
出现此错误的条件是:你用过远程桌面连接,并且安装了SQL2005+VS2005,就有很大可能触发这个问题,微软说会在将来的XP SP3里面解决掉这个问题。

解决:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=128707&SiteID=1
如果你看不懂英文,那么我告诉你我的解决办法:
删除C:\Documents and Settings\[USERNAME]\Local Settings\Application Data\Microsoft\Microsoft SQL Server Data\SQLEXPRESS目录即可,[USERNAME]是Windows用户名,比如说Administrator

(19)从客户端调用Web Method时发生[Method Error 12031]或[Method Error 500]异常:
若要从客户端调用某个服务器端Web Service中的Web Method,则该Web Service必须拥有Microsoft.Web.Script.Services.ScriptServiceAttribute属性:

//如果你装的是ASP.NET AJAX(Atlas)Beta 1则加下面的属性
[Microsoft.Web.Script.Services.ScriptService()]
//如果你装的是ASP.NET AJAX(Atlas)v1.0则加下面的属性
[System.Web.Script.Services.ScriptService]
public class MyService : System.Web.Services.WebService
{
 
// 
}

若要从客户端调用某个定义与页面中的Page Method,则该Page Method必须用Microsoft.Web.Script.Services.ScriptMethodAttribute属性修饰(当然,System.Web.Services.WebMethod也是必不可少的),且必须为静态(static)方法。目前版本的一个Bug还导致我们必须在ASPX文件中定义这个Web Method,在CS文件中定义是没有作用的(真是无奈):

//如果你装的是ASP.NET AJAX(Atlas)Beta 1则代码只能写成下面的混合模式
<script runat="server">
    [System.Web.Services.WebMethod]
    
//如果你装的是ASP.NET AJAX(Atlas)Beta 1则加下面的属性
    [Microsoft.Web.Script.Services.ScriptMethod]
    
//如果你装的是ASP.NET AJAX(Atlas)v1.0则加下面的属性
    [System.Web.Script.Services.ScriptMethod]
    
public static string GetHtml(string contextKey)
    {
      
// 
    }
</script>

//如果你装的是ASP.NET AJAX(Atlas)v1.0则代码可以分离着写
[WebMethod]
[System.Web.Script.Services.ScriptMethod]
public static CascadingDropDownNameValue[] GetArea(string knownCategoryValues, string category)
{
  
//
}

 

(20)关于String的解释:
1.给字符串变量赋值时是新建一个字符串对象,而不是修改此字符串变量原来指向的字符串对象。
2.DotNet 有字符串驻留机制:CLR内部有一张哈希表用来保存应用程序域的所有字符串;如果新创建一个字符串,如果在hash表中找到和这个字符串相同的值,那么返回相同的地址,如果不相同那么在hash表中新增一条记录。
3.不能修改字符串对象实例的值,而 StringBuilder 则是在原对象实例基础上的修改。
4.rel可以把参数的数值传递进函数,但是out是要把参数清空,就是说你无法把一个数值从out传递进去的,out进去后,参数的数值为空,所以你必须初始化一次。这个就是两个的区别,或者说就像有的网友说的,rel是有进有出,out是只出不进。
也有的人说:
ref是传入值,out是传出值。
ref侧重修改,out侧重输出。
ref是传递参数的地址。

(20)C#中out与ref的用法与区别
1、out必须在函数体内初始化,在外面初始化没意义。也就是说,out型的参数在函数体内不能得到外面传进来的初始值。
2、ref必段在函数体外初始化。
3、两都在函数体的任何修改都将影响到外面。
例:

using System;
namespace ConsoleApplication1
{
 
class C
 {
  
public static void reffun(ref string str)
  {
   str 
+= " fun";
  }
  
public static void outfun(out string str)
  {
   str 
= "test";     //必须在函数体内初始
   str += " fun";
  }
 }
 
class Class1
 {
  [STAThread]
  
static void Main(string[] args)
  {
   
string test1 = "test";
   
string test2;             //没有初始
   C.reffun( ref test1 );    //正确
   C.reffun( ref test2 );    //错误,没有赋值使用了test2
   C.outfun( out test1 );    //正确,但值test传进去
   C.outfun( out test2 );    //正确
   Console.Read();
  }
 }
}

在传值和传址情况下,C#强制要求参数在传入之前由用户明确初始化,否则编译器报错!但我们如果有一个并不依赖于参数初值的函数,我们只是需要函数返回时得到它的值是该怎么办呢?往往在我们的函数返回值不至一个时我们特别需要这种技巧。答案是用out修饰的输出参数。但需要记住输出参数与通常的函数返回值有一定的区别:函数返回值往往存在堆栈里,在返回时弹出;而输出参数需要用户预先制定存储位置,也就是用户需要提前声明变量--当然也可以初始化。
在函数体内所有输出参数必须被赋值,否则编译器报错!out修饰符同样应该应用在函数声明和调用两个地方,除了充当返回值这一特殊的功能外,out修饰符ref修饰符有很相似的地方:传址。

(21)数组参数的例子:

using System;
class Test
{
    
static int Sum(params int[] args)
    {
        
int s = 0;
        
foreach (int n in args)
        {
            s 
+= n;
        }
        
return s;
    }
    
static void Main()
    {
        
int[] var = new int[] { 12345 };
        Console.WriteLine(
"The Sum:" + Sum(var));
        Console.WriteLine(
"The Sum:" + Sum(1020304050));
    }
}


(22)GradView等控件的OnObjectCreated事件在第一次调用odsOrg3_ObjectCreated(object sender, ObjectDataSourceEventArgs e)函数时是创建表头。
(23)要想取得控件里面的控件的ID号如GradView里的模板列的,应该这样取:GradView$TemplateField。
(24)asp的控件的html端的ID如在Javascript里用其ID,可以这样得到<%=其服务器端ID.ClientID %>

(25).aspx中:<iframe id="content" runat="server" frameborder="0" style="width: 100%; height: 100%;"></iframe>
.cs中可以这样使用:((System.Web.UI.HtmlControls.HtmlGenericControl)content).Attributes["src"] = "aaa";
(26)在C#中switch的比对参数也可以是字符串:
        switch (Request.QueryString["tem"])
        {
            case "ab":
                addr = "aa.aspx";
                break;
        }
(27)这个<style type="text/css"></style>要放在<head runat="server"></head>中否则看不了设计视图。
(28)Javascript里也可以用else if(),如
if(1)
{}
else if(0)
{}

(30)

using System;
using System.Collections.Generic;
using System.Text;

namespace OBFM.BusinessRules
{
    [System.ComponentModel.DataObject]
    
public partial class BumpInBO
    {
        [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, 
false)]
        
public DataSetBumpIn.BumpInDocumentDataTable GetDocByDocId(string docId)
        {
            
return BumpInDocAdapter.GetDocByDocId(docId);
        }
    }
}

上面的类和方法加的属性可以使在页面中配置ObjectDataSource数据源时既选Configure Data Source-Choose a Business Object里看到此类,在Define Data Methods中可以看到此方法。
(31)强类型的Dataset指系统建立的带外键关系等结构,很象数据库中的表结构的Dataset,而我们自己new的Dataset只加了colume等而没有结构关系的是非强类型的。
(32)如果Dataset视图中有多个表,那么此Dataset结构是有的只是是没有数据的空结构,通过下面的方法可以使一个Dataset中的某些表充满数据:

        DataSetSystem dsRole = new DataSetSystem();

        OBFM.DataEntities.DataSetSystemTableAdapters.PathTableAdapter pathTableAdapter 
= new OBFM.DataEntities.DataSetSystemTableAdapters.PathTableAdapter();
        pathTableAdapter.Fill(dsRole.Path);

        OBFM.DataEntities.DataSetSystemTableAdapters.RolePathTableAdapter rolePathTableAdapter 
= new OBFM.DataEntities.DataSetSystemTableAdapters.RolePathTableAdapter();
        rolePathTableAdapter.FillByRoleId(dsRole.RolePath, Int32.Parse(gvRole.SelectedValue.ToString()));

上面的Dataset“dsRole”中就有了两个充满值的表。

(33)如果想给Dataset.xsd中的某个适配器类增加方法,可以右键.xsd选择View Code之后下面出现.cs文件,可以在此文件里扩展~TableAdapter类的方法。

(34)如果用<asp:ObjectDataSource/>作为数据源,查询语句的参数来自于<asp:ObjectDataSource/>监视的<asp:TextBox/>,那么当文本框为空时,虽然this.TextBoxID.Text的值为"",但SQL语句要用@~ is null对应。
如果用:
DepartmentTableAdapter departmentAdapter = new DepartmentTableAdapter();
Department.DepartmentDataTable aa = departmentAdapter.GetDataByPara("dscpn", this.txtSearchKey.Text);
this.gvOrg.DataSource = aa;
做数据源,那么传给SQL语句的值为"",所以要在SQL语句中用@~ = ''对应。

(35)在.aspx文件的
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
前面最好加上<script type="text/javascript"></script>,可使设计时见到的页面和浏览时看到的一样。

(36)http://jsjlcl.bokee.com/viewdiary.13765974.html Cookie的基本知识

(37)作安装程序时可设置的地方:
1.左键点击Setup工程-在属性窗中:
Author:JasonLi
Localization:Chinese(Simplified)
Manufacturer:
ProductName:将显示在安装对话框中
RemovePreviousVersions:True
Title:
2.右键点击Setup工程-View-File System-点击编辑窗中的Web Application Folder-在属性窗中:
VirtualDirectory:
3.右键点击Setup工程-View-User Interface-点击编辑窗中的Welcome-在属性窗中将WelcomeText改为“制作:~-~-安装程序将引导您完成在您的计算机上安装<[ProductName]>所需的步骤。”
如果是用WebSetup做个只有合并模块的安装程序则可以删掉编辑窗中的“Installation Address”
4.右键Setup工程-Properties-可在Output file name中修改生成后的.msi文件的名称如改为SetupEXT.msi
可点击Prerequisites在对话框中选预安装的东西,VS2005会将你选的东西做到你的安装程序里,在安装的时候会预先从你的安装程序里安装这些组件。记住如果改属性时候要改完debug模式后也要把release模式下的属性改成一样的。
5.右键Setup工程或右键File System里的东西都会有Add选项来添加东西。

(38)ASP.NET Error: Failed to access IIS metabase错误的解决办法
错误提示:
 

Server Error in '/PSP' Application.

Failed to access IIS metabase.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.Hosting.HostingEnvironmentException: Failed to access IIS metabase.

The process account used to run ASP.NET must have read access to the IIS metabase (e.g. IIS://servername/W3SVC). For information on modifying metabase permissions, please see http://support.microsoft.com/?kbid=267904.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[HostingEnvironmentException: Failed to access IIS metabase.]
            System.Web.Configuration.MetabaseServerConfig.MapPathCaching(String siteID, VirtualPath path) +3500410
            System.Web.Configuration.MetabaseServerConfig.System.Web.Configuration.IConfigMapPath.MapPath(String siteID, VirtualPath vpath) +9
            System.Web.Hosting.HostingEnvironment.MapPathActual(VirtualPath virtualPath, Boolean permitNull) +163
            System.Web.CachedPathData.GetConfigPathData(String configPath) +382
            System.Web.CachedPathData.GetConfigPathData(String configPath) +243
            System.Web.CachedPathData.GetApplicationPathData() +68
            System.Web.CachedPathData.GetVirtualPathData(VirtualPath virtualPath, Boolean permitPathsOutsideApp) +3393731
            System.Web.Configuration.RuntimeConfig.GetLKGRuntimeConfig(VirtualPath path) +189
            


Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210

解决方法:
1.在run里运行cmd命令进入DOS命令行-cd \-cd C:\windows\microsoft.net\framework\v2.0.50727或在Microsoft Visul Studio 2005-Visul Studio Tool里调出Visual Studio 2005 Command Prompt后直接输入命令而不用退到C:\windows\microsoft.net\framework\v2.0.50727这个目录。
2.然后执行命令 aspnet_regiis -ga <账户名>
3.aspnet_regiis -i -enable
4.net stop iisadmin
5.net start w3svc

对了说一下,aspnet_regiis.exe这个程序是在c:\windows\microsoft.net\framework\v2.0.50727目录下的,如果你的不是windows xp sp2,那么请您搜寻该程序,只要执行相同的命令即可。

(39)“VSTS 启动web测试记录器无效”问题的解决
现象:
用VS2005做性能测试时,发现添加新的web测试,启用记录web动作,发现web记录器的按钮都是灰显的,只是web浏览器左面提示要从vs内部打开web记录器。
原因:
在微软的论坛中发现这个可能是个Bug,相关帖子http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=572411&SiteId=1 
解决:
办法1:安装Visual Studio 2005 Service Pack 1 (SP1)即VS80sp1-KB926601-X86-ENU下载地址http://msdn2.microsoft.com/en-us/vstudio/bb265237.aspx 安装完后要重启才能起作用
办法2:使用工具Fiddler录制脚本,可以录制后保存为后缀为.webtest的文件,然后导入项目中。下载地址http://www.fiddlertool.com/fiddler/ 
办法3:可以通过重新注册插件恢复,但这种方法可能不起作用,打开记事本输入内容如下:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT
\CLSID\{8C84B9F5-3D9E-4204-BB0B-F85D46455868}]
@
="Web Test Recorder"
"MenuText"="Web Test Recorder"
"HelpText"="Record Web Tests."

[HKEY_CLASSES_ROOT
\CLSID\{8C84B9F5-3D9E-4204-BB0B-F85D46455868}\Implemented Categories]

[HKEY_CLASSES_ROOT
\CLSID\{8C84B9F5-3D9E-4204-BB0B-F85D46455868}\Implemented Categories\{00021493-0000-0000-C000-000000000046}]

[HKEY_CLASSES_ROOT
\CLSID\{8C84B9F5-3D9E-4204-BB0B-F85D46455868}\Implemented Categories\{62C8FE65-4EBB-45e7-B440-6E39B2CDBF29}]

[HKEY_CLASSES_ROOT
\CLSID\{8C84B9F5-3D9E-4204-BB0B-F85D46455868}\InprocServer32]
@
="mscoree.dll"
"ThreadingModel"="Both"
"Class"="Microsoft.VisualStudio.TestTools.WebTest.RecorderBarControl"
"Assembly"="Microsoft.VisualStudio.QualityTools.RecorderBar, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"

[HKEY_CLASSES_ROOT
\CLSID\{8C84B9F5-3D9E-4204-BB0B-F85D46455868}\InprocServer32\8.0.0.0]
"Class"="Microsoft.VisualStudio.TestTools.WebTest.RecorderBarControl"
"Assembly"="Microsoft.VisualStudio.QualityTools.RecorderBar, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"

[HKEY_LOCAL_MACHINE
\SOFTWARE\Microsoft\Internet Explorer\Explorer Bars\{8C84B9F5-3D9E-4204-BB0B-F85D46455868}]
"BarSize"=hex:06,01,00,00,00,00,00,00

然后保存为.reg文件,并双击植入注册表

部分原文内容http://www.cnblogs.com/oscarxie/archive/2007/01/11/618150.html 

(40)
现象:

The specified display mode is currently disabled on this page. Make sure personalization is enabled for the current user.
Parameter name: value 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.ArgumentException: The specified display mode is currently disabled on this page. Make sure personalization is enabled for the current user.
Parameter name: value

原因:
除Browse模式外其他模式都需要认证才能使用。
WebPart与Membership是有联系的,在DesignMode下需要认证的用户才能访问,如果用户没有登陆,那么会出现上面的提示.而微软说没有认证的用户也可以使用DesignMode,但是一切的改变只会存储在ViewState中。
解决办法:
1.在切换模式时让用户先登陆
2.在登入的地方加上:
FormsAuthentication.RedirectFromLoginPage(userid, false);
并且修改web.config如下:
<authentication mode="Forms"/>
3.如果想让没有被认证的用户也可以使用其他模式,可以通过加上下面的代码实现:
C#

    protected void Page_Load(object sender, EventArgs e)
    {
        
if (!IsPostBack)
        {
            HttpCookie authCookie 
= Request.Cookies.Get(FormsAuthentication.FormsCookieName);
            
if (authCookie == null)
            {
                String MyCookieName 
= "Reminder";
                System.Web.HttpCookie MyCookie 
= Request.Cookies.Get(MyCookieName);
                String UserID;
                
if (MyCookie == null)
                {
                    UserID 
= System.Guid.NewGuid().ToString().Replace("-""");
                    MyCookie 
= new System.Web.HttpCookie(MyCookieName, UserID);
                    MyCookie.Expires 
= DateTime.Now.AddYears(10);
                    Response.Cookies.Add(MyCookie);
                }
                
else
                {
                    UserID 
= MyCookie.Value;
                }

                FormsAuthenticationTicket authTicket 
= new FormsAuthenticationTicket(1, UserID, DateTime.Now, DateTime.Now.AddSeconds(30), false"roles");
                String encryptedTicket 
= FormsAuthentication.Encrypt(authTicket);
                authCookie 
= new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
                Response.Cookies.Add(authCookie);
                Response.Redirect(Request.Url.ToString());
            }

            System.DateTime LastDate 
= System.DateTime.Now.AddYears(-1);

            System.Data.SqlClient.SqlConnection cnn 
= new System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings["LocalSqlServer"].ConnectionString);
            System.Data.SqlClient.SqlCommand cmd;

            cmd 
= new System.Data.SqlClient.SqlCommand("DELETE FROM" + " aspnet_PersonalizationPerUser where UserID IN " + "(SELECT UserID from aspnet_Users where " + "[LastActivityDate] < @Date)", cnn);
            cmd.Parameters.Add(
"@Date", SqlDbType.DateTime);
            cmd.Parameters[
"@Date"].Value = LastDate;
            
try
            {
                cnn.Open();
                cmd.ExecuteNonQuery();
            }
            
catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
            
finally
            {
                cnn.Close();
            }

            cmd 
= new System.Data.SqlClient.SqlCommand("DELETE FROM" + " aspnet_Users where [LastActivityDate] < @Date", cnn);
            cmd.Parameters.Add(
"@Date", SqlDbType.DateTime);
            cmd.Parameters[
"@Date"].Value = LastDate;
            
try
            {
                cnn.Open();
                cmd.ExecuteNonQuery();
            }
            
catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
            
finally
            {
                cnn.Close();
                cmd.Dispose();
                cnn.Dispose();
            }
        }
    }

VB.NET代码:
http://www.codeproject.com/aspnet/anonywebparts.asp 

(41)

网页中调用qq和msn

调用qq的方法:
<A href="tencent://message/?uin=20989163&amp;Site=博客园&amp;Menu=yes"
target=blank><IMG alt=点击这里给我发消息 src="http://wpa.qq.com/pa?p=1:20989163:11"
border=0></A>

调用msn的方法:
<A href="msnim:chat?contact=xxqq0824@hotmail.com" target=blank>点这里和我MSN聊天</A>

放在页面上就能出效果了!
还要补充一点,如果你想要自定义的话,可以访问:
http://is.qq.com/cgi-bin/webpresence/wpa_code;在这里可以设置你的qq的图片,以及一些附加功能。


QQ:

<a target=blank href=tencent://message/?uin=QQ号&Site=网站名称&Menu=yes><img border="0" SRC=http://wpa.qq.com/pa?p=1:QQ号:7 alt="点击这里给我发消息">

MSN:

<A href="msnim:chat?contact=lyjier@hotmail.com" target=blank>点这里和我MSN聊天</A>


网页调用MSN功能
在新添加的功能中,还包括可通过网页中的链接添加联系人、开始交谈、开始视频交谈和开始语音交谈。链接的构造如下:
  开始交谈:msnim:chat?contact=contact@hotmail.com
  添加联系人:msnim:add?contact=contact@hotmail.com
  启动一个语音聊天:msnim:voice?contact=contact@hotmail.com
  启动一个视频聊天:msnim:video?contact=contact@hotmail.com


建立对话:msnim:chat?contact=[MSN ID]

添加好友:msnim:add?contact=[MSN ID]

语音聊天:msnim:voice?contact=[MSN ID]

视频聊天:msnim:video?contact=[MSN ID]

只要把以上的代码作为链接放入<a href="">中的引号里面,就可以了。。。。


网页调用msn对话框
<Script language=javascript>
function SendMSNMessage(name)
{
//MyStatus == 1 本地MSN未登录
//MyStatus == 2 本地MSN已登录
 if(MsgrObj.MyStatus == 1){
  alert("Please login your MSN Messenger!");
 }else{
  MsgrObj.InstantMessage(name);
 }
}
function AddMSNContact(name)
{
 MsgrObj.AddContact(0, name);
}
</script>
<object id="MsgrObj" classid="clsid:B69003B3-C55E-4B48-836C-BC5946FC3B28" codetype="application/x-oleobject" width="0" height="0"></object>
<a href="javascript:SendMSNMessage('name@hotmail.com')">msn_test</a>

(42)怎样使用#if test #endif:
先在“Configuration Manager”里New一个"Conditional compilation symbols", 之后在Project Properties里的Build项里的"Conditional compilation symbols"内输入刚刚新建的那个符号,之后在代码中的#if test #endif中使用这个符号就可以实现条件编译了。

 (43)如果website不能通过vs打开可以尝试下面的方法:
1.如果是vs2003项目则要在IIS上创建此站点
2.确信ContentGroupManagement.sln文件能的路径是IIS上此站点的的虚拟路径(不用修改ContentGroupManagement.vbproj.webinfo文件的信
息,因为.sln文件会更新.webinfo文件)
3.在vs里右键此项目选择reload
4.如果还不能打开,则单独打开此project,不要通过.sln,如果成功后再reload
5.如果Browse此站点时,报下面的错误:
Server Error in '/ContentGroupManagement' Application.
--------------------------------------------------------------------------------

Server cannot access application directory 'C:\Documents and Settings\jason_li\Desktop\MS@WorkoldWeb\MSAtWork\ContentGroupManagement\'. The directory does not exist or is not accessible because of security settings.

则可能是你把代码放到了桌面上。
6.如果在代码中使用System.Net.WebClient.OpenRead(webserviceUrl)打开webservice抛出异常可以到IIS上,右键站点选“Properties”-“Document”中添加CGManagement.asmx并将其设置成默认主页,右键选“Browse”核实是否能浏览成功。
7.如果报“没权限访问”的错误,可右键站点选“Properties”-“Directory Security”-勾选“Enable anonymous access”。

(44)Copy Local 属性:确定是否将引用复制到本地 bin 路径。在运行时,引用必须位于全局程序集缓存 (GAC) 或项目的输出路径中。如果将该属性设置为 true,则在运行时将把引用复制到项目的输出路径。

部署/复制包含对自定义组件(该组件在 GAC 中注册)的引用的应用程序时,无论 Copy Local 的设置如何,组件都不会与应用程序一起部署/复制。

http://msdn.microsoft.com/zh-cn/library/t1zz5y8c.aspx 

(45)
安装VS6.0时可能遇到下面的问题:
问题一:
scrrun.dll was unable to register itself in the system registry.
DiffMrg.ocx was unable to register itself in the system registry.
pdm.dll was unable to register itself in the system registry.

解决办法:
方法一:
将安装盘上VID98\BIN\下的DIFFMRG.OCX拷贝到c:\winnt\system32下,运行:regsvr32 c:\winnt\system32\DIFFMRG.OCX

方法二:
如果方法一不能注册成功。使用ProcessMonitor软件查看在注册这些dll时那些注册表是access denied。将不能访问的赋给当前用户管理员权限。

方法三:
如果还不能注册成功,直接给HKEY_CLASSES_ROOT赋予管理员权限。就能安装成功了。

问题二:
setup was unable to create a DCOM user account in order to register 'E:\Program Files\Microsoft Visual Studio\Common\Tools\VS-Ent98\Vanalyzr\VALEC.EXE'
解决办法:
微软承认的一个bug。安装时不安装Enterprise Tools-Options-Visual Studio Analyzer就可以解决这个问题了。
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257413 

(46)

当安装vs2005时如果不能设置安装路径,其原因是需卸载vs的一些辅助组件,如Team Explorer等。其中Microsoft Visual Studio 2005 premier partner Edition是由于装Microsoft Visual Studio 2005 Team Explorer后出现的。

(47)

调试项目时如果遇到下面的错误:
Could not write lines to file "obj\Components.csproj.FileListAbsolute.txt". Access to the path 'E:\InfoPath2007\Microsoft.ContractManagement\Components\obj\Components.csproj.FileListAbsolute.txt' is denied.

解释:
FileListAbsolute表示“文件绝对路径列表”,包括.dll、.exe以及.pdb文件等。
If you look in this file you should find the string of Illegal characters that match the error. Anyway, make a copy of this file as a backup (just in case). Then delete the original version and rebuild your project. This file apparently gets recreated if it does not exist and will correct itself, at least it did for me. You should get a clean build now.

(48)\r\n与\n的区别

 

\r 是回车,return
\n 是换行,newline

我们在平时使用电脑时,已经习惯了回车和换行一次搞定,敲一个回车键,即是回车,又是换行,但在早期的打字机上,要另起一行打字需要两个步骤,首先要发送命令"\r”将打字头复位,即回车,然后再发送命令"\n”让打字机走纸移到下一行,所以这个历史遗留问题导致了如今我们在DOS-Windows的系统里需要区分"\r\n”和“\n”,但在Unix中只有"\n”。

用UltraEdit打开文本查看,会看到换行处显示的是0x0D0A,0x0D即"\r”,0x0A即"\n”。

有时候在文本文件中出现■这样的符号,是因为没有"\r\n"连用,导致不能正确回车换行。

在C中读取文本时,"\r\n”已自动转成"\n”。


\r 就是return 回到本行行首.
\n 换到下一行.
\r\n与\n用起来应该都没有区别,有些编辑器它不认\n,如果要通用的则是\r\n.

 

VB 

1)

function是函数,sub是子程序,都可以传递参数,但函数有返回值,子程序没有

sub过程是子过程,是在响应事件时执行的代码块。本身没有类型和返回值。

function是函数过程,有返回值,同时有数据类型,即返回值的类型

2)VB 6.0升级到VS2005时,因下面的错误提示而不能自动转换。

<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
When attempting to upgrade a VB6 project to VB2005 on a 32bit machine, the
following error is displayed as the wizard is initializing:

   Unexpected exception occurred during upgrade engine operation: Not able to bind
to the source (Exception from HRESULT: 0x8004000A (OLE_E_CANT_BINDTOSOURCE)

Cause:
The Regmon log shows we are looking for VBExpress on a 64bit machine:

vbu.exe:2344 OpenKey HKLM\SOFTWARE\Wow6432Node\Microsoft\VBExpress\8.0 NOT FOUND
vbu.exe:2344 OpenKey HKLM\SOFTWARE\Wow6432Node\Microsoft\VBExpress\8.0\VBUpgrade\Sou
rce Language Drivers NOT FOUND

The following key had been erroneously added to the registry during the
installation:

      HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node

and contained one entry for SQL Server. This key should only be present on a 64bit
machine. If this key exists on a 32bit machine, VBU.exe wrongly searches the node
for the components and fails even though the correct entries exist elsewhere in the registry.

<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
*** Resolution *** Apr  7 2006  1:12PM robdil

Export and delete the HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node key.

<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>

I don't have the Wow6432Node key.  And the problem is still there.

After a bit more research / hacking (using the great Regmon log) I've found that my problem was fixed after adding these missing keys;

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\VBUpgrade]
"HelpLink"="ms-help://MS.VSCC.v80/MS.MSDNQTR.80.en/commoner/redir/redirect.htm?keyword="

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\VBUpgrade\Source Language Drivers]

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\VBUpgrade\Source Language Drivers\Visual Basic]
@="Visual Basic 6.0"
"FileLocation"="VBSLD"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\VBUpgrade\Target Language Drivers]

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\VBUpgrade\Target Language Drivers\VB7]
@="Visual Basic 7"
"FileLocation"="vb7tld"

I noticed that the keys were correctly in the "VBExpress" location so I just exported them at the "VBUpgrade" point and then edited the .reg file by replacing the "VBExpress" with "VisualStudio".

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VBExpress\8.0\VBUpgrade]
"HelpLink"="ms-help://MS.VSCC.v80/MS.MSDNQTR.80.en/commoner/redir/redirect.htm?keyword="

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VBExpress\8.0\VBUpgrade\Source Language Drivers]

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VBExpress\8.0\VBUpgrade\Source Language Drivers\Visual Basic]
@="Visual Basic 6.0"
"FileLocation"="VBSLD"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VBExpress\8.0\VBUpgrade\Target Language Drivers]

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VBExpress\8.0\VBUpgrade\Target Language Drivers\VB7]
@="Visual Basic 7"
"FileLocation"="vb7tld"


Win Form开发 
(1)某些动作发生前的事件可以用e.Cancel=true;取消此事件例如:Validating事件。如果执行控件A时不想触发另外一个控件B的Validating事件,可以设置控件A的属性CausesValidation为False。

JavaScript 

http://www.weiw.com/tech/javadict/ref_a-c.htm Javascript各个函数的使用示例


(1)如果不知道页面中某个控件的下面有什么属性可以用,可以给Javascript代码加断点并调试起来,然后右键此对象选择QuickWatch,之后可以象调试.cs文件里的代码一样使用。
(2)在.cs中加脚本的方法:
当给某个控件加脚本时可以用ddlID.Attributes.Add("onChange", "javascript:ControlItemEnable1();");
当给页面中加脚本时候可以用:
Page.ClientScript.RegisterStartupScript(~)  脚本块出现在Form结束符前,一般用于初始化Form页面,加载时启动。也可以注册Javascript文件。
Page.ClientScript.RegisterClientScriptBlock(~)  脚本块出现在Form开始符之后,一般用于注册与Form初始属性无关的脚本块。
参数key相同的脚本块只有第一个会出现在客户端页面上。在.cs文件中注册前用Page.ClientScript.IsClientScriptBlockRegistered(~)检查一下是否注册过。

 

if (!Page.ClientScript.IsClientScriptBlockRegistered("myKey"))
{
    
string sct = @"var viewer = document.getElementById('myID');
                              alert();
"
    Page.ClientScript.RegisterStartupScript(
this.GetType(), "myKey", sct, true);
}



AJAX 

(1)
掌握 Ajax 系列:
http://www.ibm.com/developerworks/cn/web/wa-ajaxintro/


(1)"An extender can't be in a different UpdatePanel than the control it extends." error really needs debugging information"错误。

出这里错误的ajax 控件一般为有target属性的,指定到一个updatePanel里面的控件里。

一个简单的解决方法可以把ajax 控件也放进updatepanel里。但不是对所有的有效的

That is a difference of the new release over previous...  The error however is explicit - any controls that have target properties to point to something that the Update Panel triggers on can only be placed within the update panel....  HOWEVER... there is an override by programtically overriding it using the "ChldrenAsTriggers" property...http://ajax.asp.net/docs/mref/0b850465-67ca-2600-9fdc-2c16d689ab89.aspx

(2)Asp.net Ajax的PopupControl控件的CommitProperty属性是指:目标控件的客户端属性,这个属性是它的值在弹出窗口选择完值后要更新的属性,比如可以是TextBox客户端属性value(注:不是Text属性),即是<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>生成HTML标签<input type="text" name="textfield" value="aa">后的属性value。
最关键的地方是弹出控件选择值后,值被Ajax PopupControlExtender管理,PopupControl控件然后把值传给客户端TextBox的value属性。

(3)当用户快速点击按钮或其他会导致postback的动作时(即每次request还没有来得及接受到response就又再点击其他按钮)会发生下面的错误:
Invalid postback or callback argument. Event validation is enabled using in configuration or in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.

原因如下:
这是由于在net2.0里增加了一项页面验证:enableEventValidation此属性默认值是TRUE。
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="AEBnx7v.........tS" />
在我们的页面PostBack的时候,asp.net会根据存储在这个隐藏控件中的Value来校验你点击的BUTTON被委托的事件是不是有效的,当它发现postback的资料不是原始的控制项发出来的就会产生上述异常,如果网页上有一些特殊的写法会去修改postback资料也会出现这个错误。
通常产生这个错误都是由于在该隐藏控件还没有被render出来之前执行了postback。

解决办法如下:
1.禁用事件校验,不过这个会产生安全问题, 在页面里用<%@ Page EnableEventValidation="false"%>,也可在web.config里<pages enableEventValidation="false"/>
2.呼叫ClientScriptManager.RegisterForEventValidation

(4)AJAX的<asp:UpdatePanel></asp:UpdatePanel>所囊括的部分区域被PostBack时其内的控件都会被恢复成初始状态,所以此前如果
<asp:TextBox ID="aa" runat="server">在Javascript里被设置成了不可编辑当PostBack时就会变成可编辑,所以应该设成
<asp:TextBox ID="aa" runat="server" Enabled="false">

(5)AJAX发送请求后的监视readystate的函数和原来的宿主页面内的函数是两个不同的线程。onreadystatechange的承接函数和监视readystate的函数在同一个线程,有执行的先后顺序的。

oXMLHttpRequest.open(bstrMethod, bstrUrl, varAsync);
当varAsync为true时为异步请求,宿主页面发送AJAX请求同时也会为AJAX再开一个线程用于处理此请求、监视readystate的状态等操作,此时宿主页面不会等此线程结束(请求返回)而是继续执行宿主页面的代码。
当varAsync为false时为同步请求,宿主页面发送AJAX请求同时也会为AJAX再开一个线程用于处理此请求、监视readystate的状态等操作,此时宿主页面只有等此线程结束(请求返回)才会执行宿主页面以下的代码。

document.writeln(sText);函数会覆盖掉当前页面内的所有代码,最后页面上内容只是其参数的内容,但不会覆盖掉提取到内存的代码。

document.writeln(sText);输出的内容会自动加入换行。document.write(sText);不加换行。

页面标签如“</head>”如果想作为js的字符串则要分开写如var str1 = "</"; var str2 = "head>";不能写成var str = "</head>";因为此时会当成页面标签了。也可以前加转义字符“\”。

(6)
1.如果浏览页面时提示下面的错误:

Configuration Error 
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. 

Parser Error Message: Could not load file or assembly 'System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

Source Error: 


Line 51:         
<compilation debug="true">
Line 52:             
<assemblies>
Line 53:                 
<add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
Line 54:                 
<add assembly="System.Web.Extensions.Design, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
Line 55:                 
<add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
 

Source File: E:\M\PerforceRoot\Olympic\OBFM\Web\web.config    Line: 53 

 

2.或者拖crystalreportviewer控件到页面提示:memory 写保护时,
3.或者一些系统提供的类找不到,
以上的异常的原因可能是没装ASP.NET 2.0 AJAX Extensions 1.0

也可以通过把System.Web.Extensions.Design.dll和System.Web.Extensions.dll放到web工程的Bin目录里来解决(当部署到产品环境时用此法)

(7)

当页面继承了master page,并使用了AJAX控件,如果出下面的错误:
找不到AjaxControlToolkit_AjaxTk\Release\AjaxControlToolkit\ExtenderBase\ScriptObjectBuilder.cs为debug,之后页面显示下面的错误:The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)

当使用了AjaxControlToolKit时候会引起这个错误。
You need to move the script block out of the head tag. The problem is due to the runat="server" clause in the head tag and is related to ASP.NET 2.0 not allowing this syntax.

I remove runat="server" from head tag and it work.

When the MaskedEditExtender/CalendarExtender is used, a <LINK ...> tag to a stylesheet will result in this error. One workaround is to move the CSS file to a theme folder and add a reference to the theme in the web.config file <pages theme="themeName">. Each page needs to have the "<head>" tag replaced with "<head runat="server"> and any "<LINK ...>" tags removed.



Crystal Report 
(1)用向导给水晶报表CrystalReportViewer加ReportSource时(Propertyies-DataBindings-ReportSource)如选Custom binding expression则其值的格式为:@"C:\Program Files\Microsoft Visual Studio .NET 2003\Crystal Reports\Samples\Reports\General Business\World Sales Report.rpt",即:一要为绝对路径,二要加双引号,三为了表示此“\”不是表示转义字符的作用前面要加@。

(2)Crystal report 出现

The maximum report processing jobs limit configured by your system administrator has been reached.


Exception Details: System.Runtime.InteropServices.COMException: The maximum report processing jobs limit configured by your system administrator has been reached.

错误的解决办法:
WEB下的水晶报表在正常运行一段时间后会出现以上错误,后来发现,水晶报表会在注册表中注册,并限制了打印数量为75,在“开始-Run”中运行regedit命令后在注册表编辑器里更改以下注册表内容:

HKEY_LOCAL_MACHINE\SOFTWARE\Crystal Decisions\10.2\Report Application Server\InProcServer\PrintJobLimit

HKEY_LOCAL_MACHINE\Software\Business Objects\Suite 11.0\Report Application Server\InProcServer\PrintJobLimit

将PrintJobLimit由75改为0,然后重启动计算机后,故障排除。
也可以通过关掉电脑右下脚的“ASP.NET Development Server”再浏览页面的方法解决这个异常。


上面的异常出现在ReportDocument.Load();之后,如果ReportDocument.Load();被写成
        try
        {
            ReportDocument.Load();
        }
        catch ()
        {
        }
则提示下面的错误:

Invalid report file path.
Exception Details: CrystalDecisions.CrystalReports.Engine.LoadSaveReportException: Invalid report file path.


(3)水晶某些数据为汉字时打印出现“方框乱码”的解决办法:乱码一般是字体问题,在报表文件里右键出现乱码的字段-Format Object-Font将Font文本框改成宋体。
(4)在设计Reporting Services报表时如果左面没有数据库字段浏览窗口,可以通过“View-Datasets”掉出来。
(5)“System.Runtime.InteropServices.COMException: Invalid pointer”这个水晶报表的异常的原因可能是在“Database-Database Expert”里对水晶报表建立的连接数据库的连接已经没了。

(6)如果水晶报表预览时显示不出来数据,可以右键Database Fields-Database Expert-Links去掉其中多余的Link。

(7)如果在Database Expert中想通过Project Data设置报表的数据源,但Dataset.xsd文件又不在Web Site工程里即在Project Data中看不到想用的Dataset.xsd,可以先将报表建立在和那个Dataset.xsd在同一个工程下就可以用了并且可以设计报表了,然后在将此报表拷贝到相应工程里。

如果在Database Expert中用Dataset作为设计报表时的数据源时,Dataset视图中的表的字段可以自己构造既增加你想要的字段,也可以自己增加外键关系。

如果在Database Expert中多个表中有些表没有link关联,可以在Database Expert中的links里通过用鼠标拖一个表的字段到另一个表的字段上来给它们关联,也可以在.cs中的Dataset中构造所需的多个主表,然后写下面的代码:
ReportDocument docObj = new ReportDocument();
docObj.SetDataSource(dataset);

(8)如果想在Database Expert给水晶报表增加个表但建立的连接没有了即看不到那些表了,则可以在History里找到你以前的连接重新建立,之后加你想加的数据库表到水晶报表文件。

(9)对CrystalReportViewer控件的属性设置如下:
EnableDatabaseLogonPrompt="False" 页面不提示输入登陆数据库信息的对话框,此时可以在程序中设置登陆信息。
HasToggleGroupTreeButton="False" 不出现“显示/隐藏树”的按钮。
DisplayGroupTree="False" 默认左边的树是不显示的,点按钮才显示。
DisplayGroupTree="False" 不显示左边的树状结构。
HasCrystalLogo="False" 不显示水晶报表logo。
PrintMode="ActiveX" 设置点击打印按钮时出现的提示形式。

(10)当水晶报表重复多次显示一条记录时,有两种解决办法:
   A.先在Database Expert中只导入一张表不要一次把所需的报表都导入,之后设计报表,显示正确后,再一次性的导入其他所需的数据库表,如果在程序中用ReportDocument给报表赋数据源则只需要用Dataset取出第一个表的字段(不用追溯其他关联表的字段,Crystal Report会根据主表即第一个导入的表并通过自己的link得到其他关联表的所需字段),但要保证Database Expert中link存在。因为如果一次性的导入所有所需表会让Crystal Report不知道哪个是主表。

   B.在Database Expert中一次把所需的报表都导入,并删掉所有的link,在代码中用Dataset在数据库中取出所有导入表中的所需字段,把Dataset给ReportDocument,再用ReportDocument给报表赋数据源。

(11)如果既想用ReportDocument给报表赋数据源,又在Database Expert中一次把所需的报表都导入,可能浏览页面时会报下面的错误:
“Cannot determine the queries necessary to get data for this report. Failed to open a rowset. Error in File C:\DOCUME~1\jqli\LOCALS~1\Temp\NOCMR{30B5E15A-2756-44D8-AEA7-0A4723A9CBA7}.rpt: Failed to open a rowset.”

两种解决办法:
1.是重新设计报表且分两次打开Database Expert第一次只导入一张表作为主表,第二次导入其他所需的表。
2.除了主表外都删掉,再打开Database Expert导入其他表。

(12)如果水晶报表显示不出数据或显示的记录数目比用SQL命令查水晶报表主表得到的记录少,可能原因是因为水晶报表内不只一个表而是有很多关联表但从主表向下追溯时可能传了null造成此条由多表组成的一行记录查不出来则少了此个记录。

(13)如何调节水晶报表.rpt文件的最大宽度:
1.右键报表空白处-Design-Printer Setup,在Paper栏里设置Size
2.点击.rpt文件上某个节,选择Section Expert-Details-勾选Format with Multiple Columns-标签页会多出一个标签为“Layout”-点击“Layout”标签后在里面就可以设置报表的宽度了。

Reporting Service 
(1)电脑A放置代码-有report view,电脑B安装有数据库和report server,如果在A上安装过TFS再卸载后并且删掉了A上IIS上的report server应用程序池后,可能造成报表显示不出来,页面提示:
为用户“HSLCN\CSSERVER$”授予的权限不足,无法执行此操作。 (rsAccessDenied)

解决办法:
打开B电脑上的IIS的ReportServer应用程序的Properties-Directory Security-Edit-勾选Enable anonymous access,将默认帐号IUSR_HCSSERVER改为域帐户,如输入B电脑的域帐户,注意域帐户一定要加上域名如“hslcn\hcsserv”,可通过Browse的Check Names来检查输入的帐户的正确性。


SQL 

SQL Server 2005 联机丛书
http://msdn.microsoft.com/zh-cn/library/ms189826(SQL.90).aspx
SQL教程:
http://www.ibook8.com/book/sql.htm
如何一个数据库服务器的存储过程中远程更新另一个数据库服务器的表的内容:
http://www.80diy.com/home/20060118/17/4524068.html#

(1)两种连接字符串的写法:
“Driver={SQL Server};Server=LIJIANQIANG\SQLSERVER2;DataBase=OBFM;user id=HSLCN\jqli;password=ass;”
“workstation id=10.167.9.83;packet size=4096;integrated security=SSPI;data source=LIJIANQIANG\SQLSERVER2;persist security info=False;initial catalog=OBFM”


(2)在存储过程中加上exec pGetDepartmentByPara 'aaa', 'bbb'可测试存储过程pGetDepartmentByPara(@searchCategory nvarchar(20), @searchKey nvarchar(300)),其中后面两个是参数。
用光标亮选哪个语句,点执行后就执行被选择的语句。

(3)将一个表新增加的若干列用语句一次性插入进去:

insert into City(ID, State, Name) select ID, State, Name from Collector.dbo.City where ID not in (select ID from City)


(4)select distinct age from [Person],加distinct可以避免选出重复的值。

(6)
如何查看SQL Server的版本号:
方法一:
打开企业管理器-右键数据库引擎-选属性-在General标签里可以看到版本。
方法二:
select serverproperty('ProductLevel')查看SQL补丁
select serverproperty('ProductVersion')查看SQL版本号
select serverproperty('Edition')查看SQL是企业版还是开发版
Select @@Version查看版本号等信息

(7)char、varchar、nchar、nvarchar、text、ntext区别:

char      定长
varchar   变长,ASCII字符,只占1个字节
nvarchar  变长,Unicode字符,字符都占2个字节

char和varchar的长度都在1到8000之间,它们的区别在于char是定长字符数据,而varchar是变长字符数据。所谓定长就是长度固定的,当输入的数据长度没有达到指定的长度时将自动以英文空格在其后面填充,使长度达到相应的长度;而变长字符数据则不会以空格填充。varchar变长字符数据类型与存储数据的实际长度是一致的。
例如char(100),无论储存了一个字节还是100个字节,它占用的空间都是100字节,而varchar(100)的字段,则如果储存一个字节就是一个字节大小,储存10个字节就是10个字节大小。

N表示national character varying,字符数据采用Unicode编码,可以解决多语言字符集之间的转换问题。它所有的字符都用两个字节表示,即英文字符也是用两个字节表示。

(7)SQL分页语句 

-----------------------------------------
--
据说效率最高,适用于SQL 2005
--
---------------------------------------
declare @topn int,@skipm int
set @topn=100
set @skipm=3000

select * from 
(
select ROW_NUMBER ( ) OVER (order by pn desc,sn ascas fno,* from (select top (@skipm+@topn* from serial order by pn desc,sn asc) a) a 
where fno>@skipm and fno<=@skipm+@topn order by fno

-----------------------------------------
--
效率高(利用ID大于多少和SELECT TOP分页)语句形式.前提是必需有一列是自动增长类型,且唯一性.即表中主键必须为标识列"[ID] int IDENTITY (1,1)",如果没有主键,可以用临时表.
--
---------------------------------------
SELECT TOP 10 * FROM TestTable WHERE (ID > (SELECT MAX(id) FROM (SELECT DISTINCT TOP 20 id FROM TestTable ORDER BY id) AS T)) ORDER BY ID 
SELECT TOP [每页记录数] * FROM TestTable WHERE (ID > (SELECT MAX(id) FROM (SELECT TOP [每页记录数*(当前页码-1)] id FROM 表 ORDER BY id) AS T)) ORDER BY ID 

-----------------------------------------
--
前提是必需有一列是自动增长类型,且唯一性.即表中主键必须为标识列"[ID] int IDENTITY (1,1)",如果没有主键,可以用临时表.
--
---------------------------------------
select top 10 * from [order details] where orderid > all(select top 10 orderid from [order details] order by orderid) order by orderid

-----------------------------------------
--
效率次之(利用Not In和SELECT TOP分页)语句形式.前提是必需有一列是自动增长类型,且唯一性.即表中主键必须为标识列"[ID] int IDENTITY (1,1)",如果没有主键,可以用临时表.
--
---------------------------------------
SELECT TOP 10 * FROM TestTable WHERE (ID NOT IN (SELECT TOP 20 id FROM TestTable ORDER BY id)) ORDER BY ID 
SELECT TOP [每页记录数] * FROM TestTable WHERE (ID NOT IN (SELECT TOP [每页记录数*(当前页码-1)] id FROM 表 ORDER BY id)) ORDER BY ID

-----------------------------------------
--
利用SQL未公开的游标存储过程实现分页.方法简单且效率高(也有人说“效率低,但是最为通用.建议优化的时候,加上主键和索引,查询效率会提高”)已知的问题就是要多返回一个空的记录集.解决的方法是在前台调用时,用 set recordset=recordset.nextrecordset的方法跳过第一个记录集.
--
---------------------------------------
If Exists (Select * From Dbo.Sysobjects Where Id = Object_Id(N'[Dbo].[P_Splitpage]'And Objectproperty(Id, N'isprocedure'= 1)
Drop Procedure [Dbo].[P_Splitpage]
Go

Create Procedure p_splitpage   
@Sql nvarchar(4000),    --要执行的sql语句
@CurrentPage int=2,     --要显示的页码
@PageSize int=10,       --每页的大小
@PageCount int=0 OUTPUT --总页数
As
Set Nocount On
Declare @P1 Int
--初始化分页游标
Exec Sp_Cursoropen @cursor=@P1 Output,@stmt=@Sql,@Scrollopt=1,@Ccopt=1,@Rowcount=@PageCount Output
--计算总页数
Select @PageCount=Ceiling(1.0*@Pagecount/@Pagesize),@Currentpage=(@Currentpage-1)*@Pagesize+1
Select @Currentpage
--显示指定页的数据
Exec Sp_Cursorfetch @P1,16,@Currentpage,@Pagesize 
--关闭分页游标
Exec Sp_Cursorclose @P1
set nocount off
Go

--调用示例
declare @temPageCount int
exec p_splitpage @sql='select id,name from sysobjects'@CurrentPage=2@PageCount=@temPageCount OUTPUT
SELECT   @temPageCount

-----------------------------------------
--
数据量小的时候可用ROW_NUMBER()实现分页功能.适用于SQL 2005
--
---------------------------------------
DECLARE @pagenum AS INT@pagesize AS INT
SET @pagenum = 2
SET @pagesize = 3

SELECT * FROM (SELECT ROW_NUMBER() OVER(ORDER BY newsid DESCAS rownum, newsid, topic, ntime, hits FROM news) AS D
WHERE rownum BETWEEN (@pagenum-1)*@pagesize+1 AND @pagenum*@pagesize
ORDER BY newsid DESC

-----------------------------------------
--
数据量小的时候还可以通过读取出数据然后再写到另一个表里并增加一个ListID字段的值作为序号,可以通过三种方法实现
--
---------------------------------------
--
1.用外部程序实现:用数据库应用程序,将记录从学生信息表StudInfo,考试成绩表ExamResult中一条一条读出来,再写回成绩排行表ScoreList中,写回的时候赋ListID字段的值.
  
--2.通过游标赋ListID字段的值.
declare @StudID   int 
declare @StudName nvarchar(10
declare @Score    int 
declare @ExamID   int 
declare @ListID   int 

set @ExamID = 8042 
set @ListID = 1 

declare pScoreList cursor for 
select ExamResult.StudID, StudInfo.StudName, ExamResult.Score from ExamResult inner join StudInfo on ExamResult.StudID = StudInfo.StudID where ExamID = 8042 order by Score desc 
open pScoreList 
fetch next from pScoreList into @StudID@StudName@Score 
insert into ScoreList values@ExamID@ListID@StudID@StudName@Score ) 
While @@FETCH_STATUS = 0 
Begin 
 
set @ListID = @ListID + 1 
 
fetch next from pScoreList into @StudID@StudName@Score 
 
insert into ScoreList values@ExamID@ListID@StudID@StudName@Score ) 
End 
close pScoreList 
DeAllocate pScoreList 
  
--3.通过临时表实现.可以在临时表中建立一个自增的主键,先将记录按顺序写到临时表中去,这时临时表的主键值就是这次考试的排名.也可以不通过自增主键来实现,通过在select into语句中加入identity( int, 1, 1 )字段来实现.
select ExamResult.ExamID, identityint11 ) as ListID, ExamResult.StudID, StudInfo.StudName, ExamResult.Score 
into #ScoreList_8042 
from ExamResult inner join StudInfo on ExamResult.StudID = StudInfo.StudID where ExamID = 8042 order by Score desc 

insert into ScoreList select * from #ScoreList_8042
drop table #ScoreList_8042

 

(8)安装SQL2005 Developer Edition时,客户端和服务器端都在“Server components,tools,Book Online,and samples”-~-Components to Install-Advanced里,服务器的安装程序:Database services,客户端的安装程序:Client Components-Management Tools。
如果装Reporting Services2005(被装在SQL2005上,用于存储做好的报表),记住装Client Components-Business Intelligence Development Studio(用于在VS2005上建立Reporting Services2005的工程,它总是被装到C盘上,所以C盘空间要满足要求)。同时也最好装上Analysis Services和Integration Services,但也可以不装。
一台电脑上不能同时装Reporting Services2000和Reporting Services2005。
如果要装Reporting Services2000,请先装SQL Server?2000 Service Pack 3a (English) ,如果你跳过SQL Server?2000 Service Pack 3a (English) 的安装,则在安装Reporting Services2000的最后要求你装Service Pack 3a 而且要重启电脑一下才可以安装了,多了一次重启电脑。
如果要想有Reporting Services2000的中文联机丛书,则必须安装“文档和示例-联机丛书-英语”。
如果要卸载Reporting Services2000则可以用安装盘卸载。
如果安装了两个SQL Server则记住第二个Server要启动后才能用。
SQL2000和SQL2005的卸载都不能通过光盘卸载,必须在“添加/删除”里卸载。
如果只安装SQL2000的客户端则安装路径不能选择,卸载时可以通过光盘卸载。


(9)改Server被别人登陆时候使用的验证方式:右键点server名-“Edit SQL Server Registeration Properties”。
改某个用户的属性如登陆方式:到数据库引擎中的Security文件夹中-Logins-双击右面视窗中的某个用户则出现修改页面。

(10)转移另一个数据库的方法:先备份-右键此数据库-All Tasks-Back Up Database-设置保存的路径Destination后点OK;再新建一个数据库-右键此数据库-All Tasks-Restore Database-General里选From device之后选源表-Options里选Eject taps~~和Force restore over~~,之后Original File Name保持默认,Restore As处设置新生成的数据库数据的目的路径和文件名字,点OK即可生成新的数据库;
再备份SQL2005时,要记住在Destination栏里只有一个路径,否则如果有2个那么被备份的数据会被分摊到两个文件里,则恢复时不能成功。在恢复时要注意要覆盖的目标路径默认为源数据库的安装路径,如果目标数据库的安装路径不一样则要手动改一下,否则会报找不到路径的错误。

(11)SQL2005改集成验证模式为混合验证模式的方法:
打开SQL Server Management Studio-用数据库管理员登陆-右键数据库引擎-Properties-Security-此处可以更改了。

让某个用户可以访问某个数据库的方法:
Security文件夹-右键某用户-Properties-User Mapping-勾选相应数据库,Default Schema处可以选dbo-Database role membership for: Collector处可以选db_owner和public

(11)电脑A访问电脑B的SQL Server的设置:
1.能ping通SQL所在的电脑。
2.防火墙必须打开,并且加端口TCP 1433到例外。
3.打开SQL Server Configuration Manager-展开SQL Server 2005 Network Configuration-点击下属的Protocols for MSSQLSERVER-在其右面Enabled “Named Pipes”

一般用的连接协议是NAMEPIPE,因此一般用机器名称。  
如果要用IP的话,那么连接协议应该采用TCP/IP。

(12)问题:
Cannot connect to LJQ2.
Addition information:
Timeout expired. The timeout period elapsed to completion of the operation or the server is not responding.(Microsoft SQL Server)
原因:
安装有SQL2005的电脑上,微软操作系统默认提供的Windows Firewall防火墙拦截了另一个电脑的访问数据库的请求。
解决:
Control Panel-Windows Firewall-Exceptions-Add Program-Browse选“C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Binn\sqlservr.exe” -确定。这样就添加到了防火墙里,就可以被访问了。

如果要建立“Microsoft SQL Server Analysis Services”数据源则要加入“C:\Program Files\Microsoft SQL Server\MSSQL.2\OLAP\bin\msmdsrv.exe”到防火墙,不让防火墙阻挡对此程序的访问。

(13)Microsoft SQL Server 2005 安装过程中提示下面的问题:
无法在 COM+ 目录中安装和配置程序集 C:\Program Files\Microsoft SQL Server\90\DTS\Tasks\Microsoft.SqlServer.MSMQTask.dll。错误: -2146233087
错误消息: Unknown error 0x80131501
错误说明: 要执行此任务,您必须具有管理凭据。请与您的系统管理员联系以获得帮助。


解决办法:

http://blog.csdn.net/zhzuo/archive/2007/05/29/1630045.aspx

方法一:
1.运行regedit命令。授权下面的注册表项,Administrators组,“完全控制”权限:
'HKEY_CLASSES_ROOT\Microsoft.SqlServer.Dts.Tasks.MessageQueueTask.DataFileMessage'
'HKEY_CLASSES_ROOT\Microsoft.SqlServer.Dts.Tasks.MessageQueueTask.MessageQueueTask'
'HKEY_CLASSES_ROOT\Microsoft.SqlServer.Dts.Tasks.MessageQueueTask.EncryptionAlgorithmWrapper'
'HKEY_CLASSES_ROOT\Microsoft.SqlServer.Dts.Tasks.MessageQueueTask.ServCompMQTask'
'HKEY_CLASSES_ROOT\Microsoft.SqlServer.Dts.Tasks.MessageQueueTask.Formatter'
'HKEY_CLASSES_ROOT\Microsoft.SqlServer.Dts.Tasks.MessageQueueTask.StringFormatter'
如果不行的话就给HKEY_CLASSES_ROOT赋予Administrators组,“完全控制”权限。
2.点击Reset则安装成功。

方法二:

点击Ignore继续安装,安装成功后按照下面的步骤解决。

1.确认没有安装:
Administrative Tools-Component Services-计算机-我的电脑-COM+应用程序节点-应该不能发现Microsoft.SqlServer.MSMQTask节点。

2.运行regedit命令。授权下面的注册表项,Administrators组,“完全控制”权限:
'HKEY_CLASSES_ROOT\Microsoft.SqlServer.Dts.Tasks.MessageQueueTask.DataFileMessage'

'HKEY_CLASSES_ROOT\Microsoft.SqlServer.Dts.Tasks.MessageQueueTask.MessageQueueTask'

'HKEY_CLASSES_ROOT\Microsoft.SqlServer.Dts.Tasks.MessageQueueTask.EncryptionAlgorithmWrapper'

'HKEY_CLASSES_ROOT\Microsoft.SqlServer.Dts.Tasks.MessageQueueTask.ServCompMQTask'

'HKEY_CLASSES_ROOT\Microsoft.SqlServer.Dts.Tasks.MessageQueueTask.Formatter'

'HKEY_CLASSES_ROOT\Microsoft.SqlServer.Dts.Tasks.MessageQueueTask.StringFormatter'

3.使用cmd执行过程如下:
C:\Documents and Settings\jasonlee>cd C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727>regsvcs.exe "f:\Program Files\Microsoft SQL Server\90\DTS\Tasks\Microsoft.SqlServer.MSMQTask.dll"

4.确认安装成功:
Administrative Tools-Component Services-计算机-我的电脑-COM+应用程序节点-发现Microsoft.SqlServer.MSMQTask节点,可见该COM+服务已经安装上。

(13)错误:
SQL Server Setup failed to modify security permissions on file E:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\ for user v-jjjj. To proceed, verify that the account and domain running SQL Server Setup exist, that the account running SQL Server Setup has administrator privileges, and that exists on the destination drive.


原因:
可以到“E:\Program Files\Microsoft SQL Server\90\Setup Bootstrap\LOG”打开Summary.txt文件查看安装失败的详细解释。
当你卸载后这个“E:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\”文件夹中有残余的数据库文件时,而这些文件在Security里又没有Administrators组并且没有给此组赋予Full Control权限时,则会发生上面的问题。


解决办法:
到文件夹内给每个文件都添加管理员组。右键文件-选Property-选Security标签-添加Administrators组并赋予Full Control权限(并确认v-jjjj账户在Administrators组里),添加v-jjjj账户是不管用的。

(14)SQL2000的调试:

http://blog.csdn.net/fish_zhang/archive/2007/06/30/1672578.aspx
http://blog.csdn.net/fish_zhang/archive/2007/06/30/1672586.aspx

 

Use SQL Server 2000 Query Analyzer to debug Sql statements:
By the Query Analyzer for SQL 2000, right-click on the stored procedure name. The right-click menu should have a 'debug' option at the very bottom. If this menu option is grayed-out, you should review the permissions associated with your current user.

On the Debug Procedure Window, you will need to check 'Set to null' for each of those parameters that are treated as OUTPUT only.
If you do not want the debug session to affect your database, make sure to check the 'Auto roll back' check box. This will roll back any changes to the database made while debugging the stored procedure.
The first section has 3 parts to show local variables, global variables and your call stack. The local variables can be changed will in the debugger. The global variables can be added or removed will in the debugger.
The last section is the results pane.

To go to a nested stored procedure, click on the 'Step Into' tool on the debug tool bar or press F11.

调试:

开始-所有程序-MS SQL ServerQuery AnalyzerTools-对象浏览器-存储过程-选择要调试的存储过程-右击-选择调试(debug)-输入参数-设置完你的参数值后,点击执行,就是出现一个浮动工具条,上面有单步执行,断点设置等

FAQ:
服务器: 消息 514,级别 16,状态 1,过程 sp_sdidebug,行 1
[Microsoft][ODBC SQL Server Driver][SQL Server]
无法与 GISWORLD"GISQLAND 上的调试程序联络(错误 = 0x80070005)。已禁用对连接 54 的调试。
如果用本地系统帐户登陆电脑,而SQL Server服务也用此账户运行,则不能调试存储过程,其解决方法如下:
控制面板-管理工具服务—MSSQLServer—右键选“属性”选“登陆”标签选一个Windows帐户,填写密码,再重新启动SQL Server 2000就可以调试存储过程了。
跟踪:

开始-所有程序-MS SQL Serve-事件探查器(Profiler)-文件-新建“跟踪”,然后数据库的调用情况就会显示出来。

 

(14)调试多层数据库应用程序
以下方法可在SQL2000和2005中使用。

http://msdn.microsoft.com/zh-cn/library/zefbf0t6(VS.80).aspx

数据库对象的开发生存周期包括编码、部署到数据库、单元测试、应用程序测试和调试等阶段。在 SQL Server 2005 之前,所有数据库对象都是用 T-SQL 编写的。常见的做法是,除了使用 Visual Studio 完成应用程序测试以外,整个生存周期的其他阶段都使用查询分析器工具(它包括 T-SQL 调试器)来完成。在 SQL Server 2005 中,查询分析器已由 SQL Server 管理控制台替换。由于有了创建 SQL/CLR 数据库对象这种新功能,因此可以在 Visual Studio 内部完成调试,而不用在 SQL Server 管理控制台中进行调试(该管理控制台不包括调试器)。

 

SQL 调试限制
多层 SQL 调试
连接池是提高性能的技术。当应用程序关闭它的数据连接时,SQL Server 连接并未完全关闭,而是保留在可以重用的池中,以便应用程序随后试图重新打开该连接时使用。但是,当通过连接池重新建立连接时,不重新启用 SQL 调试。

 

调试时,应当临时禁用连接池。为此,可在用来连接到 SQL Server 的连接字符串中设置“Pooling=false”。完成调试后,从连接字符串中移除该属性,默认情况下将启用池。

修改如下:

<connectionStrings>
<add name="NorthwindConnectionString" connectionString="DataSource=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\NORTHWND.MDF;Integrated Security=True;User Instance=True; Pooling=false" providerName="System.Data.SqlClient"/>
</connectionStrings>

 

如果通过用 OleDbDataAdapter 建立的连接进行调试,命中断点后等待一段较长的时间将导致连接超时。如果试图在此超时过后继续调试(例如,从“调试”菜单选择“继续”),则调试器将退出而不是继续执行。这是预期的行为。调试器退出是因为 OleDbDataAdapter(与 SqlDataAdapter 不同)在发生超时不引发异常。若要解决这个问题,请在使用 OleDbDataAdapter 时将超时值设置为一个较大的数字。

 

其他限制
触发器必须被激发后才能进行调试:不能直接调试触发器。而应当在将导致触发器被激发的存储过程中开始调试。

 

在运行时调试中,一系列子选择(例如,在联合中的选择)可以填充网络缓冲区。这可以导致通常运行良好的代码在调试期间暂停运行。这时若要获得更多数据,请使用 RecordSet.MoveNext 和 RecordSet.NextRecordSet。

 

如果存储过程名包含引号,则可能会收到调试器错误信息。有关更多信息,请参见当调试的过程的名称包含引号时出现错误。

 

在调试存储过程的同时不能附加到本机 SQL Server 进程。


如何:为项目启用 SQL 调试 

从 C++ 项目中启用 SQL 调试

  1. 在“解决方案资源管理器”中,单击鼠标右键并在快捷菜单上单击“属性”。

  2. 在“<Project> 属性页”对话框中,打开“配置属性”节点,然后选择“调试”节点。

  3. 将“SQL 调试”设置为“是”。

为 Visual Basic 或 C# 项目启用 SQL 调试

  1. 在“解决方案资源管理器”中选择项目。

  2. 单击鼠标右键,然后单击“属性”。

    “属性页”对话框随即出现。

  3. 单击“调试”选项卡。

  4. 在“启用调试器”部分中,选中“SQL Server 调试”复选框。

如何:启用多层调试 

启用多层调试

  1. 打开“服务器资源管理器”。

  2. 单击一个数据库连接以选择它。

  3. 右击想要调试的连接,并从快捷菜单中单击“应用程序调试”。

(15)数据库的多层调试的设置的总结:
一.为 Visual Basic 或 C# 项目启用 SQL 调试
在“解决方案资源管理器”中选择项目。

单击鼠标右键,然后单击“属性”。

“属性页”对话框随即出现。

单击“调试”选项卡。

在“启用调试器”部分中,选中“SQL Server 调试”复选框。


二.启用多层调试
打开“服务器资源管理器”。

单击一个数据库连接以选择它。

右击想要调试的连接,并从快捷菜单中单击“应用程序调试”。


三.调试时,应当临时禁用连接池。为此,可在用来连接到 SQL Server 的连接字符串中设置“Pooling=false”。完成调试后,从连接字符串中移除该属性,默认情况下将启用池。


四.调试多层应用程序时,不能使用“逐语句”从应用程序层(C#、Visual Basic 或 C++)中的代码进入 SQL Server 2005(T-SQL 或 SQL/CLR)上的代码。而应当在存储过程代码中设置断点。而且,也不能从存储过程代码返回到调用该存储过程的层上的代码。如果要在返回应用程序层之后继续进行调试,请在应用程序代码中调用存储过程的点之后设置断点。


五.连接帐户必须是 sysadmin 角色的成员。

调试远程数据库最关键的要点在于,要确保启动Visual Studio的Windows用户与连接远程数据库的用户是同一个用户。 此外,该用户必须隶属于sysadmin角色。

例如,你可以在Windows的域中创建一个名为“TestDebug”的用户。 然后使其可以登录到远程SQL Server数据库,并将该用户添加到sysadmin角色内。另外,你还需要使用“TestDebug”用户来登录你的电脑,或者确保使用runas.exe命令启动的Visual Studio运行在“TestDebug”用户下。

(15)在Visual Studio中创建一个SQL Server项目并在该项目中调试Sql Server2005:

http://www.cnblogs.com/eugenewu0808/articles/1287015.html
1.在vs中选择“Sql Server项目”模版
2.可以在项目的属性页里修改数据库连接
3.把要调试的语句放入Test Scripts下的TestScript.sql文件里,并加上断点
4.按F5就可以调试到断点了

(16)当用你的电脑的VS2005去调试远程电脑上的数据库的存储过程,如果抛出下面的错误:
T-SQL execution ended without debugging. You may not have sufficient permissions to debug. Click Help for more infomation.
解决办法:
1.去到远程电脑上。
2.到控制面板-管理工具—服务—MSSQLServer—右键选“属性”—选“登陆”标签。如果SQL Server服务用的是“本地系统帐户”则改成你运行VS2005的电脑的Windows帐户,填写密码,再关掉再重启此服务就可以调试存储过程了。

(17)使用VSTS开发数据库:
此插件用于给Visual Studio 2005 Team Suite增加Database Professional部分,即是增加了建立数据库工程的模版。
Visual Studio 2005 Team Edition for Database Professionals Add-on for Visual Studio 2005 Team Suite Edition:
http://www.microsoft.com/downloads/details.aspx?FamilyID=7de00386-893d-4142-a778-992b69d482ad&DisplayLang=en
用于 Visual Studio 2005 Team Suite Edition 的 Visual Studio 2005 Team Edition for Database Professionals 加载项:
http://www.microsoft.com/downloads/details.aspx?FamilyID=7DE00386-893D-4142-A778-992B69D482AD&displaylang=zh-cn

创建数据库项目

  1. 启动 Visual Studio(如果尚未启动的话)。

  2. “文件”菜单上,指向“新建”,然后单击“项目”

    将出现“新建项目”对话框。

  3. “项目类型”列表中,展开“数据库项目”节点,然后单击“Microsoft SQL Server”

  4. “模板”列表中,单击“SQL Server 2005”

  5. “名称”中键入“MyAdvWorks”,并接受“位置”“解决方案名称”的默认值。

  6. 选中“创建解决方案的目录”复选框(如果默认情况下未选中),然后单击“确定”

    随即会创建一个包含 MyAdvWorks 空数据库项目的解决方案。

 

从现有 AdventureWorks 数据库中导入数据库架构

  1. “视图”菜单上单击“架构视图”

    如果“架构视图”尚未显示,此时将显示该视图。

  2. “架构视图”中单击“MyAdvWorks”。

  3. “项目”菜单上,单击“导入数据库架构”

    说明:

    还可以右击“MyAdvWorks”并单击“导入数据库架构”

    将出现“导入数据库向导”。

  4. “源数据库连接”列表中,单击与现有 AdventureWorks 数据库相对应的连接。如果尚未连接到该数据库,则必须先创建与该数据库的连接。有关更多信息,请参见如何:创建数据库连接

  5. 单击“完成”

(18)SQL智能提示助手 for Visual Studio and SQL Server:

SQLPrompt 3.9
应该是最好用的,可在任何文件中有提示,语法和表名等都有提示,有设置界面,不支持VS2003支持VS2005。
http://www.red-gate.com/
破解
http://www.cnblogs.com/studyzy/archive/2008/07/24/1250101.html
http://www.cnblogs.com/jintan/archive/2008/06/13/1220365.html
http://www.cnblogs.com/jintan/archive/2008/06/16/1223282.html
http://www.cnblogs.com/liuxzh1026/
http://www.cnblogs.com/madgoat/archive/2007/06/21/792297.html 

静态分析 破解Spices.net v5.1 --- 试谈.net程序的破解
http://bbs.pediy.com/showthread.php?p=239330 
SQL Prompt 3.8.0.244
http://download.csdn.net/source/598801

在VS2005中的SQLPrompt的设置:
1.当此软件过期后可通过重装继续使用。
2.到SQL Prompt菜单-Enable SQL Prompt可开启或关闭SQLPrompt插件。
3.要想智能提示某个数据库的对象,则先要连接到此数据库后才能正确提示:
a.如果你的VS2005-Server Explorer中已经连接到此数据库,可在工具条中点击“Connect”,使当前文件连接到数据库。
b.也可到SQL Prompt菜单-Connect to Server里设置到相应的server和数据库。
4.如果数据库有变化,可到SQL Prompt菜单-Refresh Cache或Catche Management刷新后即可反映最新内容。
5.到SQL Prompt菜单-Options-Inserted Candidates-Case:将3个下拉框都设置成Leave as is可使输入时SQL语句的关键字是首字母大写而不是都大写。
6.到SQL Prompt菜单-Lay Out SQL可格式化SQL语句。
7.到SQL Prompt菜单-Options-Layout:可设置在使用格式化命令后,被格式化的SQL语句的样式。

SoftTree SQL Assistant 3.5
可在任何文件中有提示,不能提示语法,有设置界面,支持VS2003和VS2005。
如果想在VS中使用,需安装完后在Options-Targets里勾选上MS Visual Studio。
有个问题就是我重装VS2005后再打开文件后VS2005就死了,卸载SoftTree SQL Assistant后就好了。
http://d.download.csdn.net/down/512924/mejy
http://www.softtreetech.com/download/sqlassist_setup.exe
http://downloads.zdnet.com/abstract.aspx?&docid=282836&promo=110000
注册码
715253-4G50IRL-1L44-5055

SqlAssist
只在.sql文件中有智能提示,只提示语法不提示表名什么的,没有设置界面。
http://roundpolygons.com/
SqlAssistVS2003Setup1.2.14
http://www.download.com/SqlAssist/3000-2352_4-10491027.html
SqlAssistVS2003Setup
http://downloads.zdnet.com/abstract.aspx?docid=250047

KNOCKS SQL-Sense
可在任何文件中有提示,不提示语法只提示表名等,有设置界面但可设置的选项很少。
http://knocks-solutions.com/SQLSense.aspx

 

(19)SQL错误检查工具(如有语法错误时以红色底线标出):

SQL格式化工具 Visual Studio 2005 插件 2.0
不能用红线等标出错误,不能实时纠错,需要右键选择来检查。查错的速度有点慢。
http://www.onlinedown.net/soft/49328.htm

 

(20)

如果您使用远程 Microsoft SQL Server 2000 服务器,并且您希望使用 NT Authority\Network Service 作为域帐户,则您必须添加 Domain\ComputerName$ 项,并使用 Database Creators 和 Security Administrators 权限对其进行配置。这样,Windows SharePoint Services 就可以连接到远程 SQL Server 计算机来创建配置和内容数据库。

 (21)

 

SQL Server 2000 配置SQL Mail
  1.为SQLServer创建一个NT域用户帐号,要求具有本地管理员权限

  2.双击控制面板的服务图标,找到MSSQLServer的启动设置,将Use System Account改为Use This Account,将刚才建立的NT帐号和口令输入。重新启动SQLServer。

  3.在安装SQLServer的服务器上以与启动SQLServer相同的NT帐号登录,然后安装支持MAPI接口的邮件客户端程序,如MSExchangeClient和Outlook97。

  4.打开控制面板的电子邮件选项,建立一个配置文件(Profile)。用这个配置文件启动邮件客户端程序,反复检验直至能正常收发邮件。

  5.从Sql Enterpriser Manager中,点中相应的服务器图标,从Server菜单中选SQLMail/Configure,将在第4步中建立的配置文件名输入。对于SQL Server2000,上面三步的帐户必须相同,否则此处不能看见Profile。

  6.从Sql Enterpriser Manager中,点中相应的服务器图标,从Server菜单中选SQLMail/Start,如果SqlMail的图标变为绿色,则SQLMail成功启动。

 

Enterprise Library

(1)Enterprise Library 下载:
http://msdn.microsoft.com/en-us/library/cc467894.aspx 

Microsoft Enterprise Library June 2005
http://www.microsoft.com/downloads/details.aspx?FamilyId=A7D2A109-660E-444E-945A-6B32AF1581B3&displaylang=en


 

(2)

企业库配置文件连接数据库的两种方法:

1.混合验证:

         <connectionString name="CentralDatabase">
          
<parameters>
            
<parameter name="server" value="Jasonpremdevsql01" isSensitive="false" />
            
<parameter name="database" value="CMS" isSensitive="false" />
            
<parameter name="Integrated Security" value="False" isSensitive="false" />
            
<parameter name="User ID" value="jason" isSensitive="false" />
            
<!--<parameter name="User" value="jason" isSensitive="false" />-->
            
<parameter name="Password" value="123456789" isSensitive="true" />
          
</parameters>
        
</connectionString>

 

2.集成验证:

         <connectionString name="CentralDatabase">
          
<parameters>            
            
<parameter name="server" value="JasonB11MCTSQL05" isSensitive="false" />
            
<parameter name="database" value="CMS" isSensitive="false" />
            
<parameter name="Integrated Security" value="True" isSensitive="false" />
          
</parameters>
        
</connectionString>

 

(3)当程序使用企业库时,在操作数据库时,如果抛出下面的异常:
System.TypeInitializationException: The type initializer for 'Microsoft.Practices.EnterpriseLibrary.Data.Instrumentation.DataCommandFailedEvent' threw an exception. ---> System.Security.SecurityException: Requested registry access is not allowed.
   at System.ThrowHelper.ThrowSecurityException(ExceptionResource resource)
   at Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable)
   at System.Diagnostics.EventLog.CreateEventSource(EventSourceCreationData sourceData)

原因是访问程序所在机器的注册表时没有权限。
三种解决办法:
1.到注册表的 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog 加Network Service账户并给其一定的权限。
http://support.microsoft.com/kb/842795/zh-cn

2.
a.安装Microsoft Enterprise Library June 2005
b.需要执行\Microsoft Enterprise Library June 2005\src目录下的InstallServices.bat就好了,是注册一个企业库服务。

这种方法要求你安装VS2003,否则获得“Error: Unable to locate Visual Studio.NET”错误。
You also can use the below solution to register those .dll in ~\Webservice\bin:
1. Copy the InstallUtil.exe from your machine to UAT machine. It should be at C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322. the attached is a InstallUtil.exe. Then unzip it to desktop.
2. Use the "~\Desktop\InstallUtil.exe" "~\Webservice\bin\Microsoft.Practices.EnterpriseLibrary.~.dll" command in cmd.exe to register all of Enterprise Library dll.

3.推荐此方法:打开EnterpriseLibrary源码,重新编译Microsoft.Practices.EnterpriseLibrary.Common项目,编译时把项目属性的build中的Conditional Compilation Constants设置中除DEBUG;TRACE外的其他项都去掉。然后使用新生成的Microsoft.Practices.EnterpriseLibrary.Common.dll
http://blog.joycode.com/ghj/archive/2005/07/26/60364.aspx
http://dotnetjunkies.com/WebLog/sskokku/archive/2005/03/25/61376.aspx


Dreamweaver
1)Dreamweaver MX显示汉字为乱码的解决方法:
以前经常遇到此问题,推荐几种解决方法:

   a.在“编辑”-“首选参数”中设置“新建文档”->默认编码:utf-8或者gb2312(取决于你的网页编码),并勾选“当打开未指定编码的现有文件时使用”;此时每次打开文件时都没有乱码了,也不额外加代码。

   b.当文件已经打开,并显示乱码时,选择"修改"菜单->页面属性->标题/编码,选择正确的编码方式:通常为utf8或gb2312(取决于你的网页编码),然后点击"重新载入";此时给文件加了<meta http-equiv="Content-Type" content="text/html; charset=gb2312">语句。

   c.升级至Dreamweaver 8。

2)当框架的边框看不到时,在工具栏里点击“视图选项”-“可视化助理”-“框架边框”选上就可看见边框了。


Perforce  
P4快捷键:

F6-Pending Change-lists
F7-Submitted Change-lists
F10-Client-specs
F11-Users

P4使用注意事项:
1)在VS2003中当“添,删,改(改文件名字)”文件时,工程文件会发生改变,且此文件用的人多,所以此文件用时才打开,用完立即上传。
2)上传代码前务必将本地代码同步成最新的并调试通过后再上传。
3)当文件因和服务器文件版本不一样时而不能提交时,可在P4上右键此文件-Resolve-Schedule File for Resolve来使版本更新。

虚拟机  
1)当启动虚拟机时要用鼠标点击工作窗将虚拟机窗口激活才能使按F2键进入BOIS设置相应的东西。
2)如果重装虚拟机的系统则可以从光盘启动,在BIOS里在Boot里用Shift和+将ROM上移到最上面。
3)如果系统已经启动后要改变CD-ROM的ISO源可以不关闭系统,直接在左面Favorites里右键那个虚拟机选Settings之后设置CD-ROM。
4)在虚拟机上也可以用“Open Existing VM or Team”打开一个以前建立的虚拟机备份。
5)如果操作系统已经启动则在Favorites里右键操作系统选Settings-Ethernet的Network connection选Bridged: Connected directly to the physical network时,此虚拟机相当于一台独立的电脑,在其内部配置其自己的Network Connections属性的IP则可以被域中其他电脑访问。

Windows Server 2003  
安装:
如果安装完毕后汉字都为乱码“方框”,请Start-Control Panel-Regional and Language Options的Languages里勾选Install files for East Asian languages并安装。
如果一些软件安装时的默认路径的中文为“问号”且自解压不能成功时,请Start-Control Panel-Regional and Language Options的Advanced里改成Chinese(PRC)。

配置域控制器时:
在请Start-Control Panel-右键Network Connections选Open右键连接选Properies打开TCP/IP的属性,注意此处的IP,子网掩码为255的对应的IP要相同的不同的计算机才能互相访问。
用域用户登陆后要想能在机器上安装软件要将此域用户加入到本地管理员组里,右键My Computer-Manage-Local Users and Groups-Groups里右键Administrators选属性加入域用户cs\ljq2
当域用户登陆过一次本机后,下次登陆时即使域控制器没有启动或网络没有连上,也能登陆到本机上,这样可以实现“本机做为域中的某个用户安装TFS,本机上的虚拟机做为域控制器,只有第一次本机登陆时要借助第二台实体电脑(上面有相同的域控制器服务)”
域控制器和域用户的时间都保持一样才能互相访问。

在Start-Run里用到的一些命令:
AZMan:run-azman.msc或run-mmc

域的配置:
公司网络结构:
10.167.xxx.xxx网关(物理上就是交换机)           
             /                            \                        \
10.167.26.xxx网关     10.167.26.xxx网关  公司域控 
    /            \        \                /        \        \
My域控A PC1 PC2     PC3      PC4   My域控B

在Local Area Connection Properties-Internet Protocal (TCP/IP) Properties中:
域控制器的IP地址最好是固定的,也可以是动态的但有时候可能会联不上域控。
域控的“IP address”和“Prefereed DNS server”的值要相同。
“Default gateway”的值是域控电脑所处网段的交换机的IP,“Default gateway”用来访问外网,如果指定的不是你所处网关的IP而是其他网关的IP,则不能访问外网。小的局域网用HUB就可以连上,HUB也可以连HUB。
“Use the following IP address”处是网关所管辖下的用于标识电脑自己的IP地址。
“Use the following DNS server addresses”处的地址是域控的IP。两个IP可以在不同的网关(网段)里。

将电脑加入域的方法:右键My Computer-Properties-Computer Name-Change:如果以前加入过别的域则先改成加入workgroup在加入域,Computer Name 可随便起。

一个公司的域用户可以这样建立:
    公司名称OU
     /                    \
组OU               用户OU
    |                    /              \
存储所有组 部门OU1    部门OU2
                         /        \        /            \
                 用户1   用户2  用户3  用户4 


Symantec自动更新病毒库的方法:打开Symentec AntiVirus-files-Shedule Updates-设置任务。

(2)怎样成功设置IE的安全级别:
Tools-Security-Custom Level-此时选好等级后,一定要点击“Reset”才能设置成功。

(3)
如何进行端口映射,以便外网(internet)访问内网(局域网):
http://blog.sina.com.cn/s/blog_467738e3010006x1.html



VSTS  
1)一台电脑既做域控制器又做TFS的方法:
在一台临时的电脑B上安装虚拟机并在此虚拟机上安装域控制器,在A电脑上安装TFS(以B的虚拟机做为域控制器),一切成功后,将B的虚拟机上的操作系统文件拷贝到A上,关掉B上的虚拟机,打开A上的虚拟机域控制器(此时为虚拟机Creater一个新的UUID),此时一台电脑上可运行二者了。

2)服务器端的TFS安装:
安装SQL Server 2005企业版后最后用TFS自带的补丁而不要用sp1,因为好像sp1可能会导致Integration Services不能启动,sp1也可能会影响Reporting Services不能使用。

安装TFS时如果出现下面的错误:
“Error 32000. The command line '"C:\prgram Files\Common Files\Microsoft Shared\Web Server Extensions\60\bin\Stsadm.exe" ...' returned non-zero value -1.”
则可能是SQL Server和Sharepoint的安装顺序不对,WSS要装在SQL Server之后,解决的办法是卸掉WSS重装,参见:
http://blogs.msdn.com/willbu/archive/2006/08/23/Common-Team-Foundation-Server-installation-errors-and-possible-resolutions.aspx 
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1631657&SiteID=1 

应用程序层会使用IIS的Default Web Site站点,将整个站点都占用,其下的任何站点都会有问题。而且会修改其下的网站的应用程序池到TFS。
双服务器部署会在数基层生成报表的数据库。会使用8080端口。
单双部署都会使用数据库和报表的默认实例。
安装有TFS应用层的机器即wws2.0的不能装MOSS2007即WWS3.0

 

单服务器部署
一安装 Internet 信息服务 (IIS)
1.请选择“ASP.NET”。
2.请不要选择“FrontPage 2002 服务器扩展”。
二安装 Microsoft SQL Server 2005
1.使用 Team Foundation Server 安装帐户(例如 Domain\TFSSETUP)登录到 Windows。
2.在“要安装的组件”页上,选择下面的组件,然后单击“高级”。
SQL Server Database Services
Analysis Services
Integration Services
Reporting Services
工作站组件、联机丛书和开发工具
不需要 Notification Services。
3.在“实例名”页上,选择“默认实例”,然后单击“下一步”。
4.在“服务帐户”页上,选择“使用内置系统帐户”并从列表中选择“本地系统”。在“安装结束时启动服务”中,选择所有服务:“SQL Server”、“SQL Server Agent”、“Analysis Services”、“Reporting Services”和“SQL Browser”,然后单击“下一步”。
5.在“报表服务器安装选项”页上,选择“安装默认配置”,然后单击“下一步”。
三安装 Microsoft SQL Server 2005 修补程序
1.在数据层计算机上,打开“SQL Server 配置管理器”,右击“SQL Server 浏览器服务”,然后单击“停止”。
2.在 Team Foundation Server 安装媒体上,找到 SQLServerKB 文件夹。
找到与您的操作系统和语言对应的可执行文件 (.exe),如 AS2005-KBnnnnnn-x86-ENU.exe,然后双击该文件以启动 Hotfix Installer(修补程序安装程序)。
3.在“SQL Server 配置管理器”中,右击“SQL Server Browser 服务”,然后单击“属性”。
在“服务”选项卡上找到“启动模式”,然后选择“自动”。
在“登录”选项卡上,单击“启动”。
注意
如果在“登录”选项卡上未启用“启动”,则单击“服务”选项卡,将“启动模式”设置为“禁用”,然后再次选择“自动”以显式更新“启动模式”。
四安装 Microsoft .NET Framework 2.0 修补程序
1.在应用层计算机上,找到 Team Foundation Server 安装媒体上的 KB913393 文件夹。
2.找到与您的操作系统 (X86) 对应的可执行文件 (.exe),然后双击该文件进行安装。
五安装 Microsoft Windows SharePoint Services
要点
Windows SharePoint Services 需要使用 NTFS 文件系统。

1.使用 Team Foundation Server 安装帐户(例如 Domain\TFSSETUP)登录到 Windows。
2.在“安装类型”页上选择“服务器场”,然后单击“下一步”。
3.安装完成时,将打开一个 Web 浏览器窗口,并显示“配置管理虚拟服务器”页。确认该页显示后,不要进行任何更改,关闭该浏览器窗口。
4.重新启动计算机。
六验证 Windows SharePoint Services 安装
打开 Internet Explorer 并键入相应的服务器名称作为地址。
例如,对于名为 ADATUM 的服务器,应键入 Http://adatum。
虽然未配置站点,但服务器是活动 Web 服务器并提供“建设中”页面。

注意
在本地化版本的 Windows SharePoint Services 上安装 Team Foundation Server 之前,必须先安装与 Team Foundation Server 语言匹配的 Windows SharePoint Services 语言包。例如,如果计划安装本地化版本的 Windows SharePoint Services 和英文版的 Team Foundation Server,则必须在安装 Team Foundation Server 之前安装 Windows SharePoint Services 英语语言包。
七安装 Team Foundation Server
1.使用 Team Foundation Server 安装帐户(例如 Domain\TFSSETUP)登录到 Windows。
2.在“服务登录帐户”页上,在“帐户名”框中键入您为 Team Foundation Server 服务帐户创建的 Windows 域用户帐户(例如 Domain\TFSSERVICE),并在“密码”框中键入密码,然后单击“下一步”。
3.在“报告登录帐户”页上,键入 Team Foundation Server 报告帐户的帐户信息,此帐户不应与 Team Foundation Server 安装或服务帐户相同。例如,使用 Domain\TFSREPORTS。然后单击“下一步”。
4.在“指定警报设置”页上,选择“启用 Team Foundation 警报”,然后键入以下信息:
在“SMTP 服务器”框中,键入将用于发送电子邮件通知的服务器的名称。
在“发件人电子邮件地址”框中,键入作为通知来源的电子邮件地址的名称,然后单击“下一步”。
5.在 Internet Explorer 中,定位到 http://localhost:8080/services/v1.0/Registration.asmx,然后单击“GetRegistrationEntries”。
在“GetRegistrationEntries”页上单击“调用”。不必输入 ToolID。
注意
要使用此 Web 方法,您必须位于应用层计算机上。
在 XML 中,确认类型 VSTF 存在,然后关闭。例如:
<?xml version="1.0" encoding="utf-8" ?>
  <Type>vstfs</Type>


双服务器部署
在数据层上
一安装 Microsoft SQL Server 2005
1.在数据层计算机上,使用 Team Foundation Server 设置帐户(例如 Domain\TFSSETUP)登录到 Windows。
2.在“要安装的组件”页上,选择下面的组件,然后单击“高级”。
SQL Server Database Services
Analysis Services
Integration Services
工作站组件、联机丛书和开发工具

注意
Reporting Services 应安装在应用层上。Team Foundation Server 不需要 Notification Services。

3.在“实例名”页上,选择“默认实例”,然后单击“下一步”。
4.在“服务帐户”页上,选择“使用内置系统帐户”并从列表中选择“本地系统”。在“安装结束时启动服务”中,选择所有服务:“SQL Server”、“SQL Server Agent”、“Analysis Services”和“SQL Browser”,然后单击“下一步”。
二安装 Microsoft SQL Server 2005 修补程序
1.在数据层计算机上,打开“SQL Server 配置管理器”,右击“SQL Server 浏览器服务”,然后单击“停止”。
2.在 Team Foundation Server 安装媒体上,找到 SQLServerKB 文件夹。
找到与您的操作系统和语言对应的可执行文件 (.exe),如 AS2005-KBnnnnnn-x86-ENU.exe,然后双击该文件以启动 Hotfix Installer(修补程序安装程序)。
3.在“SQL Server 配置管理器”中,右击“SQL Server Browser 服务”,然后单击“属性”。
在“服务”选项卡上找到“启动模式”,然后选择“自动”。
在“登录”选项卡上,单击“启动”。

注意
如果在“登录”选项卡上未启用“启动”,则单击“服务”选项卡,将“启动模式”设置为“禁用”,然后再次选择“自动”以显式更新“启动模式”。
三安装 Team Foundation Server 数据库
1.使用您在核对检查表时确定的 Team Foundation Server 设置帐户(例如 Domain\TFSSETUP)登录到 Windows。
2.查看 Team Foundation Server 数据库
从“开始”菜单上单击“程序文件”,再单击“Microsoft SQL Server 2005”,然后单击“SQL Server Management Studio”。
在“对象资源管理器”中,展开“数据库”并验证 Team Foundation Server 数据库是否存在。

将应用层配置为应用程序服务器
一安装IIS
1.请选择“ASP.NET”
2.不要选择“FrontPage 2002 Server Extensions”。
3.请验证是否已启用 ASP.NET,如果没有则启用。
二安装 SQL Server Reporting Services
1.在应用层计算机上,使用 Team Foundation Server 设置帐户(例如 Domain\TFSSETUP)登录到 Windows。
2.在“要安装的组件”页上,选择“Reporting Services”,然后单击“下一步”。
3.在“实例名”页上,选择“默认实例”,然后单击“下一步”。
4.在“服务帐户”页上,选择“使用内置系统帐户”并从列表中选择“网络服务”。在“在安装结束时启动服务”中,选择“Reporting Services”,然后单击“下一步”。
5.单击“完成”退出向导。

警告
不要使用 Reporting Services 配置工具检验服务是否正在运行。Team Foundation Server 安装向导为您配置 Reporting Services,打开该工具可能会阻止安装完成。
三验证 Reporting Services 安装
1.单击“开始”,单击“管理工具”,然后单击“服务”。
2.在“服务管理器”的“名称”列中找到“SQL Server Reporting Services”,并验证“状态”为“已启动”,“启动类型”为“自动”。
3.关闭“服务管理器”。
四安装 Microsoft .NET Framework 2.0 修补程序
1.在应用层计算机上,找到 Team Foundation Server 安装媒体上的 KB913393 文件夹。
2.找到与您的操作系统 (X86) 对应的可执行文件 (.exe),然后双击该文件进行安装。
五安装 Windows SharePoint Services
要点
Windows SharePoint Services 需要使用 NTFS 文件系统。

1.在应用层计算机上,使用 Team Foundation Server 设置帐户(例如 Domain\TFSSETUP)登录到 Windows。
2.在“安装类型”页上选择“服务器场”,然后单击“下一步”。
3.安装完成时,将打开一个 Web 浏览器窗口,并显示“配置管理虚拟服务器”页。确认该页显示后,不要进行任何更改,关闭该浏览器窗口。
4.重新启动计算机。
5.验证已安装 Windows SharePoint Services
打开 Internet Explorer 并键入相应的服务器名称作为地址。
例如,对于名为 ADATUM 的服务器,应键入 Http://adatum。
虽然未配置站点,但服务器是活动 Web 服务器并提供“建设中”页面。
六安装 Team Foundation Server (Services)
注意
如果正在本地化版本的 Windows SharePoint Services 上安装 Team Foundation Server,必须先安装与 Team Foundation Server 语言匹配的 Windows SharePoint Services 语言包。例如,如果计划安装本地化版本的 Windows SharePoint Services 和英文版的 Team Foundation Server,则必须在安装 Team Foundation Server 之前安装 Windows SharePoint Services 英语语言包。

1.在应用层计算机上,使用 Team Foundation Server 设置帐户(例如 Domain\TFSSETUP)登录到 Windows。
2.在“数据库服务器”框中,键入在其上安装 Team Foundation Server (databases) 的计算机的名称。

注意
必须使用计算机名,而不是 IP 地址。

3.在“服务帐户”页上,键入 Team Foundation Server 服务帐户(例如 Domain\TFSSERVICE)的帐户信息,然后单击“下一步”。
4.在“报告登录帐户”页上,键入 Team Foundation Server 报告帐户(例如 Domain\TFSREPORTS)的帐户信息,然后单击“下一步”。

注意
此帐户不应与 Team Foundation Server 安装或服务帐户相同。

5.在“Team Foundation 警报”页上,键入以下信息:
在“SMTP 服务器”框中,键入将用于发送 Team Foundation 警报的服务器的名称。
在“发件人电子邮件地址”框中,键入发送 Team Foundation 警报的电子邮件地址的名称,然后单击“下一步”。

注意
如果要在这里启用警报,就必须知道组织的 SMTP 服务器。对于仅 SMTP 访问,Team Foundation Server 不需要特殊的配置设置。

6.在 Internet Explorer 中,定位到 http://localhost:8080/services/v1.0/Registration.asmx,然后单击“GetRegistrationEntries”。
在“GetRegistrationEntries”页上单击“调用”。不必输入 ToolID。

注意
要使用此 Web 方法,您必须位于应用层计算机上。

在 XML 中,确认类型 VSTF 如此处所示,然后关闭。
<?xml version="1.0" encoding="utf-8" ?>
  <Type>vstfs</Type>



3)客户端的安装:
安装Team Explorer时,需要经过两次重启才能安装完,期间在重启后要保证光驱中有安装盘,会自动继续安装的;安装完后还要重启一遍。

如果用Project2003访问TFS时,如果提示TF86002:lack of .NET Programmability Support in the Office Application.则要打开Microsoft® Office Project Professional 2003 (English) 选择安装之后安装.NET Programmability Support就可以了。

用VS2005连接TFS时“Tools-Connection to Team Foundation Server-Servers-Add-Server name:填写安装有TFS的且在域里的电脑的计算机名如LJQ2”

4)如果用虚拟机做域控制器,如果此虚拟机所运行的操作系统文件是拷贝过来的,或者承载此虚拟机的操作系统被还原后,这些情况都可能导致以此虚拟机为域控制器的TeamFoundationServer的TFSServer域账号过期而使TFS服务启动失败。
解决办法:将将A电脑上的虚拟机上的操作系统(是域控制器并含有被TFS使用的TFSReporting和TFSService帐号)拷贝到另一个电脑B上,在B上启动此域控制器操作系统,在域控制器上将域用户的密码更新一遍(更新成和原来的一样),之后在A电脑上(装有TFS的电脑上)重新登陆一遍,此时TFS成功启动,这时将B上的域控制器拷贝到A电脑上,关B上的虚拟机,启动A电脑上的虚拟机域控制器(其间要选Create一个新的UUID为虚拟机),此时A上的TFS可用,如果此前A上的TFSServerScheduler服务已经停止则要先启动此服务才能使TFS可用。

IIS  
1)发布站点后,访问页面提示下面错误:

错误:

Server Application Unavailable

The web application you are attempting to access on this web server is currently unavailable.  Please hit the "Refresh" button in your web browser to retry your request.

Administrator Note: An error message detailing the cause of this specific request failure can be found in the application event log of the web server. Please review this log entry to discover what caused this error to occur.

解决:

如果你运行WinXP/IIS 5.1,为了给ASPNET工作进程访问你的web工程文件夹的权力请到网站文件所在的目录,右键一级文件夹,选SecurityAdd-键入“ASPNET”,点击OK或点击Check Names,如果弹出对话框提示“Name not Found”则应点击Locations改变位置到本机计算机名,点击OK,分配此用户权限为“Full Control”点击OK

错误变为:
You are not authorized to view this page

You do not have permission to view this directory or page using the credentials you supplied.

解决:

IIS里右键此虚拟目录-PropertiesDirectory SecurityEdit-勾选上Integrated Windows authentication即可。

2)IIS上的asp.net version 只有2.0时的解决办法:
需要重新注册一下asp.net 1.1-在“Visual Studio .NET 2003(vs2005则是注册asp.net2.0)命令提示” 里输入“Aspnet_regiis.exe -i”,如果问题还是没有解决,可能是系统内还驻留有原来的注册,卸载 ASP.NET 1.1 的版本(Visual Studio .NET 2003 命令提示行里输入:“Aspnet_regiis.exe -u”),然后重新注册安装 ASP.NET 1.1版本,并启用 ASP.NET 1.1(在“Visual Studio .NET 2003 命令提示”里输入"Aspnet_regiis.exe -i -enable")


测试 
LoadRunner8.1既可以装在Windows Server 2003上也可以装在XP上,但系统最好是刚刚装的,不要装其他软件,好像尤其不能装VS2005,否则不能安装成功。
LoadRunner7.8和LoadRunner8.0的破解协议是通用的,LoadRunner8.1的破解可以通过拷贝C:\Program Files\Mercury\LoadRunner\bin里的LoadRunner7.8或LoadRunner8.0的lm70.dll和mlr5lprg.dll来覆盖LoadRunner8.1的实现破解。
安装前可以先把当前时间后退到以前的一年,安装中输入破解的协议,安装后恢复当前时间,这样LoadRunner的协议就只有一个被破解的协议而那个试用版本的协议就没了。但如果没这样设置而有那个试用版的协议也不要紧,等到过期后LoadRunner会自动使用那个被破解的协议。

MOSS开发: 
(1)
问题:
访问http://hcsserver:9001/时候,页面出现错误为:

返回网站
错误

此网页存在致命错误。如果问题持续存在,请与系统管理员联系。
Windows SharePoint Services 疑难解答。

原因:
在C:\Inetpub\wwwroot\wss\VirtualDirectories\9001中的web.config文件的内容
<SafeControls>
  <SafeControl ~~~~~~/>
</SafeControls>
被修改的不正确,比如Safe写成Sage或少了“,”

解决方法:
将web.config修改正确,重启IIS的相应站点和应用程序池

由此想到的:
WSS属于2次开发,这些原始代码不能直接去修改,如果修改则要有版本控制。
我的解决方安:
1.WSS的原始代码上传到TFS
2.IIS上运行的WSS代码由TFS下载得到
3.任何人对WSS源码的修改,都只能签出TFS的代码作修改,之后上传,之后再将IIS的代码作同步。

(2)
当IIS上的SharePoint - 9091站点被删除后的恢复办法:
打开SQL Server Configuration Manager-停掉SQL Server-再打开其-copy出WSS_Content数据库-删掉WSS_Content数据库打开MOSS的管理中心-应用程序管理-创建或扩展web应用程序,创建新的9091站点-将现在的WSS_Content数据库换成刚刚拷贝的数据库,可以直接替换或通过备份恢复-在MOSS的“管理中心”的“应用程序管理”的“内容数据库”中-删掉现有的WSS_Content,再添加以前的WSS_Content,一切OK,可能需要用老的文件再覆盖一下现在的文件。

(3)
Infopath表单发布成表单库时让Browser可用的注意事项:
1.网站操作-网站设置-修改所有网站设置-网站功能:激活“Office SharePoint Server 企业版网站集功能”
2.发布时勾选“Enable this form to be filled out by using a browser”

Infopath表单用作工作流的注意事项:
1.Tools-Form Options-Security and Trust,选择Domain或Full Trust后工作流才可用。如果表单用了Full Trust而双击打不开时,则右键.xsn文件选择Design。
2.Infopath表单保存的文件名和发布的文件名应该一致,因为MOSS用的是发布后的文件而ID内的某段单词是保存的文件名。
3.如果使用了Contact Selector控件,则在数据源里要加组Person和域DispalyName、AccountId、AccountType,注意组名和域名必须写的正确且区分大小写,还要加名为Context.xml的文件其内容为<Context siteUrl="http://myserver/">。此规定可在Contact Selector Properties里的Items里找到。


手动配置MOSS工作流:
1.右键工程文件-Properties-“Build Events”->“Post-build event command line”改变“NODEPLOY”到“DEPLOY”
2.右键工程文件-Properties-“Signing”-勾选“Sign the assembly”-选下拉菜单的“New”,不要加密码。
3.配置feature.xml:
Id的获得VS2005-Tools-Create GUID,选4.Registry Formagt,点击Copy-黏贴到feature.xml文件的Id处。
有可能需要删掉或修改feature.xml内的<ElementFile Location="MyForm.xsn"/>
其中“Title”,“Description”可以修改。<Property Key="RegisterForms" Value="*.xsn" />用于注册Infopath表单。

4.配置workflow.xml:
“Name”,“Description”可修改。
“Id”,“CodeBesideClass”,“CodeBesideAssembly”必须修改。
获得.dll文件的公钥标记的方法C:\Program Files\Microsoft Visual Studio 8\VC>sn -T "C:\Documents and Settings\jqli.HSLCN\Desktop\MOSS\SequentialWorkflow\SequentialWorkflow\bin\Debug\SequentialWorkflow.dll"
ModificationUrl="_layouts/ModWrkflIP.aspx"依照情况删掉。
<Association_FormURN>associationFormURN</Association_FormURN>,<Instantiation_FormURN>instantiationFormURN</Instantiation_FormURN>,<Task0_FormURN>taskFormURN</Task0_FormURN>需修改。
如果想增加一个Task表单则添加<Task1_FormURN>并且在代码中用createTask1_TaskProperties1.TaskType = 1;指定任务与表单的关系。
依照情况删除<Modification_GUID_FormURN>modificationURN</Modification_GUID_FormURN>和<Modification_GUID_Name>Name of Modification</Modification_GUID_Name>
URN的获得-打开Infopath表单-转到编辑状态(Tools-Design This Form)-在设计窗口中点击File-Properties-拷贝ID里的文本内容。

5.拷贝所有用到的Infopath表单到项目文件的~\DeploymentFiles\FeatureFiles内。

6.自动发布工作流到MOSS则修改PostBuildActions.bat文件内的所有http://localhost为正确的地址后,Build一下工程文件则工作流发布成功。也可以手动发布,如下。

手动安装MOSS工作流:
1.拷贝dll文件到GAC中,在C:\WINDOWS\assembly里面或Start-Administrative Tools-Microsoft .Net Framework 2.0 Configuration
2.拷贝项目文件的~\DeploymentFiles\FeatureFiles内的配置文件和表单文件到C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\内。
3.可以先验证一下表单,执行C:\Program Files\Microsoft Visual Studio 8\VC>"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\STSADM.EXE" -o verifyformtemplate -filename  "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\
TEMPLATE\FEATURES\SequentialWorkflow\testTmpl.xsn"
再执行
C:\Program Files\Microsoft Visual Studio 8\VC>"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\STSADM.EXE" -o installfeature  -filename "SequentialWorkflow\feature.xml" -force
再执行
C:\Program Files\Microsoft Visual Studio 8\VC>"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\STSADM.EXE" -o activatefeature -filename "SequentialWorkflow\feature.xml" -url http://localhost:9091
4.此时“网站设置>网站功能”内能看到工作流且已激活。“Central Administration > Application Management > Manage Form Templates”内能看到Infopath表单且Status为Ready,Workflow Enabled为yes
5.执行iisreset
6.显示工作流表单时,如果出现以下问题:“The form cannot be displayed because the session state is not available”或“该表单无法显示,因为会话状态不可用”
解决方法:在网站的web.config中的httpmodules一节增加<add name="Session" type="System.Web.SessionState.SessionStateModule"/>


手动卸载MOSS工作流:
1.停用“~>网站设置>网站功能”内的相应工作流
可先执行C:\Program Files\Microsoft Visual Studio 8\VC>"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\STSADM.EXE" -o deactivatefeature -filename "SequentialWorkflow\feature.xml" -url http://localhost:9091
再执行
C:\Program Files\Microsoft Visual Studio 8\VC>"C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\STSADM.EXE" -o uninstallfeature  -filename "SequentialWorkflow\feature.xml"
2.此时“Central Administration>Application Management>Manage Form Templates”内的Infopath模版也已经卸载掉。
3.卸载“C:\WINDOWS\assembly”内的dll
4.删除“C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\”内的相应文件。

(4)
WebPart开发:
1.要在WebPart工程的AssemblyInfo.cs文件中添加“[assembly: System.Security.AllowPartiallyTrustedCallers()]”,以便在MOSS中能正确使用此WebPart。
把WebPart编译后的.dll文件放到C:\Inetpub\wwwroot\wss\VirtualDirectories\9091\bin里面或放到GAC即C:\WINDOWS\assembly里面。

2.把UserControl的.ascx文件可放到任意地方如C:\Inetpub\wwwroot\wss\VirtualDirectories\9091\bin,如果UserControl的C#的代码没有放到.ascx文件里,而是采用的后置代码形式,则应该将编译后的UserControl的.dll文件也放到MOSS站点中。

如果UserControl建立在ASP.NET Web Site工程里,则通过右键工程选“Publish Web Site”-勾选“Allow this precomplied site to be updatable”和“Use fixed naming and single page assemblies”-点“OK”,将发布得到的.dll文件放到C:\Inetpub\wwwroot\wss\VirtualDirectories\9091\_app_bin里面。.ascx文件可放到任意地方。

如果UserControl建立在ASP.NET Web Application工程里,则通过编译工程后在Bin目录中得到的.dll文件,将其放到C:\Inetpub\wwwroot\wss\VirtualDirectories\9091\bin里面。.ascx文件可放到任意地方。

3.为了添加WebPart到MOSS站点,在C:\Inetpub\wwwroot\wss\VirtualDirectories\9091中的web.config文件中的<SafeControls>里面添加一句<SafeControl Assembly="HRManagementWP" Namespace="HRManagementWP" TypeName="*" Safe="True" />

为了使MOSS有权限访问C:\Inetpub\wwwroot\wss\VirtualDirectories\9091\bin目录中的UserControl的.dll等文件,把<trust level="WSS_Minimal" originUrl="" />修改为<trust level="Full" originUrl="" />



(5)
Microsoft® Visual Studio® 2005 Team Suite Service Pack 1
在开始SP1更新前,假如你在你系统上安装了那个单独的VS 2005 Web应用项目的话,确认你将它卸载了。你不再需要它了,因为它的支持是内置于SP1中的,假如你安装了它的话,SP1安装程序会停止,让你将它卸载了才会继续下去。你现有的web应用项目文件还会继续工作,所以你对它们不需要做什么更新。
http://www.microsoft.com/downloads/details.aspx?FamilyId=BB4A75AB-E2D4-4C96-B39D-37BAF6B5B1DC&displaylang=en
安装vs05 sp1时遇到“Error 1718. File was rejected by digital signature policy”错误的解决办法:
http://support.microsoft.com/kb/925336/zh-cn


Visual Studio 2005 Web 应用程序项目
http://msdn2.microsoft.com/zh-cn/asp.net/Aa336618.aspx
为了在 Visual Studio 2005 中完全启用 Web 应用程序项目,必须首先安装 Microsoft Visual Studio 2005 – 更新到支持 Web 应用程序项目(Microsoft Visual Studio 2005 - Update to Support Web Application Projects),然后再安装此外接程序。

Microsoft Visual Studio 2005 - Update to Support Web Application Projects
http://www.microsoft.com/downloads/details.aspx?familyid=8B05EE00-9554-4733-8725-3CA89DD9BFCA&displaylang=en



Windows SharePoint Services 3.0
http://www.microsoft.com/downloads/details.aspx?FamilyId=D51730B5-48FC-4CA2-B454-8DC2CAF93951&displaylang=en

Windows SharePoint Services 3.0: Software Development Kit (SDK):
http://www.microsoft.com/downloads/details.aspx?familyid=05E0DD12-8394-402B-8936-A07FE8AFAFFD&displaylang=en


Windows SharePoint Services 3.0 Tools: Visual Studio 2005 Extensions:
http://www.microsoft.com/downloads/details.aspx?familyid=19f21e5e-b715-4f0c-b959-8c6dcbdc1057&displaylang=en

Visual Studio 2005 extensions for .NET Framework 3.0 (Windows Workflow Foundation):
http://www.microsoft.com/downloads/details.aspx?familyid=5D61409E-1FA3-48CF-8023-E8F38E709BA6&displaylang=en

SharePoint Server 2007 SDK: Software Development Kit
http://www.microsoft.com/downloads/details.aspx?familyid=6d94e307-67d9-41ac-b2d6-0074d6286fa9&displaylang=en


Microsoft? Windows? Workflow Foundation Runtime Components Beta 2.2 and Visual Studio? 2005 Extensions for Windows Workflow Foundation Beta 2.2:
http://www.microsoft.com/downloads/details.aspx?familyid=5c080096-f3a0-4ce4-8830-1489d0215877&displaylang=en#filelist

2007 Office System Starter Kit: Enterprise Content Management Starter Kit:
http://www.microsoft.com/downloads/details.aspx?FamilyID=38ca6b32-44be-4489-8526-f09c57cd13a5&displaylang=en

Windows SharePoint Services 3.0 Starter Kit: Workflow Developer Starter Kit for Windows SharePoint Services 3.0:
http://www.microsoft.com/downloads/details.aspx?familyid=5DDF902D-95B1-4640-B9E4-45440DC388D9&displaylang=en

Windows SharePoint Services 3.0 Application Templates: All Templates
http://www.microsoft.com/downloads/details.aspx?familyid=5807b5ef-57a1-47cb-8666-78c1363f127d&displaylang=en&tm

Application Templates for Windows SharePoint Services 3.0
http://www.microsoft.com/technet/windowsserver/sharepoint/wssapps/templates/default.mspx

SharePoint Products and Technologies Templates: Web Part Templates for Visual Studio .NET (好像用于VS2003):
http://www.microsoft.com/downloads/details.aspx?FamilyID=cac3e0d2-bec1-494c-a74e-75936b88e3b5&DisplayLang=en



海洋工作室:
http://www.oceanstudio.net/default.aspx
海洋邮箱:
v-haiju@microsoft.com

Erucy's blog
http://blog.joycode.com/erucy/  

陈老师博客:
http://blog.joycode.com/choral/  

11大哥博客:
http://sps.dnngo.com/Blog/default.aspx

兰竹菊梅博客:
http://www.cnblogs.com/foundation/articles/515615.html

彦斌博客:
http://blog.sina.com.cn/s/blog_4925e2f901000ati.html  用loadcontrol的方式来加载webpart
http://blog.sina.com.cn/s/blog_4925e2f901000a23.html  Moss2007搜集来的资料

Andrew Connell博客:
http://www.andrewconnell.com/blog/articles/MossWcmResources.aspx#MasterPagesPageLayouts

 

Office中文官网
http://office.microsoft.com/zh-cn/2007/FX100649542052.aspx?ofcresset=1
Office英文官网
http://office.microsoft.com/en-us/FX100647101033.aspx?pid=CL100569831033

Visual Studio 2005 Tools for Office Second Edition视频教程:
http://msdn2.microsoft.com/en-us/office/aa905543.aspx

2007 Office System Video: Enterprise Content Management:
http://www.microsoft.com/downloads/details.aspx?familyid=562b9b75-55b7-4f5d-afe4-1f78c8b7fc6d&displaylang=en#filelist

如何最方便的创建SharePoint解决方案包:
http://blog.joycode.com/choral/archive/2007/06/15/104276.aspx

SharePoint 2003 + VS2003 WebPart 开发
http://www.devx.com/dotnet/Article/17518

Using Visual Studio 2005, MakeCab.exe and MSBuild to Create Window SharePoint Services v3 Solution Files (*.WSP's)
http://www.andrewconnell.com/blog/articles/UsingVisualStudioAndMsBuildToCreateWssSolutions.aspx

模板:SharePoint2007解决方案包
http://blog.joycode.com/choral/archive/2007/01/17/91647.aspx

SharePoint2007 Solution Generator
http://weblogs.asp.net/soever/archive/2006/11/11/SharePoint-Solution-Generator-_2D00_-part-1_3A00_-create-a-site-definition-from-an-existing-site.aspx

Visual Studio 2005 extensions for Windows SharePoint Services 3.0 图解
http://blog.joycode.com/choral/archive/2006/11/17/86698.aspx

SharePoint Developer Explorer - Visual Studio Add-in
http://blog.thekid.me.uk/archive/2007/10/15/sharepoint-developer-explorer-visual-studio-add-in.aspx

“增补\For IT Professionals\Office\SharePoint Portal Server 2003\SharePoint Portal Server 2003 WebPart 开发msft021506vxpm.zip”
在vs2003下开发SharePoint2003时候,制作和使用Webpar的.cab安装包。开发Webpart时怎样调试。

 

MOSS 解决方案包WSP:
http://www.cnblogs.com/wanghao-3/archive/2007/07/12/815563.html

一步一步SharePoint 2007:
http://www.winos.cn/forum/viewthread.php?tid=5397

SharePoint 2003安装步骤
http://www.cnblogs.com/payche/archive/2007/04/27/729653.html
http://www.cnblogs.com/applengine/archive/2006/01/19/320266.aspx
http://blog.donews.com/ynzf/archive/2006/09/27/1048182.aspx

让用户控件包装器“见鬼”去:
http://www.cnblogs.com/wanghao-3/archive/2007/08/13/853207.html

SharePoint WebPart开发实战(一):定制属性及配置界面:
http://blog.csdn.net/jackjoy/archive/2007/08/05/1727745.aspx

QuickPart:
http://www.codeplex.com/quickpart
http://blog.joycode.com/kaneboy/articles/89144.aspx

六步实现Sharepoint+QuickPart+Ajax
http://taglib.cn/story.php?title=%e5%85%ad%e6%ad%a5%e5%ae%9e%e7%8e%b0sharepointquickpartajax

UpdatePanel在Quickpart中的应用
http://jlj80.spaces.live.com/blog/cns!B14C4E651E0B0354!213.entry

SharePoint多级审批工作流开发文档[Sequential版] v1.1
http://www.cnblogs.com/xiaoshatian/archive/2007/09/03/657181.html

MOSS工作流开发+Email提醒:
http://www.cnblogs.com/wanghao-3/archive/2007/06/26/795844.html

针对开发人员的 Windows SharePoint Services V3 和 SharePoint Server 2007 工作流简介:
http://www.microsoft.com/china/MSDN/library/Office/sharepoint/ms406057.mspx?mfr=true

Office SharePoint Server2007开发入门指南
http://book.csdn.net/bookfiles/476/10047616654.shtml

Visual Studio.net 2005 新建项目对话框中项目模版消失的解决方案:
http://www.cnblogs.com/xiaoshatian/archive/2006/12/14/592464.html


MOSS工作流开发入门学习:
http://www.cnblogs.com/wanghao-3/archive/2007/06/28/799238.html
因为Windows SharePoint Services和用户通过Web浏览器通讯,所以它依靠ASP.NET显示表单。这些表单被定义为ASPX页面。一个Windows SharePoint Services的工作流可以在流程生命周期中的4个地方显示自己的表单:

n      关联:When a Windows SharePoint Services administrator associates a workflow template with a particular document library or list, he might be able to set options that will apply to every workflow instance created from this association. If a workflow author chooses to allow this, she must provide a form that lets the administrator specify this information.

n      初始化:: The initiator of a workflow might be allowed to specify options when he starts a running instance. In the approval scenario just described, for instance, the options included specifying the list of workflow participants and defining how long each one had to complete his or her task. If a workflow allows this, its author must provide a form to allow the initiator to set these options, as shown in step 3 of the previous diagram.

n      完成任务:Task Completion: The running workflow instance must display a form to the participants in the workflow to let them complete their task. Shown in step 6 in the previous diagram, this form is what allowed the approvers in the earlier scenario to make comments on the document and indicate their approval or rejection.

n      修改任务:Modification: Although it wasn’t shown in the scenario above, the creator of a workflow can allow it to be modified while it’s running. For example, a workflow might allow adding new participants after it’s begun executing or extending the due date for completing tasks. If this option is used, the workflow must display a form at this point to let a participant specify what changes should be made.

 

WF’s Base Activity Library provides a group of fundamental activities, as described earlier. Windows SharePoint Services also provides a set of activities designed expressly for creating Windows SharePoint Services workflows. Among the most important of these are the following:

n      OnWorkflowActivated: provides a standard starting point for a Windows SharePoint Services workflow. Among other things, this activity can accept information supplied by a Windows SharePoint Services administrator via the Association form when the workflow is associated with a document library or list. It can also accept information supplied via the Initiation form when the workflow is started. Every Windows SharePoint Services workflow must begin with this activity.

n      CreateTask: creates a task assigned to a particular user in a task list. For example, the approval workflow in the scenario described earlier used this activity to add a task to the task list used by each of the participants. This activity also has a SendEmailNotification property that, when set to true, automatically sends an email message to the person for whom this task was created.

n      OnTaskChanged: accepts information from the Task Completion form. The approval workflow in the earlier scenario used this activity to accept the input of each participant when the document was approved.

n      CompleteTask: marks a task as completed.

n      DeleteTask: removes a task from a task list.

n      OnWorkflowModified: accepts information from the Modification form, which can then be used to change how this instance of the workflow behaves. If the workflow’s creator chooses not to include any instances of this activity in the workflow, that workflow cannot be modified while it’s running.

n      SendEmail: sends email to a specified person or group of people.

n      LogToHistoryList: writes information about the workflow’s execution to a history list. The information in this list is used to let users see where a workflow is in its execution, look at the workflow’s history after it’s completed, and more. To allow this kind of monitoring, the workflow’s author must write information to a History list at appropriate points in the workflow’s execution. Because it provides its own mechanism for tracking workflows, Windows SharePoint Services doesn’t support WF’s standard tracking service.

A typical pattern for a simple Windows SharePoint Services workflow begins with an OnWorkflowActivated activity, then uses a CreateTask activity to assign a task to a participant in the workflow. The BAL’s standard While activity might then be used to wait until the user completes the task. To learn when this has happened (perhaps the user makes multiple changes to the task, then checks a box on the Task Completion form when she’s done), an OnTaskChanged activity executes within the While, extracting whatever information the user has entered on that form. When the user has completed the task, a CompleteTask activity might execute, followed by a DeleteTask. The workflow can then go on to the next participant, using CreateTask to assign a task to him, and so on. And of course, other things can occur, such as sending email, logging information to the history list, or even including the BAL’s Code activity, which allows running arbitrary code.

 

(5)
40 Template Install:
*********************************************************

APPLICATION TEMPLATES FOR WINDOWS SHAREPOINT SERVICES 3.0

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


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

To install the Application Template Core solution:
=========================================================

C:\Documents and Settings\jqli.HSLCN>"C:\Program Files\Common Files\Microsoft Sh
ared\web server extensions\12\BIN\STSADM.EXE" -o addsolution -filename "C:\Docum
ents and Settings\jqli.HSLCN\Desktop\New Folder\ApplicationTemplateCore.wsp"

Operation completed successfully.


C:\Documents and Settings\jqli.HSLCN>"C:\Program Files\Common Files\Microsoft Sh
ared\web server extensions\12\BIN\STSADM.EXE" -o deploysolution -name "Applicati
onTemplateCore.wsp" -allowgacdeployment -immediate

Timer job successfully created.

Please specify either '-immediate' or '-local' or '-time' parameter.

C:\Documents and Settings\jqli.HSLCN>"C:\Program Files\Common Files\Microsoft Sh
ared\web server extensions\12\BIN\STSADM.EXE" -o copyappbincontent

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

To install an Application Template:
=========================================================

C:\Documents and Settings\jqli.HSLCN>"C:\Program Files\Common Files\Microsoft Sh
ared\web server extensions\12\BIN\STSADM.EXE" -o addsolution -filename "C:\Docum
ents and Settings\jqli.HSLCN\Desktop\New Folder\RoomEquipmentReservations.wsp"

Operation completed successfully.


C:\Documents and Settings\jqli.HSLCN>"C:\Program Files\Common Files\Microsoft Sh
ared\web server extensions\12\BIN\STSADM.EXE" -o deploysolution -name "RoomEquip
mentReservations.wsp" -allowgacdeployment -immediate

Timer job successfully created.


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

Instructions for use:
=========================================================

1. Log into your SharePoint site as the site
   Administrator.
2. From the Site Actions drop-down menu in the top right,
   select Site Settings.
3. Under the Site Administration section, select Sites
   and Workspaces.
4. Select Create to create a new site using a site
   template.
5. Complete the new SharePoint site information. In the
   Template Selection section, select the Application
   Templates tab. All deployed Application Template will
   be listed in this tab.
6. Select the template to use for this site and click
   Create.
7. A site has now been created using the application
   template.

 

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

APPLICATION TEMPLATES FOR WINDOWS SHAREPOINT SERVICES 3.0

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


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

To install this download:
=========================================================

4. Log into your SharePoint site as the site Administrator.
5. From the Site Actions drop-down menu in the top right,
   select Site Settings.
6. Under the Galleries section, select Site templates.
7. Select Upload to load an application template into this
   SharePoint site.
8. Browse to the <template_name>.stp file from the distribution
   and select Open. If you have several application templates
   to load into your site, you can use the Upload Multiple
   Files?option to load them all at once.

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

Instructions for use:
=========================================================

1. Log into your SharePoint site as the site Administrator.
2. From the Site Actions drop-down menu in the top right,
   select Site Settings.
3. Under the Site Administration section, select Sites and
   Workspaces.
4. Select Create to create a new site using a site template.
5. Complete the new SharePoint site information. In the
   Template Selection section, select the Custom tab. Any
   application templates that have been uploaded will be
   listed here.
6. Select the template to use for this site and click Create. 

WebPart开发: 
Anonymous Personalization Trick in Web Parts:
http://www.codeproject.com/aspnet/anonywebparts.asp

 

SharePoint2003开发: 

1)SharePoint2003开发调试:
Debug-Processes-双击w3wp.exe-选择"Common Language Runtime" and "Script" 即可开始调试。不用修改根目录下的web.config。

2)SharePoint2003某个站点的备份
smigrate.exe -w http://msatwork/ -u redmond\mcwservp -f e:\MSATWORKProd.fwp -y
SharePoint2003某个站点的恢复
smigrate.exe -r -w http://%3c%3cwebserver%3e%3e/servicesprojects -u fareast\v-jasl -f C:\CMS_BACKUP\CMSSite.fwp

3)部署WebPart的dll到SharePoint2003时,不强签名也可以部署。

部署自定义站点到SharePoint站点时候,要先在IIS上欲创建SharePoint站点的IIS站点下部署好自定义的虚拟目录,之后再在IIS上创建SharePoint站点才能使自定义站点能正常访问。

4)部署Webpart时候出现下面的问题:
Request for the permission of type 'Microsoft.SharePoint.Security.SharePointPermission,

Microsoft.SharePoint.Security, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' failed.

By default WSS/MOSS is configured with a security policy called WSS_Minimal.  This policy definition doesn't

grant access to the SP object model. 

The simplest approach to enable access is to modify the web.config file in the virtual directory root for

your site and change the following tag
<trust level="WSS_Minimal" originUrl="" />
to
<trust level="WSS_Medium" originUrl="" />
The difference between Minimal and Medium is the addition of SharePoint object-model access and access to the NT event log.

也可修改到<trust level="full" originUrl="" />

http://msdn.microsoft.com/zh-cn/library/dd583158(en-us).aspx


Mobile开发: 
Windows Mobile Developer Power Toys:
http://www.microsoft.com/downloads/details.aspx?FamilyID=74473FD6-1DCC-47AA-AB28-6A2B006EDFE9&displaylang=en#filelist


Office开发: 
1)
Microsoft Visual Studio Tools for the Microsoft Office system (version 3.0 Runtime) (x86)。运行使用 Microsoft Visual Studio 2008 生成的面向 2007 Microsoft Office system 的 VSTO 解决方案时需要该库。
http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=54eb3a5a-0e52-40f9-a2d1-eecd7a092dcb


Microsoft Visual Studio 2005 Tools for the 2007 Microsoft Office System (also known as “Visual Studio 2005 Tools for Office Second Edition” or “VSTO 2005 SE”),这个不同于Microsoft Visual Studio 2005 Tools for Office Second Edition Runtime (VSTO 2005 SE) (x86),这个要装完vs2005才能装,应该是vs2005的项目板。这个是安装在vs2005上而不是vs2003上,好像没有安装在vs2003上的软件。安后会在vs2005上有office2003和office2007的模板:
http://www.microsoft.com/downloads/details.aspx?familyid=5e86cab3-6fd6-4955-b979-e1676db6b3cb&displaylang=en

Microsoft Visual Studio 2005 Tools for Office Second Edition Runtime (VSTO 2005 SE) (x86)。这个是给用vs2005开发的office软件安装时提供运行时环境,不用安装vs2005就可以安装。
Microsoft Visual Studio 2005 Tools for Office Second Edition Runtime (build 8.0.50272.940) (x86) 是VSTO 2005 SE的build版本。

http://www.microsoft.com/downloads/details.aspx?familyid=F5539A90-DC41-4792-8EF8-F4DE62FF1E81&displaylang=en

2)
在 Visual Studio 中创建 Office 解决方案
http://msdn2.microsoft.com/zh-cn/library/3295w01c(VS.80).aspx
Visual Studio Tools for Office 项目模板概述
http://msdn2.microsoft.com/zh-cn/library/8553caee(VS.80).aspx
产品组合可用的功能
http://msdn2.microsoft.com/zh-cn/library/aa942839(VS.80).aspx
Office 解决方案开发概述
http://msdn2.microsoft.com/zh-cn/library/hy7c6z9k(VS.80).aspx


3)命名空间Microsoft.Office.Interop.Word不存在的解决办法:
首先确保.NET Programmability Support(.net可编程支持)已经安装。如未安装则,再次运行office安装
程序,选择“添加或删除组件”,->勾选“高级自定义应用程序”,->展开特定于应用程序的节点。例如,要获取 Microsoft Office word 2003 PIA,请展开 Microsoft Office word 节点并选择 .NET Programmability Support(.net可编程支持)。单击 .NET Programmability Support (.net可编程支持)旁边的下拉箭头以选择更新选项,并选取 Run from My Computer(从本机运行)。然后点击“更新”按钮

在VS2005中右键项目->添加引用->COM->
Microsoft Office 11.0 object Library
Microsoft Word XX.X Object Library

(4)

using Excel = Microsoft.Office.Interop.Excel;报错。
添加COM引用,包括:Microsoft.Excel.x.0.Object.Library,Microsoft.Office.x.0.Object.Library

建议安装正版OFFICE,而且版本在11.0以上(Office2003以上),引用以上两个Com后,在项目引用栏发现多了Excel、Microsoft.Office.Core,VBIDE三个 Library.

Office 2003 应用程序或组件 主 Interop 程序集名 主 Interop 程序集命名空间
Microsoft Office 11.0 Object Library Office.dll Microsoft.Office.Core
Microsoft Excel 11.0 Object Library Microsoft.Office.Interop.Excel.dll Microsoft.Office.Interop.Excel
Microsoft Word 11.0 Object Library Microsoft.Office.Interop.Word.dll Microsoft.Office.Interop.Word

 (5)

Object reference not set to an instance of an object.

The problem is in first line of your code snippet at:
ApplicationClass ex = null; 
You should try to modify it in style:
ApplicationClass ex = new ApplicationClass();
Or use:
Excel.Application xlApp = new Excel.Application();

(6)Old format or invalid type library. (Exception from HRESULT: 0x80028018 (TYPE_E_INVDATAREAD))

http://social.msdn.microsoft.com/Forums/en-US/Vsexpressvb/thread/4565361b-aeff-4d01-af92-d21a6eb631e3

http://msdn.microsoft.com/en-us/library/aa168494(office.11).aspx

Infopath开发: 
1)打开工程时如果提示安装the application for the project type .ipproj则需要安装下面的插件:

对于Visual Studio 2003 + InfoPath 2003:
首先安装Office 2003 Service Pack 1:
http://www.microsoft.com/downloads/details.aspx?familyid=9C51D3A6-7CB1-4F61-837E-5F938254FC47&displaylang=en

之后安装InfoPath 2003 Toolkit for Visual Studio .NET 可使Visual Studio .NET 2003开发Infopath:
http://www.microsoft.com/downloads/details.aspx?familyid=7e9ebc57-e115-4cac-9986-a712e22879bb&displaylang=en

如果不能打开Infopath工程,请去掉manifest.xsf文件的只读属性。

2)http://www.infopathdev.com/
http://blogs.msdn.com/infopath/default.aspx

3)教程:
http://office.microsoft.com/en-us/infopath/CH011619191033.aspx
http://office.microsoft.com/en-us/training/CR061832771033.aspx
http://office.microsoft.com/en-us/infopath/CH100740821033.aspx

http://office.microsoft.com/en-us/word/CH100740901033.aspx
http://office.microsoft.com/en-us/outlook/CH100740861033.aspx

Office 2007 Partner Technical Readiness Training Presentations
http://www.microsoft.com/downloads/details.aspx?FamilyID=5cb386ff-1b77-4adc-a42f-f5ea375e4ed1&DisplayLang=en

http://channel9.msdn.com/posts/scobleizer/Eric-Richards-and-Team-First-look-at-InfoPath-12/

Submitting Forms in InfoPath 2003:
http://msdn.microsoft.com/en-us/library/aa168465.aspx

SolutionBase: Building database-integrated forms with InfoPath 2003
http://articles.techrepublic.com.com/5100-22_11-5618641.html

InfoPath and OneNote: New Office applications on the block
http://articles.techrepublic.com.com/5100-10878_11-5035197.html

4)创建级联列表框:
http://office.microsoft.com/zh-cn/infopath/HA011177132052.aspx

其次:通过Infopath的菜单 "工具 "--> "编程 "或者控件的属性,可以添加自定义代码
通过infopath菜单 "工具 "--> "选项 "--> "设计 "可以指定编程语言是C#或者VB

5)
Visual Studio Debugging: "Unable to Attach to Application" Error

If you have installed an application that uses .NET Framework 2.0, you might suddenly find that you can no longer debug your managed code InfoPath forms. This can be very frustrating, but is easily fixed with the following steps:

  1. Shut down Visual Studio.
  2. Open Notepad and copy the following XML into it:

<configuration>
    <startup>
        <requiredRuntime imageVersion="v1.1.4322" version="v1.1.4322" />
        <supportedRuntime version="v1.1.4322" />
    </startup>
</configuration>

  1. Save the file to the same folder as the InfoPath application as InfoPath.exe.config.

The default folder is C:\Program Files\Microsoft Office\OFFICE11.

  1. Launch Visual Studio, open an InfoPath project, and run the debugger.

The file you just created directs InfoPath to run in the context of .NET Framework 1.1 instead of 2.0.
http://www.infopathdev.com/blogs/greg/archive/2005/03/29/Visual-Studio-Debugging_3A00_-_2200_Unable-to-Attach-to-Application_2200_-Error.aspx

I had the same problem too. The problem was that Excel was loading the .Net 2.0 framework which the VS 2003 debugger couldn’t handle. I solved the problem by instructing Excel to load the .Net 1.1 framework instead of the 2.0. This can be achieved by creating in the directory where the EXCEL.EXE file resides a file named EXCEL.EXE.config with the following content.

<?xml version ="1.0"?>
<configuration>
    <startup>
       <supportedRuntime version="v1.1.4322" /> 
    </startup>
</configuration>
Another possible solution is to use the debugger for .Net 2.0 that comes with the .NET 2.0 SDK which can be downloaded from the Microsoft website for free. This debugger is very similar to the VS debugger except that it is not integrated to a development environment.

 

6)

用“XML架构定义工具(Xsd.exe)”将Infopath的schema转换为数据类,即将XML文件Mapping成代码类:
调出Visual Studio .NET 2003 Command Prompt窗口,在此窗口中可以直接使用xsd.exe。可以cd到Infopath的myschema.xsd文件所在的目录再使用xsd.exe,如E:\Dev\CMS Clients\InfoPath\Microsoft.ContractManagement\InfoPathForms\Contract>xsd.exe myschema.xsd /c

注意:转换时要关掉打开的Infopath表单。

其中,myschema.xsd是infopath自己产生的数据定义文件。如果你直接使用infopath设计一个form,你是找不到这个文件的,只能看到一个xsn文件。这个xsn实际是一组文件打包后的安装文件。你把xsn后缀改为cab后,可以用winzip打开它。这时你就会看到 myschema.xsd了。

如果在VS2005下使用此命令则先调出Visual Studio .NET 2005 Command Prompt窗口,然后在此窗口中使用下面的命令:

XSD /classes /language:C# "E:\myschema.xsd" /outputdir:"E:\XSD" /namespace:a.b.c


XML架构定义工具(Xsd.exe):
http://msdn.microsoft.com/zh-cn/x6c1kb0s(vs.80).aspx
http://msdn.microsoft.com/zh-cn/x6c1kb0s.aspx

7)访问Infopath的XML数据:
http://hi.baidu.com/gatse/blog/item/4d6396540dd4021a3b293549.html
用代码访问InfoPath表单内容
http://www.cnblogs.com/linken/archive/2008/05/08/1188430.html

 

7)

Infopath表单在重复表中用代码动态生成3行

    // The following function handler is created by Microsoft Office InfoPath. Do not
    
// modify the type or number of arguments.
    [InfoPathEventHandler(EventType = InfoPathEventType.OnLoad)]
    
public void OnLoad(DocReturnEvent e)
    {
        
//Write your code here.
        for (int i = 0; i < 2; i++)
        {
            IXMLDOMNode objNode 
= thisXDocument.DOM.selectSingleNode("/my:myFields/my:group1/my:group2");
            IXMLDOMNode objInsertNode 
= objNode.cloneNode(true);
            objInsertNode.selectSingleNode(
"/my:field1").text = "abc";
            thisXDocument.DOM.selectSingleNode(
"/my:myFields/my:group1").appendChild(objInsertNode);
        }
    }

 

8)怎样得到dll的路径:

 

            //获得当前被执行的dll的绝对路径。
            string aa = System.Reflection.Assembly.GetExecutingAssembly().Location;
            
//获得指定dll的绝对路径。
            string bb = System.Reflection.Assembly.GetAssembly(typeof (MyDllFile)).Location;
            
//获得dll所在的文件夹。
            string cc = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
            
//获得dll所在的文件夹的上一级文件夹。System.IO.Path.DirectorySeparatorChar代表目录分隔符如“\”。
            string dd = cc.Substring(0, cc.LastIndexOf(System.IO.Path.DirectorySeparatorChar) + 1);

 

9)对域用户或域组的一些操作:

 

        //advapi32.dll是一个高级API应用程序接口服务库的一部分。现在导入它的两个函数。
        [DllImport("advapi32.dll")]
        
public extern static bool CheckTokenMembership(IntPtr TokenHandle, IntPtr SidToCheck, out bool IsMember);
        [DllImport(
"advapi32.dll")]
        
public static extern bool ConvertStringSidToSid(string StringSid, out IntPtr Sid);

        
public static void JudgeIsMember()
        {
            
//The groups to which a user belongs are stored by Windows, but the actual
            
// group name is only cached temporarily until the space is needed for something else. As a result, Windows 'forgets' group names
            
// for users who tend to be disconnected from CorpNet for several weeks at a time, meaning that a security check by group name
            
// will fail. Windows does, however, remember the SID for allowed groups permanently. As a result, we have to store the SIDs
            
// here, and check membership based on the SID itself rather than the group name.
            
//将字符串转换成SID。SID是域用户或域组的唯一标识。
            ConvertStringSidToSid("S-1-5-21-124525095-708259637-1543119021-562509"out sid);
            
//判断当前用户是否是sid域组的成员。IntPtr.Zero表示当前用户。
            CheckTokenMembership(IntPtr.Zero, sid, out isMember);
        }

 

            //得到当前域用户的标识
            System.Security.Principal.WindowsIdentity identity = System.Security.Principal.WindowsIdentity.GetCurrent();
            
//标识的主体,也就是标识及其附加信息。
            System.Security.Principal.WindowsPrincipal principal = new System.Security.Principal.WindowsPrincipal(identity);

 

10)

怎样在Infopath后置代码中load普通的XML文件:

http://msdn.microsoft.com/zh-cn/library/aa948640.aspx

使用 InfoPath 2003 对象模型的表单模板项目在内部采用 Microsoft XML Core Services (MSXML) 5.0 for Microsoft Office 来处理 XML。

在托管代码中,使用由 .NET Framework 类库中的 System.Xml 命名空间所提供的 XML 支持通常更加容易。

由于性质决定,MSXML 和 System.Xml 不能交换对象,因此当需要在 InfoPath 与其他托管代码之间传递 XML 数据时,需要转换 XML 数据。

下面的方法可以将 System.Xml 对象中的 XML 数据与 InfoPath 表单代码进行交换。

 

可下载安装“Microsoft XML Core Services (MSXML) SDK”来查询类、属性、方法的解释。下面是MSXML 4.0 SP2 和 SDK:

http://www.microsoft.com/downloads/details.aspx?displaylang=zh-cn&FamilyID=3144b72b-b4f2-46da-b4b6-c5d7485f2b42

 

        //Here is the code to load the xml file, 
        
//filePath is the XML file name or path of where it is available.
        
//namespaces is the namespace of your file. If you do not have any namespace then pass the empty string.
        private IXMLDOMDocument2 LoadXmlDocument(string filePath, string namespaces)
        {
            IXMLDOMDocument2 xmlDocument 
= (IXMLDOMDocument2)thisXDocument.CreateDOM();
            xmlDocument.async 
= false;
            xmlDocument.validateOnParse 
= false;
            xmlDocument.load(filePath);
            xmlDocument.setProperty(
"SelectionNamespaces", namespaces);
            
return xmlDocument;
        }

 

12)

怎样给Infopath form template以Full Trust权限,如果打开表单时有System.Security.SecurityException异常。
The form template must:
1.be installed and registered
2.or digitally signed with a trusted certificate

 

http://support.microsoft.com/kb/832512
To work around this problem in your InfoPath form, use either of the following methods:
一.Make the form a fully-trusted URN-based form.
二.Add the URL of the server that hosts the InfoPath form to the list of trusted sites in Microsoft Internet Explorer.
三.Digitally sign a form template. (Apply for InfoPath)

 

一.Make the form a fully-trusted URN-based form
The following command line produces a .js file and a .bak file in the same folder as the template that you are converting。The .bak file is a copy of the original form template file before the URN-based changes. The .js file is a script file that you can use to install the URN-based form:
regform /U urn:MyForm:MyCompany /T Yes C:\MyForms\MyTrustedForm.xsn

 

The /U switch specifies the URN to use for the form template. The /T switch specifies that the form template is fully trusted. This sets the requireFullTrust attribute in the form definition (.xsf) file to Yes.

 

二.Add the URL of the server that hosts the InfoPath form to the list of trusted sites in Microsoft Internet Explorer
When you add the URL of the server that hosts the InfoPath form as a trusted site, you receive the following message when you run the code:
“An ActiveX control on this page might be unsafe to interact with other parts of this page. Do you want to allow this interaction?”
If you click Yes, the code runs.

 

To add a site as a trusted site, follow these steps:
1. Start Internet Explorer.
2. On the Tools menu, click Internet Options.
3. In the Internet Options dialog box, click the Security tab.
4. On the Security tab, click Trusted sites.
5. Click Sites. Add the URL of the server that hosts the InfoPath form to the Add this Web site to the zone text box.
6. For example, if the name of the server that hosts the InfoPath form is MyServer, the URL that you must add to the text box is http://myserver/. Click Add.
7. This adds the newly-entered site to the Web sites list box. Click OK two times.
8. This commits the change and then closes the dialog box.

 

三.Digitally sign a form template
This applies to InfoPath 2003 Service Pack 1. If you digitally sign a form template with a trusted certificate, you can set the security level for the form template to Full Trust. Full Trust means that the form can access files and settings on the user's computer or on a different domain. Additionally, you can deploy and update that form template by sending the form template and updated versions of the form template to others by using an e-mail program.

 

To digitally sign a form with a trusted certificate, follow these steps:
1. In Design mode, click Form Options on the Tools menu.
2. In the Form Options dialog box, click the Security tab in InfoPath 2003 or click to select the Security and Trust check box in InfoPath 2007.
3. Under Form Signing in InfoPath 2003, click to select the Sign this form check box.
Under Form Template Signature in InfoPath 2007, click to select the Sign this form template check box.
4. Click Select Certificate.
5. In the Select Certificate dialog box, click the certificate that you want to digitally sign the form with.
Note If a certificate is not trusted on a user's computer, Microsoft Office InfoPath 2003 displays a security message and requires the user to enable trust for the certificate issuer before the user can open the form.

 

InfoPath 2003 Software Development Kit (SDK)
http://www.microsoft.com/downloads/details.aspx?FamilyID=351f0616-93aa-4fe8-9238-d702f1bfbab4&displaylang=en

 

我们发布一个Infopath表单模板到Sharepoint表单库是非常简单的事情,但是当我们Infopath中包含自定义的代码的时候,就会发现发布到Sharepoint表单库后,表单中的自定义代码无法运行,通常会报一个没有权限的错误。
首先要得到infopath的urn,从文件->提取表单,就可以提取到表单的所有文件,或者将xsn改成cab,用rar解压缩也可以。得到的文件中有一个manifest.xsf,用记事本打开后从里面我们可以看到<xsf:xDocumentClass>该元素中的name属性便是这里我们用的urn名字,我这里得到的是“urn:schemas-microsoft-com:office:infopath:infopath:-myXSD-2005-11-05T12-31-24”。
运行testsave.js文件,直到显示注册成功。
这个时候,表单在本地就可以运行自定义代码了,但是当你发布到Sharepoint的时候,仍然会不可用,为了能够在Sharepoint中使用,我们需要对表单模板进行签名。从工具->表单选项->安全中进行签名,可以利用infopath直接创建一个证书,也可以使用CA颁发的证书。
然后就可以发布到Sharepoint表单库中了。当发布完毕后,如果你在制作Infopath的机器上直接填写表单,不会有任何问题。但是如果是其它机器从Sharepoint中填写表单,则会提示对话框。这是因为没有信任证书的原因,点击详细信息按钮,然后选择安装证书,直到安装证书成功。然后关闭infopath,再重新填写表单,就会发现复选框已经可以选择,选中复选框,然后选择打开。
另外再告诉大家一个价值5小时的经验,那就是在制作模板的时候不要把模板放在有中文名称的目录里面,否则运行regform的时候将会出错,报一个“System error”的错误。这个错误损耗掉了我至少5小时的时间。

 

regform.exe在E:\Program Files\Microsoft Office 2003 Developer Resources\Microsoft Office InfoPath 2003 SDK\Tools下面,它的使用实例如下:
C:\Documents and Settings\jason_li>"E:\Program Files\Microsoft Office 2003 Developer Resources\Microsoft Office InfoPath 2003 SDK\Tools\regform.exe" /U urn:schemas-microsoft-com:office:infopath:Contract-xsn:-myXSD-2004-12-15T23-15-19 /T Yes
 "C:\Documents and Settings\jason_li\Desktop\InfoPath\InfoPath\Microsoft.ContractManagement\InfoPathForms\Contract\bin\Debug\Contract.xsn"

 

如果想再生成个新的Contract.js,则需要将下面的两个同时删除:
Contract.bak
Contract.js
删除前一定要用Contract.js反安装当前的Contract.xsn文件否则只能通过删除注册表来实现反安装。删除下面的键值:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\11.0\InfoPath\SolutionsCatalog\urn:schemas-microsoft-com:office:infopath:Contract-xsn:-myXSD-2004-12-15T23-15-19
用Contract.js反安装Contract.xsn的写法如下:
C:\Documents and Settings\jason_li>"C:\Documents and Settings\jason_li\Desktop\InfoPath\InfoPath\Microsoft.ContractManagement\InfoPathForms\Contract\bin\Debug\Contract.js" "C:\Documents and Settings\jason_li\Desktop\InfoPath\InfoPath\Microsoft.ContractManagement\InfoPathForms\Contract\bin\Debug\Contract.xsn" /uninstall

 

13)

How debug Fully Trusted InfoPath Forms with Managed Code Business Logic:
为什么Debug时要求full trust?
When debugging, Focus will move to the line of code in the code editor that is calling the member that requires full trust,

and the following message will be displayed: "SecurityException was unhandled by user code - Request failed".
To allow the form template's business logic to call this member when it is being debugged or previewed, you must set your

form template's security level to Full Trust as described in the following procedure.

 

可以由vs直接调试
也可以在后置代码中加System.Diagnostics.Debugger.Break();来引起一个调试

 

为什么不能用regform.exe安装注册.xsn文件的办法实现Fully Trusted调试?
regform.exe会进行下面的操作(参见http://msdn.microsoft.com/en-us/library/aa662309(office.11).aspx的Manually Creating a Fully Trusted Form):

1.Add the following attributes to the xDocumentClass element in the manifest.xsf file:

requireFullTrust="yes"
name="urn:MyForm:MyCompany"

修改publishUrl=""
2.打开Template.xml文件,Remove the href attribute from the mso-infoPathSolution,加name attribute其值与.xsf file中相同。

3.Repackage the files into the .xsn CAB format with a tool such as makecab.exe.

4.Create a custom installation program by using the RegisterSolution method to install the fully trusted form.

If you need to remove a fully trusted form, you can use the UnregisterSolution method of the ExternalApplication object.

 

当按F5调试时,会将manifest.xsf和Template.xml文件重置并repackage。这就需reinsall这个Form Template。可以按照上面先修改manifest.xsf和Template.xml文件,再debug就能重置为修改时候的了,但是publishUrl=""不能保持为空,当编译后还是有路径,所以不能用regform.exe安装。

 

通过注册manifest.xsf文件(被注册到注册表的HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\11.0\InfoPath\SolutionsCatalog位置)实现Full Trust的debug:

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

第一种写法:

To create a JavaScript file that grants FullTrust permissions to form template

  1. In InfoPath Designer, on the Tools menu, and then click Form Options.

  2. Click Security.

  3. Clear the Automatically determine security level based on form's design (recommended) box.

    NoteNote:

    InfoPath cannot automatically detect business logic that requires full trust permissions so we must explicitly give full trust permissions.

  4. Select Full Trust, and then click OK.

  5. Close InfoPath Designer. Click Yes if asked to save changes.

  6. In Visual Studio, in Solution Explorer, double-click the manifest.xsf file to open it.

  7. In the root node, look for the publishUrl attribute and remove it along with its value.

  8. Save your changes.

  9. In Visual Studio .NET 2003, on the Build menu, click Build Solution.

  10. Open Notepad (or any other text editor).

  11. Add the following code to a blank text file.

        
    oApp = WScript.CreateObject("InfoPath.ExternalApplication");
    strAbsolutePath 
    = "project_folder_url\\manifest.xsf"
    oApp.RegisterSolution(strAbsolutePath,
    "overwrite");
    NoteNote:

    Do not forget to escape your path to your manifest.xsf. All \ in your path should be replaced with \\.

  12. Save this file on your computer as register.js

  13. Double-click the register.js file that you just created.

第二种写法:

1. make the form Fully Trusted
2. Open the manifest.xsf and remove the publishURL
3.写下面的代码:

'Sample courtesy of Jeff Webb
'
http://www.mcse.ms/archive180-2004-4-605806.html
set ip = CreateObject("InfoPath.Application")
'获得此脚本所在的文件夹
Set fso = CreateObject("Scripting.FileSystemObject")
pth 
= fso.GetFolder(".").path
ip.registersolution pth 
& "\manifest.xsf"
set ip = nothing
set fso = nothing
MsgBox ("The InfoPath form template has been registered.")

 

4.因为是VBScript文件所以保存为.vbs文件。

 

The ExternalApplication object is a deprecated type that should no longer be used for automation. The Application object and the XDocument object contain the properties and methods needed for external automation of the InfoPath application.

For backward compatibility, the ExternalApplication object can be used to perform a limited set of InfoPath operations such as creating, opening, or closing a form; registering or un-registering a form template; or simply quitting the application.

 

14)Infopath脱机功能开发:

InfoPath 2003用代码检测表单的连接状态:
http://office.microsoft.com/en-us/infopath/HA011227901033.aspx
InfoPath 2007用代码检测表单的连接状态:
http://office.microsoft.com/zh-cn/infopath/HA101575532052.aspx?pid=CH100341122052
InfoPath 2007添加按钮以刷新数据连接:
http://office.microsoft.com/zh-cn/infopath/HA102117392052.aspx?pid=CH100341122052

InfoPath 2003当提交表单而脱机时生成一个Mail并将Form作为EMail附件保存并等待提交:
http://msdn.microsoft.com/zh-cn/aa944801.aspx
InfoPath 2003当提交表单而脱机时保存表单为xml并排队提交:
http://blogs.msdn.com/infopath/archive/2004/03/17/91313.aspx

 

15)用script解包.xsn文件,修改manifest.xsf文件,再打包成.xsn文件:
http://blogs.msdn.com/infopath/archive/2004/05/04/126147.aspx
http://blogs.msdn.com/infopath/archive/2004/05/05/126723.aspx
http://blogs.msdn.com/infopath/archive/2004/05/06/127594.aspx
http://blogs.msdn.com/infopath/archive/2004/05/07/127958.aspx
http://blogs.msdn.com/infopath/archive/2004/05/07/128224.aspx
中文的
http://blog.csdn.net/yanwei100/archive/2006/12/20/1450535.aspx

16)

VS2005+Infopath2007开发:
VS2005需要装Microsoft Visual Studio 2005 Tools for the 2007 Microsoft Office System 也称为“Visual Studio 2005 Tools for Office Second Edition”或“VSTO 2005 SE”,就可以有开发Infopath2007的模版了。
在安装次插件之前要先安装InfoPath2007,否则在VS2005里看不到开发Infopath2007的模版,如果先装了插件也要卸载再装完InfoPath2007之后再装此插件,通过更新安装也不能看到模版。
     1.确保您只安装了 Microsoft Office 的一个版本。VSTO 2005 SE 不支持并行安装了 Microsoft Office 产品的两个不同版本的配置,已确知 VSTO 2005 SE 在这种配置下无法正常工作。
     2.Microsoft Office InfoPath 2003 Tools for Visual Studio 2005 用户:如果您计划将 VSTO 2005 SE 与 InfoPath 2007 一起使用,那么应当在安装 VSTO 2005 SE 之前卸载 InfoPath 2003 Tools for Visual Studio 2005。

不需要安装Visual Studio 2005 Tools for Office Update: InfoPath 2007 Beta Support
http://www.microsoft.com/downloads/details.aspx?familyid=00779894-e95f-4b22-8590-07584c891207&displaylang=en
这个应该是开发Beta版的Infopath的插件,如果装了此插件而开发正式版的Infopath则可能会抛出“attempted to read or write protected memory this is often an indication that memory is corrupt”错误。


17)在vs2005或vs2008下开发Infopath2007,debug的时候如果抛出错误“Infopath cannot open the selected form.” 需要检查两个地方:
1.将Security设置成Full Trust才能解决。
2.如果你的源代码移动过位置,可能遇到上面的错误,具体解决办法如下:
http://groups.google.com/group/microsoft.public.infopath/browse_thread/thread/29bd1699a4184aa2/d7fb43b622f35e4d?lnk=raot
This error may occur after you launch an XSN file with the same form ID as
the form template in your Visual Studio project. The XSN file is cached on
your hard disk, but with default XML that doesn't conform to your current
schema.

第一种解决办法:
Workaround - close down VS2005 and double-click manifest.xsf in the InfoPath
Form Template subfolder within your project folder. Answer YES to the big
warning box that pops up. Then close down InfoPath and reopen your project in
Visual Studio. You should now be able to run the form in Preview mode from
VS2005.
第二种解决办法:
Try using the following command to clear the form template cache:
在命令行输入下面的命令.
"C:\Program Files\Microsoft Office\Office12\InfoPath.exe" /cache ClearAll

或者or delete directly files on your harddrive.

另一种解释:
There are a wide variety of things that can cause this error as this is the most generic of errors for InfoPath:

1.  Open up the form in the Rich Client/InfoPath 2007. This give the options to click "Details" and get a more specific error. Opening in Visual Studio or in the web client does not provide this option so it is a guessing game as to why.

2.  Building the solution in VS2005 isn't enough and won't create an XSN, need to publish instead of build.  Once the XSN is created, open in the rich client and see if the error occurs and get details.  Check the date on the XSN to verify it built the file.

3.  I'm using Full Trust Security mode which is not set by default.  Open up the manifest.xsf in VS2005, select Tools... Form Options..   Security.

4.  This one is tricky...  The cache won't refresh in VS2005.  Close VS2005 then click on the manifest.xsf file.  During the open process it will ask if you want to overwrite the cached version.  Say yes.

5.  Beyond this it is typically a schema issue with the xml.

6.  Can also try restarting VS2005 and/or removing then readding references in the VS2005 solution.

Also, to use the Tools..  Form Options...  Preview feature:

1. Open up the XSN in InfoPath and fill out the form. 

2. Save As..  and enter the file name.  Usually I put sampledata.xml and place in the project directory.

3. Goto Tools... Form Options... Preview... and enter this file name.

4. Now when the form is run, it shows the data that was entered in step 1.

18)开发Infopath2003时最好别同时装Infopath2007否则debug预览时会报错误“Infopath cannot create a new, blank form. The form template is not valid. InfoPath cannot open the selected form because of an error in the form's code.”

Solution:
Make sure, when you install Office 2007 and you need to keep Infopath2003 for dev purposes, do a "Customize" install of Office 2007. Select the box where you can keep previous versions of Office and
continue to install Office 2007.  Your end result will be a side by side installation of Office 2007 and your previous version of Office.

19)可以使用 Wsdl.exe 工具创建代理类。 随后,Web 服务客户端便可以调用该代理类的方法,这些方法通过处理发往和来自 Web 服务的 SOAP 消息来通过网络与该 Web 服务进行通信。 由于代理类通过 Internet 与 Web 服务通信,因此最好验证该代理类的 Url 属性是否引用受信任的目标。
wsdl http://10.192.12.125:8086/getdata.asmx /out:proxy.cs

http://msdn.microsoft.com/zh-cn/library/7h3ystb6.aspx
http://msdn.microsoft.com/zh-cn/library/cy2a3ybs(VS.80).aspx
http://msdn.microsoft.com/zh-cn/library/d2s8y7bs.aspx


20)The type 'CMSWebServices.Global' is ambiguous: it could come from assembly 'C:\SYSROOT\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\cmswebservices\9f47ba1e\3650df8c\App_Code.enoeb--o.DLL' or from assembly 'E:\download\CMSWebServices\bin\CMSWebServices.DLL'. Please specify the assembly explicitly in the type name.
问题的原因是bin目录里有重复的dll,因为一个站点应用程序build后vs2003生成dll在bin里,vs2005生成在临时文件里,vs2005在发布后才生成dll在bin里。

 

 

Outlook: 

1)为什么需要备份邮件:

控制面板-Mail-Show Profiles中的每个profile可以设置多个邮箱(即Account),但只能连到一个Exchange Server,其他的都是普通邮箱,Exchange Server的脱机文件为.ost后缀,存档文件为.pst后缀,普通邮箱的都是.pst后缀。
.ost文件不能通过连接到其他Exchange Server而打开,必须还要连到其当初的Exchange Server,所以要有当初的帐号和访问权限。所以要想得到此邮件,可以存档,存档后为.pst文件,可以被Outlook打开。也可以用软件将.ost文件转换成.pst文件,软件有:Advanced Exchange Recovery和OST2PST。
关于怎样更改以建好的帐户的保存脱机文件的位置,请参见:
http://office.microsoft.com/zh-cn/outlook/HA012276282052.aspx
也可新建帐户时直接更改此位置。

 

调试: 

http://msdn.microsoft.com/zh-cn/library/d0b8xh0y(VS.80).aspx 


(1)怎样对一条特定的线程进行调试:
Visual C++调试器支持多线的情况,如果你在许多线程都调用的函数中设置一个断点,每当一个线程遭遇到此断点,调试器就会在线程之间循环切换有个方法可以避开这个问题,就是挂起所有线程,除了你感兴趣的那条(要调试的那条),在调试器中打开[Debug]菜单并选择[Thread]你就可以获得一个线程对话框,在这里你可以挂起所有的线程,把你要调试的线程留下来,单独调试。

(2)多进程调试方法:
方法一:
1.在vs中选择Debug-选择Attache to Process-选择主进程。
2.通过Debug-Windows-Processes打开Processes窗口,点击Attache to Process-点击Refesh直到第二个进程出现-选择此进程。第二个进
程有时候不会马上在Attache to Process窗口看到,或者是灰显的,要不断点击Refesh才能出现。
http://msdn.microsoft.com/zh-cn/library/c6wf8e4z(VS.80).aspx

方法二:
在你想要调试的子程序的代码中加入一句代码DebugBreak();

DebugBreak Reference in C#, VB.NET and VB6
Library:kernel32.dll

Visual Basic .NET definition
Declare Sub DebugBreak Lib "kernel32" () 

C# definition
[DllImport("kernel32.dll", SetLastError=true)] static extern void DebugBreak () 

Description
DebugBreak Causes a breakpoint exception to occur in the current process.

Dotnet Replacement :
VB.Net:
System.Diagnostics.Debugger.Break()
C#:
System.Diagnostics.Debugger.Break();

然后重新编译你的子程序的调试版本。现在调试主程序,子程序的调试版本在运行的过程中,当执行到DebugBreak()时,将会抛出一个异常,这个异常会由操作系统捕捉到,然后弹出一个对话框,说程序遇到了问题,问你要不要发送错误报告,点击该对话框的调试按钮,系统又会弹出一个对话框,选择相应的调试器进行调试,然后子进程就会中断在代码DebugBreak()处,接下来就可以正常调试了。任何进程都可以添加一个DebugBreak函数强制中断,相当于设置断点,这个用于调试服务、DLL等尤其方便。

如果你想使用的vs没有出现在弹出的对话框里,请按照下面的步骤设置:
To enable/disable Just-In-Time debugging

1.    On the Tools menu, click Options.

2.    In the Options dialog box, select the Debugging folder.

3.    In the Debugging folder, select the Just-In-Time page.

4.    In the Enable Just-In-Time debugging of these types of code box, select or clear the relevant program types: Managed, Native, or Script.

To disable Just-In-Time debugging, once it has been enabled, you must be running with Administrator privileges. Enabling Just-In-Time debugging sets a registry key, and Administrator privileges are required to change that key.

5.    Click OK.

(3)JavaScript调试:

1)用VS2005调试Javascript时最好用Ctrl+F5(不调试直接运行)不要用F5(调试后运行),因为后者的调试器还是用同一个VS2005且单步光标指示的位置也不是实际位置,而前者可以选择是否打开新的VS2005调试Javascript且光标停的位置也是正确的。

光标不停在实际位置的另一个解决办法是,将web站点部署到IIS,通过IIS浏览这个站点,当出现javascript错误时候会提示你打开vs调试,此时会停在实际位置。

两种方法都不要选择当前的vs作为调试器,否则停的位置不正确。

以上的原因可能是页面继承了MasterPage,而Javascript代码又在Master Page里,使得vs找不到实际的代码。



安装包: 
1)在VS2005生成的安装包中,.msi文件和.exe文件的区别:
先为你解释一下MSI的意思,说到MSI文件,不得不先说说Windows Installer,它不只是安装程序,而是可扩展的软件管理系统。Windows Installer的用途包括:管理软件的安装、管理软件组件的添加和删除、监视文件的复原以及使用回滚技术维护基本的灾难恢复。另外,Windows Installer还支持从多个源位置安装和运行软件,而且可以由想要安装自定义程序的开发人员自定义。要想使用这些功能,就必须通过MSI文件。MSI文件是Windows Installer的数据包,它实际上是一个数据库,包含安装一种产品所需要的信息和在很多安装情形下安装(和卸载)程序所需的指令和数据。MSI文件将程序的组成文件与功能关联起来。此外,它还包含有关安装过程本身的信息:如安装序列、目标文件夹路径、系统依赖项、安装选项和控制安装过程的属性。

如果你是用.net 打包工具进行的打包,并且写了一个自定义类去读取某些值,举个例子,比如你要得到安装程序的运行路径,你会发现,起始位置会是C:\Windows\system32。但是如果你是自己写的一个.EXE文件,它的取得的位置会是实际位置。
对于注册表的读取,应该没有什么影响,但我要提醒你,会不会有别的什么地方处置的不妥当。


.msi需要Microsoft的一个服务支持(大概叫做Microsoft   Installer,目前版本2.00),基本上只用于安装软件。  
.exe是可执行文件,不一定是安装程序。

msi是微软出的一种封装格式,只适用于windows系统,对安装和卸载都有严格要求,支持系统还原,微软出的软件都用这种格式安装

.msi是微软的自解压文件,如安装某些软件时就是这种文件格式打包而成的,Windows系统中自带有软件将其解压。正如WINRAR可以将文件压缩成.rar文件,也可以将.rar文件解压一样;而.exe是可执行文件类型,通俗一点来说.exe文件不依靠其他软件(当然不能脱离系统)而单独运行的文件,因为.exe就是软件。


系统: 

1)怎样解决Windows XP的IE错误"Internet Explorer has encountered a problem and needs to close. We are sorry for the inconvenience."

   症状:
   当打开某个特殊的网址时,而不是所有的网站,IE会出现"Internet Explorer has encountered a problem and needs to close.  We are sorry for the inconvenience."的对话框,点击对话框中的"click here"链接时弹出的对话框包含"Error signature AppName: iexplore.exe AppVer: 6.0.2900.2180 ModName: pnxr3260.dll ModVer: 6.0.7.4552 Offset: 00003e98"信息,当点击第一个对话框中的"Don't Send"按钮时,网页会自动关闭。
   解决方法:
   在系统盘上查找pnxr3260.dll,通常在C:\Program Files\Common Files\Real\Plugins\pnxr3260.dll,删掉它。这是RealOne Player的一个文件,会导致很多莫名其妙的错误,建议卸载RealOne Player,使用RealPlayer10,或者升级RealOne Player。
   如果上面的方法不行(应该行,因为我的就这样解决了),就到华军软件园下载"黄山IE修复专家"软件,启动到网络连接的安全模式,用此软件修复IE,但这种方法是解决中病毒的情况。

 

2)svchost.exe占用CPU 100%的解决方法

现象:
机器启动运行几分钟后 svchost.exe就会占系统cpu资源的100%
拔掉网线重启就好了,重连上网后一会儿:svchost.exe又占cpu资源的99%;
在断掉网线系统能正常工作的情况下,打开控制面板-管理工具-服务,找到"Automatic Updates",设置成stop,再插上网线,CPU占用率高的问题消失。
确认:
A)
按ctrl+alt+del打开任务管理器,点击“View-Select Columns”,钩选PID(进程标识符)。然后在进程选项卡查看进程信息。XP系统可能有多个名称为svchost.exe的进程。如果发现某一个svchost.exe进程CPU占用率高,记下这个进程的PID。
B)
1.在run里运行cmd,在命令窗口中退到cd C:\后运行Tasklist /m wuaueng.dll命令。
找到运行Automatic Update服务的SVCHOST进程的PID看是否与占用CPU过高的PID相同。如果相同,可以判断是此问题。
2.此步骤帮助用户判断问题。执行下面的命令行来强制客户端发起补丁检测 (某些情况下这个命令行能够重现CPU占用率过高的问题)
Wuauclt /detectnow

解决方案:
您可以尝试用下面的方法看能否解决这个问题:
1.安装更新KB927891:
http://support.microsoft.com/kb/927891
2.如果安装了更新KB927891之后,客户端仍然有持续的100%CPU问题,请您下载安装最新的WSUS 3.0 客户端:
http://download.windowsupdate.com/v7/windowsupdate/redist/standalone/WindowsUpdateAgent30-x86.exe

针对64位操作系统:
http://download.windowsupdate.com/v7/windowsupdate/redist/standalone/WindowsUpdateAgent30-x64.exe 
http://download.windowsupdate.com/v7/windowsupdate/redist/standalone/WindowsUpdateAgent30-ia64.exe

上面两个步骤应该能够缓解这个问题。关于这个问题的最新的进展请参考:
http://blogs.technet.com/wsus/archive/2007/04/28/update-on.aspx

 

3)Using XP and intalled IE7. Every time i start internet it will not start with
my preset webpage but it starts with
http://go.microsoft.com/fwlink/?LinkId=74005 and then jumps to
http://www.msn.com/404.aspx?aspxerrorpath=/runonce2.aspx.
Can someone help me with this problem ?

解决办法:

http://support.microsoft.com/kb/945385/en-us

1. Click Start, click Run, type regedit, and then click OK.
2. Locate the following registry subkey, and then click it:
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main
3. In the details pane, double-click the RunOnceHasShown registry entry.

Note If the RunOnceHasShown registry entry is not located in the details pane, you must create it. To do this, point to New on the Edit menu, click DWORD Value, and then type RunOnceHasShown in the New Value box. 
4. In the Value data box, type 1, and then click OK.
5. In the details pane, double-click the RunOnceComplete registry entry.

Note If the RunOnceComplete registry entry is not located in the details pane, you must create it. To do this, point to New on the Edit menu, click DWORD Value, and then type RunOnceComplete in the New Value box.
6. In the Value data box, type 1, and then click OK.
7. Close Registry Editor.

 

4)x86,x64和IA64的区别:
X86是一个指令集。
X64就是基于x86架构的64位CPU。AMD64位CPU就是用这种技术的,全称应该是X86-64。
IA64指安腾(Itanium)体系的架构的64位CPU。IA64是INTEL的技术。

 

5)

GDR Software Updates和QFE Software Updates区别:
基本上来说,现在微软Windows补丁包中的更新文件大致包含了两类。一类叫做GDR(普通分发版本),一类叫做QFE(快速修补工程更新)。其中,GDR文件经过了大量严格的测试,稳定性很高。而对QFE所做的测试相对则要相对少一些,所以稳定性亦要低一些。

所以,微软的补丁包也可以按此分为两类。一类就是安全修补程序,这类补丁包中同时包含了GDR和QFE版本的更新文件,也就是两个副本。微软的很多关键性安全补丁就属于此类。还有一类叫做修复程序,仅包含了QFE版的更新文件。常见的就是一些需要正版验证的补丁。

那么为什么安全修补程序要包含两种版本的文件呢?如果你要在系统中安装修复程序,也就是说要安装QFE更新文件。然而当前系统中需要被替换的文件为GDR版,而且版本号要比补丁包中的QFE文件版本号高,那么就不能用补丁包中的QFE文件来替换,而需要用与当前GDR文件版本相同的QFE文件来修补。那么到哪里取得这个文件呢?其实这个QFE文件在你以前安装GDR版更新文件(就是当前系统中使用的文件)时就已经被同时复制到了你的硬盘中。这就是安全修补程序需要同时包含GDR和QFE更新文件,且两类文件版本号都相同的原因。

以名为WindowsXP-KB896688-x86-CHS.exe的安全修补程序为例来说明,该补丁包需要更新MSHTML.DLL这个文件。如果安装程序检测到系统中当前的MSHTML.DLL为GDR版时,则会用补丁包中GDR版的MSHTML.DLL(文件说明为xpsp_sp2_gdr.051004-1415)来进行更新,并且把QFE版的MSHTML.DLL复制到"%windir%\$hf_mig$"这个文件夹。反之,如果安装程序检测到系统中当前的MSHTML.DLL为QFE版时,则会用补丁包中QFE版的MSHTML.DLL(文件说明为xpsp.051004-1419)来进行更新。两个文件的版本号都是6.00.2900.2769。

同时在注册表中也可以发现这个特点。在我的系统中反映为两个注册表项:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Updates\Windows XP\SP3\KB896688\Filelist\8和HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Updates\Windows XP\SP3\KB896688\Filelist\50。两个项下的FileName字串值都是"MSHTML.DLL",而Location字串值分别为"C:\WINDOWS\system32"和"c:\windows\$hf_mig$\KB896688\SP2QFE",也就是分别存放GDR和QFE文件的位置。

如果你在安装了GDR版的KB896688补丁之后,又要重新安装一个需要把MSHTML.DLL更新为QFE版的修复程序。但是该修复程序中的MSHTML.DLL版本号比6.00.2900.2769要低,那么这时候更新程序就不会选取补丁包中的MSHTML.DLL来更新,而是到"%windir%\$hf_mig$"去找之前预留的QFE版MSHTML.DLL来更新。所以说一般最好不要轻易删除Windows目录下的"$hf_mig$"文件夹。

 

 

 

posted on 2006-09-18 09:31 JasonLi 阅读(12372) 评论(0)  编辑 收藏 网摘 所属分类: 21Java技术-Java各大网站15.NET技术-.NET开发日记




发表评论

昵称: [登录] [注册]

主页:

邮箱:(仅博主可见)

评论内容:

  登录  注册

[使用Ctrl+Enter键快速提交评论]

0 507082




相关文章:

相关链接: