edrp.cn的Blog

学习,需要交流,欢迎大家和我共同来学习C#,ASP.NET,MS SQL Server开发Web项目,欢迎大家和我交流

博客园 首页 新随笔 联系 订阅 管理
  115 Posts :: 0 Stories :: 199 Comments :: 3 Trackbacks

2008年9月3日 #

开发环境:Windows server 2008 Enterprise,Microsoft Visual Studio 2008 SP1,.NET Framework 3.5 SP1,Microsoft SQL Server 2008

开发架构: ASP.NET AJAX,WCF,ADO.NET Entity Framework

开发步骤:

1、创建一个空白解决方案:JXCSln;

2、添加一个类库项目,名称为:Jxc.DAL,删除生成的Class1.cs,接着引用一下:System.Data.Entity,否则在创建数据库连接时会出现错误,无法连接到数据库。然后添加新项:ADO.NET Entity Date Model。名称为:NorthwindDbModel.edmx;在弹出的实体模型向导的第一个窗口中,选择“从数据库生成”,然后下一步,数据库连接设置如下图:

设置好后,单击下一步,出现如下图所示窗口,这时,我们只选择表:

最后单击无成,生成的实体模型图如下:

三、选择Jxc.DAL类库,生成一下。

四、添加一个新项目(类库项目),名称为:Jxc.BLL,删除生成的Class1.cs文件。添加引用,选择项目,引用Jxc.DAL,引用System.Data.Entity。

五、添加一个新类,名称:EmployeesInfo。

六、打开EmployeesInfo.cs文件,输入如下代码:

(需要 using Jxc.DAL;)

        NorthwindEntities EmployeesContent = new NorthwindEntities();

        public string GetEmployeeNameByID(int EmployeeID)
        {
            var query = EmployeesContent.Employees.First(p => p.EmployeeID == EmployeeID);
            return query.LastName + query.FirstName;
        }

        public Employees[] GetAllEmployees()
        {
            var query = from emp in EmployeesContent.Employees select emp;
            return query.ToArray();
        }

 

(时间关系,待续...)

接着上面的

七、添加一个新项目:ASP.NET Web 应用程序,并命名为:Jxc.Web。

八、添加引用——>项目:Jxc.BLL,Jxc.DAL,System.Data.Entity。

九、添加新项,WCF服务,名称:EmployeeService.svc; 删除文件IEmployeeService.cs,并将以下代码粘贴到EmployeeService.svc.cs文件中:

 

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using Jxc.DAL;
using Jxc.BLL;  //记得引用

namespace Jxc.Web
{
    [ServiceContract(Namespace = "WcfService")]
    public class EmployeeService
    {
        EmployeesInfo employeefobl = new EmployeesInfo();
        int recordCount = 0;


        [OperationContract]
        public string GetEmployeeNameByID(int empid)
        {
            return employeefobl.GetEmployeeNameByID(empid);
        }

        [OperationContract]
        public Employees[] GetAllEmployees()
        {
            return employeefobl.GetAllEmployees();
        }
    }
}

十、接着删除Web.Config文件中生气的代码:

    <system.serviceModel>
        <behaviors>
            <serviceBehaviors>
                <behavior name="Jxc.Web.EmployeeServiceBehavior">
                    <serviceMetadata httpGetEnabled="true" />
                    <serviceDebug includeExceptionDetailInFaults="false" />
                </behavior>
            </serviceBehaviors>
        </behaviors>
        <services>
            <service behaviorConfiguration="Jxc.Web.EmployeeServiceBehavior"
                name="Jxc.Web.EmployeeService">
                <endpoint address="" binding="wsHttpBinding" contract="Jxc.Web.IEmployeeService">
                    <identity>
                        <dns value="localhost" />
                    </identity>
                </endpoint>
                <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
            </service>
        </services>
    </system.serviceModel>

十一、选择文件EmployeeService.svc,右键——>查看标记:

将代码::<%@ ServiceHost Language="C#" Debug="true" Service="Jxc.Web.EmployeeService" CodeBehind="EmployeeService.svc.cs"  %>

改成如下代码:<%@ ServiceHost Language="C#" Debug="true" Service="Jxc.Web.EmployeeService" CodeBehind="EmployeeService.svc.cs"  Factory="System.ServiceModel.Activation.WebScriptServiceHostFactory" %>

