Windows应用程序开发入门到精通九,十 中间层程序 SmartClient

本文介绍了Windows应用程序开发中的中间层技术,包括WEBService、COM+、Remoting等,并详细讲解了WEBService的实现步骤及注意事项。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

看了欧岩亮的Windows应用程序开发入门到精通九,十的笔记,省略了很多内容。

 

中间层程序

什么叫中间层,就是需要一个宿主平台来执行这个程序。比如,IIS,WebService等等。我们写的程序是在这些平台上才能执行的。

主要有以下一些方法:

1.  WEB ServiceSystem.Web名称空间

2.  COM+EnterpriseServices名称空间

3.  Remoting组件和System.Runtime.Remoting名称空间

Remotinghttp,效率和WEB Service差不多。

Remotingtcp,效率比WEB Service提高很多。

 

如何用WEB Service

1.  新建一个项目,类型为ASP .NET WEB Service,地址为服务器地址。比如为:http://localhost/newwebproject

2.  在新建的项目中,增加一个web service文件,后缀为asmx。比如:mywebservice.asmx

3.  在这个mywebservice.asmx文件中可以增加处理代码。

4.  配置web.config(如果有需要)

5.  在调用web service项目的项目中增加web 引用。

6.  在弹出的窗口中输入web service项目的地址。精确到asmx文件。比如: http://localhost/newwebproject/ mywebservice.asmx,点击地址栏旁边的转到按钮确认后等待一会儿,可以修改web引用的名字。然后点击增加引用按钮。

注意,有时候按下转到按钮会提示网页没有找到的404错误。是因为你的iis没有配置对asp.net的支持。在运行中输入:

C:/WINNT/Microsoft.NET/Framework/v1.0.3705/aspnet_regiis.exe -i(这里的目录为系统目录)即可解决问题。

 

在用using(myclass nwda = new myclass())

    {    ………   }

时候会出错,因为nwda出了using作用域会自动垃圾回收。

这时可以通过让myclass继承IDisposable接口解决。

Public MyclassIDisposable

{

    ……

    public void Dispose(){} //自动生成这个空方法

}

这样就OK了。

 

 

SmartClient

可以将可执行程序拷贝到iis的网站目录中,然后可以从浏览器直接访问这个exe文件并执行。比如将1.exe拷贝到http://localhost/newwebproject目录下,其实就是c:/inetpub/wwwroot/ newwebproject目录下。然后在浏览器输入http://localhost/newwebproject/1.exe就能执行1.exe文件。

 

上面的1.exe程序,如果里面有磁盘操作的代码。比如在c盘生成文件,那么运行的时候会出现异常。System.IO.FileStream f=new System.IO.FileStream(“c:/1.txt”, System.IO.FileMode.Create, System.IO.FileAccess.ReadWrite);

为了使1.exe能在本地磁盘操作,必须通过.NET Framework 2.0 Configuration操作。这个工具在控制面板的管理工具里。

打开工具,在Runtime Security Policy中有个machine,即对本机进行安全设置。

Machine中的code group中的All_Code上点击右键,选择新增。

弹出窗口中选择url,输入url地址。(说明对url指定的程序有效)

下一步,选择权限,可以选择fulltrust.

下一步,配置完成。

 

 

Forger 推荐的学习windows 编程的所有书籍都在这儿: windows 编程 windows MFC入门精通 windows 高级编程 windows 网络编程 Programming Windows Programming Windows with MFC Programming Applications for Windows Network Programming for Microsoft Windows Programming Windows by Charles Petzold. The book to get on Win32 API. If you want to write programs using just the API (which is what this tutorial covers), you need this book. 如果你想只用windows API编程,这本书是入门经典,你需要这本书。 Programming Windows with MFC by Jeff Prosise. If you want to venture into MFC (AFTER becoming fully accustomed to using the Win32 API), this is the book for you. If you don't like MFC but intend on getting a job doing windows developement, get this anyway, it's better to know than not. 如果你想用MFC这本书是你想要的 Programming Applications for Windows by Jeffrey Richter. Not for newbies, if you want to be up on managing processes and threads, dlls, windows memory management, exception handling, and hooking into the system, then this is the book for you. 如果你想了解操作系统内幕,这本书是经典,书中包含了进程,线程,动态库,windows内存管理,异常处理。。。 Visual C++ Windows Shell Programming by Dino Esposito. For anyone interested in the visual and user-friendly aspects of windows, this book covers writing extentions to the windows shell, working efficiently with files and drag and drop, customizing the taskbar and windows explorer, and numerous other tricks. Well worthwhile for anyone writing GUI apps in windows. Network Programming for Microsoft Windows Up to date information on network programming, including NetBIOS, mailslots and pipes, and of course the ever important windows sockets, complete with winsock2 and raw sockets. Also contains specific information on the various windows platforms including 2000 and CE.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值