十二、打开Default.aspx窗口,加入Asp.net Ajax功能:ScriptManager代码如下:
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
      <Services>
        <asp:ServiceReference Path="~/EmployeeService.svc" />
      </Services>      
    </asp:ScriptManager>
    <br />
    <h2>
        ASP.NET AJAX+WCF+ADO.NET Entity 架构实例</h2>
    <p>
      输入一个员工ID调用WCF并返回对应的名字!</p>
    请输入部门ID:<input id="txtdeptID" name="txtdeptID" type="text" />
    <input id="btnTransfer" onclick="ClientGetEmployeeID()" type="button"
        value="调用" /> <span id="Results"></span>
    </form>
</body>

十三、编写javascript代码,如下:

    <script type="text/javascript">
        function ClientGetEmployeeID() {
            var txtdeptID = document.getElementById("txtdeptID");
            if (isNaN(txtdeptID.value)) {
                alert('部门ID必须是数字!')
                txtdeptID.focus();
                return;
            }
            var proxy = new WcfService.EmployeeService();
            proxy.GetEmployeeNameByID(txtdeptID.value, OnSucceeded, OnFailed, "");
        }
        function OnSucceeded(result) {
            var RsltElem = document.getElementById("Results");
            RsltElem.innerHTML = result;
        }
        function OnFailed(error) {
            var RsltElem = document.getElementById("Results");
            RsltElem.innerHTML = "调用失败!";
        }     
    </script> 

十四、在Default.aspx.cs文件using一下引用项目:

using Jxc.BLL;
using Jxc.DAL;

 

 十五、程序运行如下:

 

 

 

 

 至此,已经可以正常运行,测试通过。

现有如下问题:

一、如果换成使用jquery如何调用?

二、无论是ASP.NET AJAX或者是jquery调用,如何和Web页面中的GridView绑定?

三、如何将依赖注入、IOC加入项目?

四、使用了ADO.NET Entity后,数据库中的表结构发生变化,如何应对项目中的变化?比如:员工表的地址字段由原来的长度20加为50?

 

 请路过的朋友发表高见,当然也为像我一样想学这些技术的朋友指引一下,不过,还得大家多发表意见,谢谢

posted @ 2008-09-03 22:49 edrp.cn 阅读(75) | 评论 (0)编辑

2008年9月1日 #

服务器环境:Windows Server 2003 Enterprise sp2+Citrix MetaFrame XP FR3

客户端环境:Citrix MetaFrame Program Neighborhood Version 9.00.32649 (包换WEB登录)

错误现象:无论是客户端登录还是WEB登录都出现如下错误:wfshell.exe - 应用程序错误,"0x00000000"指令引用的"0x00000000"内存,该内存不能为"read"的提示。

解决访求:经过测试,所有客户端均有此错误,可判断是服务器配置问题,经过检查可能是客户端的插件程序版本高的原因,在服务器上升级Citrix MetaFrame XP FR3 SP4。升级完后,客户不再出现错误提示。

 

 

posted @ 2008-09-01 20:10 edrp.cn 阅读(27) | 评论 (0)编辑

利用IIS作为宿主 发布你的WCF Service

http://www.xiaozhou.net/cooldog/article.asp?id=161

 

WCF宿主与服务托管

http://www.cnblogs.com/wayfarer/archive/2008/01/02/1022967.html

 

 

posted @ 2008-09-01 14:21 edrp.cn 阅读(47) | 评论 (0)编辑

2008年8月31日 #

奥运结束了,留给我了无限的感慨,不仅仅是中国健儿取得了金牌第一......

台上一分钟,台下10年功,这是给我最深刻的体会......

曾记得自己刚开始学习编程的时候是使用VB5,后来又学习Delphi,再后来学习C#Builder,接着又学习Microsoft Visual Studio(C#)系列......

日新月异的技术,让我学的迷茫,可是当看到我们的奥运冠军背后的故事,我会觉得我远远没有达到为了那一分钟而做出的努力。

在园子了里面有很多技术一流,为人很好的朋友,很庆幸自己在博客园安了家,认识了这么多朋友。我想将来自己的学习肯定要比体育健儿们的“苦其心志、劳其筋骨”的锻炼轻松千万倍了......,给自己加油!

 

posted @ 2008-08-31 11:22 edrp.cn 阅读(90) | 评论 (0)编辑

2008年8月29日 #

开发一个B/S的系统,到底该如何来设计架构呢?

带着这个问题,我GOOGLE了,也BAIDU了,结果是使用NBear,学了没有几天知道了ADO.NET Entity Framework,知道了很多微软的新技术,既然有这么好的ADO.NET Entity Framework,为什么不用呢?可是又该如何用呢?如何和其它技术整合起来?如何分层来架构一个系统?我迷惑了......

要想开发一个健壮的,易于扩充的,可维护的,可修改的项目谈何容易,新技术日新月异,压得你喘不过气来。

Asp.net ajax, asp.net mvc, wcf,Silverlight,jQuery, ado.net entity framework等等技术。到底该如何将它们应用到一个WEB项目中或者是说如何来利用这些技术来架构一个项目?如何分层呢...

请大家一起讨论讨论,也请有经验的朋友给些指导,我在此代表想使用这些技术的菜鸟向你们致谢了!

posted @ 2008-08-29 12:17 edrp.cn 阅读(266) | 评论 (3)编辑

2008年8月25日 #

修改citrix 默认侦听端口的命令:
在命令行下输入icaport /port:2494,或你所想改成的端口
如果输入 icaport /reset 恢复默认侦听端口

 

ctxxmlss /r8080

 

在citrix的外部客户端通过web方式登陆时,提示“the alternate address cannot be found”的错误信息,无法正常登陆
解决方法:该问题主要是alternate address设置的问题,可以通过执行下面的dos命令来修复   ALTADDR /SET xxx.xxx.xxx.xxx   --citrix服务器的外部IP地址,执行完命令后重新启动CITRIX服务器。

posted @ 2008-08-25 21:43 edrp.cn 阅读(44) | 评论 (0)编辑

2008年8月23日 #

出错环境:windows server 2003 enterprise sp2+Access2000+iis6

 

出错情况:打开页面修改数据后保存时出现错误:所有记录中均未找到搜索关键字

 

出错原因:Microsoft office access 2000的备注型字段不能超过1950字节,是由于备注型字段是有“索引”。用Access对数据库的表进行设计时,点试设计视图->索引, 可以看到这个字段有索引。出错就是因为这个索引。

 

解决方法:取消主键,索引为无即可。

 

PS:使用ACCESS设计视图创建表时,如果只一个字段,而且是备注型的字段,则关闭时会提示设置主键,设置了主键的会出现些错误。

 

(另外:网友说创建表根本就没有选项对备注型字段加上索引功能,会偷偷地跑出一个索引出来?也许这个确实是ACCESS的一个BUG。)

posted @ 2008-08-23 22:46 edrp.cn 阅读(38) | 评论 (0)编辑

终于下了狠心,把自己的windows server 2003 企业版换成了windows server 2008 企业版,并安装了VS2008和VS 2008 SP1。

在安装过程中还是费了点事,今天写出来,供朋友们参考:

一、安装windows server 2008 企业版;

二、安装完后启动必须要修改密码,此时设置简单的密码则不行,必须带有大小写字母及数字,而且长度要大于8位。

三、激活系统,从网上下载激活工具,解压后打开文件crack.nfo,按照里面的说明操作即可(参见下面的回复)。

四、安装VS2008,再安装VS2008 sp1(切记:安装VS 2008 sp1需要两个多小时,非常慢,我曾经取消过一次安装。)

五、升级VS2008 使之正式版本。操作如下:控制面版→程序和功能→找到“Microsoft Visual Studio 2008”,选中,右键“卸载/更改”。等一会儿后,在出现的窗口中输入升级的序列号:XMQ2Y-4T3V6-XJ48Y-D3K2V-6C4WT

完成。

此贴仅限学习交流,请支持正版。

posted @ 2008-08-23 01:43 edrp.cn 阅读(292) | 评论 (9)编辑

2008年8月19日 #

Explaining and Changing the Citrix XML Service Port

Document ID: CTX104063   /   Created On: 2004-5-7   /   Updated On: 2008-4-16
Average Rating: 2

Explaining the XML Service

The Citrix XML Service was introduced with MetaFrame 1.8 Service Pack 2 and a Feature Release 1 license needed to be installed. MetaFrame XP and later incorporates the Citrix XML Service as a standard feature.

When MetaFrame 1.8 Service Pack 2 or later is installed and the server rebooted, the Citrix XML Service binaries are placed on the system whether the Citrix XML Service was or was not installed. All that must be done to complete the Citrix XML Service installation is to register the XML Service itself by running the ctxxmlss command.

Unlike MetaFrame XP or later, MetaFrame 1.8 does not allow for the sharing of port 80 with IIS.

The below command-line syntax applies to all MetaFrame environments:

CTXXMLSS.EXE Command Line Usage

Syntax

CTXXMLSS [switches] [/Rnnnn] [/Knnn] [/U] [/?]

Parameters

/Rnnnn - Registers the service on port number nnnn

/Knnn - Keep-Alive nnn seconds (default 9).

/U - Unregisters the service.

/? (help) - Displays the syntax for the utility and information about the utilities options.

After the Citrix XML Service is registered, a new service appears in the Services Applet and registry entries are created. Ensure this service is started.

To determine which port is being used, either look in the Citrix Management Console (MetaFrame XP and later) and/or locate the following registry key (assuming IIS port sharing is not being used):

WARNING: Using Registry Editor incorrectly can cause serious problems that may
require you to reinstall your operating system. Microsoft cannot guarantee that problems
resulting from the incorrect use of Registry Editor can be solved. Use Registry Editor at
your own risk.For information about how to edit the registry, view the "Changing Keys
and Values" Help topic in Registry Editor (Regedit.exe) or the "Add and Delete
Information in the Registry" and "Edit Registry Data" Help topics in Regedt32.exe. Make
sure you back up the registry before you edit it. If you are running Windows NT, also
update your Emergency Repair Disk (ERD).

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\CtxHttp

Value: "TcpPort" If the value is listed in hex, change to a decimal notation.

If Microsoft IIS is installed, the administrator of the MetaFrame XP installation is given the option to install the Citrix XML Service and share a port with IIS.

In fact, no separate XML Service is running. IIS serves the XML data using an ISAPI filter named Wpnbr.dll located in the \Inetpub\Scripts folder. To remove the Citrix XML Service functionality from your MetaFrame server, simply rename or delete the Wpnbr.dll file.

Lastly, once the XML Service port is changed on the MetaFrame Servers, change NFuse or Web InterFace, MetaFrame Secure Access Manager, or the Program Neighborhood Client to use the new port.

Unregistering the XML Service

    1. Open a command Prompt window.

    2. Run ctxxmlss /u (This command will unregister the Citrix XML Service and mark it for deletion).

    3. Reboot the server.

Registering the XML Service on a port other than sharing with IIS

      1. Unregister the service using the previous instructions.

      2. Open a command Prompt window.

      3. Run ctxxmlss /r[Port Number] (Notice that there is no space between the switch “/r” and the port number.

      4. Reboot the server or open the service control manager and manually start the Citrix XML Service.

Registering the XML Service to share the port with IIS 5.0

    1. Unregister the service using the previous instructions.

    2. Copy the files ctxxmlss.txt, clm.dll, wpnbr.dll to the \Inetpub\Scripts folder. ***(If you are running MetaFrame Presentation Server 3.0 then the clm.dll file is no longer needed).***

    3. If you are running MetaFrame Presentation Server 3.0 or Citrix Presentation Server 4.0, locate the file ctxadmin.dll and copy it to a folder called ctxadmin under \Inetpub\Scripts.

    4. If you are running Citrix Presentation Server 4.0, locate the files ctxconfproxy.dll,ctxsta.dll,ctxsta.config and copy them to \Inetpub\Scripts.

    5. Open the IIS Manager MMC Snap-in.

    6. Expand the Default Web Site.

    7. Right-click the Scripts folder and click Properties.

    8. On the Virtual Directory tab make sure that the Execute Permissions field is set to Scripts and Executables.

    9. Open a command prompt window.

    10. Run the iisreset command (be aware that this command will restart all IIS-related services).

Registering the XML Service to share the port with IIS 6.0

For Citrix Presentation Server 4.0 on Windows 2003, refer to CTX107683 – How to Configure the XML Service to Share with IIS.

Otherwise, follow these steps:

By default when installing IIS 6.0 the virtual Scripts Folder is not created.

1. Unregister the service using the previous instructions.

2. Navigate to the \Inetpub folder and create a new folder named Scripts.

3. Open the IIS Manager MMC Snap-in.

4. Right-click the Default Web Site and select New | Virtual Directory…

5. Click Next.

6. Under Alias: type the name Scripts and click Next.

7. Under Path: type Drive Letter:\Inetpub\Scripts and click Next.

8. Under Allow the following permissions: make sure that the following are selected:

    a. Read

    b. Run Scripts (such as ASP)

    c. Execute (such as ISAPI applications or CGI)

9. Click Next and click Finish.

10. Right-click the Scripts virtual directory and go to Properties.

11. Under the Virtual Directory tab make sure that the Execute Permissions: field is set to Scripts and Executables.

12. Under the Directory Security tab, click Edit… under Authentication and Access Control and make sure that the Enable anonymous access check box is selected.

13. Now copy the files ctxxmlss.txt, clm.dll, wpnbr.dll to the newly create Scripts folder under the Inetpub folder. ***(If you are running MetaFrame Presentation Server 3.0 then the clm.dll file is no longer needed).***

14. If you are running MetaFrame Presentation Server 3.0 locate the file ctxadmin.dll and copy it to a folder called ctxadmin under \Inetpub\Scripts.

15. In IIS Admin right-click Web Service Extensions, select Add a new web service extension. Type the name Citrix XML ISAPI in the Extension name field and click Add. In the Add File popup window, type in or browse to the location of the wpnbr.dll file. Then finish by selecting the Set the extension status to allowed check box.

16. For MetaFrame Presentation Server 3.0, in IIS Admin right-click Web Service Extensions, select Add a new web service extension. Type the name Citrix XML Administration ISAPI in the Extension name field and click Add. In the Add File popup window, type in or browse to the location of the ctxadmin.dll file. Then finish by selecting the Set the extension status to allowed check box.

17. Run the iisreset command (be aware that this command will restart all IIS-related services).

Note: The file ctxxmlss.txt is located in the Program Files\Citrix\System32 folder and the files clm.dll and wpnbr.dll are located in the %SYSTEMROOT%\System32 folder.

With MetaFrame Presentation Server 3.0, all the files required are located in Program Files\Citrix\System32.


This document applies to:

  • MetaFrame XP 1.0 for Microsoft Windows 2003
  • Presentation Server 4.0 for Microsoft Windows 2000
  • MetaFrame Presentation Server 3.0 for Microsoft Windows 2003
  • Presentation Server 4.5 for Windows Server 2003
  • MetaFrame XP 1.0 for Microsoft Windows 2000
  • Presentation Server 4.0 for Microsoft Windows 2003
  • MetaFrame Presentation Server 3.0 for Microsoft Windows 2000
posted @ 2008-08-19 18:28 edrp.cn 阅读(81) | 评论 (0)编辑

2008年8月18日 #

  网站打开是出错,信息如下:

“/”应用程序中的服务器错误。

编译错误

说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。

编译器错误信息: CS0016: 未能写入输出文件“c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\fe6e7be4\7c198db4\App_Web_masterpage.master.cdcab7d2.fqsi_qfb.dll”--“拒绝访问。 ”

源错误:

[没有相关的源行]

源文件:    行: 0



 


 




版本信息: Microsoft .NET Framework 版本:2.0.50727.42; ASP.NET 版本:2.0.50727.42

 

在微软的网站搜到了这个问题的解决方法,其实很简单,只要在windows/temp权限设置里


面把Network service(如果是win2000则是asp.net用户)的权限加上就行。

 

如果不行,将系统安装目录windows下的TEMP文件夹的USER用户的访问权限更更为,写入,或者完全控制,因为,windows2003中如果安装了vs2003或者vs2005,在系统用户中将自动添加ASP.NET用户,而增加的此用户属于USERS组,所以默认情况下,USER用户没有写入TEMP文件夹的权限,因此在编译时出现以上错误!

具体解决方法请参照
http://support.microsoft.com/default.aspx?scid=kb;en-us;825791

posted @ 2008-08-18 11:02 edrp.cn 阅读(96) | 评论 (0)编辑