国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Delphi > 正文

Delphi2005學(xué)習(xí)筆記4——再談NameSpace和Dll以及Package

2019-11-18 18:07:26
字體:
供稿:網(wǎng)友
今天在BDN中看到一篇文章
http://bdn.borland.com/article/0,1410,32765,00.html

重要的部分摘抄如下

Executive Summary

          Namespaces do not affect Delphi for Win32.

          Namespaces are PRoduced based on the unit name as follows:

          If a unit name is dotted then the unit name up to the last dot is used.

          If it is not dotted then the default namespace is used.

          If there is no default namespace then the unit name is used.

          Code converted from Delphi 8 may require some modifications.

          Always use Packages not Libraries to create shareable assemblies.

          Delphi will always refer to types by their full unit name.

          Other languages will need to refer to types using their namespace.

          asp.net declarations, configuration files and .NET reflection always refer to types by their namespace.

          If multiple units emit a public type with the same name into the same namespace, the assembly may be unusable

1)     Always Use Packages

Borland has always recommended not using library projects to create assemblies. In Delphi 2005, the compiler is stricter and will no longer allow you to compile an application referencing a Delphi ‘library’.
Always use a package project to create .NET assemblies.

However, as with anything, there are exceptions to the rule and there are several situations where you need to use the namespace even though you are coding in Delphi.

 

One example is when you are using tags in ASPX, ASCX or ASMX files. If you create a web page called TWebForm in the file Application.­Pages.­WebForm1.­­pas then the page tag would be:

 

<%@Page Language="c#" Codebehind="WebForm1.pas" Inherits="Application.Pages.TWebForm1"%>

 

Another is when passing type information to .NET in the form of strings, especially when using reflection based APIs and configuration files:

 

var c:TypeConverter;

c:=Assembly.CreateInstance('Sample.Controls.TConverter');

 

This slight difference commonly trips people up and is something you need to be careful of, especially when porting code from Delphi 8 or converting code from other languages.

這就解釋了我原來的疑問,在D2005中,新建一個.Net Dll,編譯,在別的編譯器中(C#),可以使用,但是在Delphi中自己卻不能用,雖然用薄可以解決問題,但是包中添加資源很不方便,真是不知道Borland是怎么想的。



上一篇:delphi7找不到TBDEClientDataSet控件的解決方案

下一篇:Delphi幫助里的虛擬鍵值表

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
學(xué)習(xí)交流
熱門圖片

新聞熱點

疑難解答

圖片精選

網(wǎng)友關(guān)注

主站蜘蛛池模板: 夹江县| 金沙县| 辰溪县| 宜阳县| 安康市| 临武县| 锡林浩特市| 阿巴嘎旗| 车险| 瑞昌市| 如东县| 五台县| 沈阳市| 水城县| 墨脱县| 开鲁县| 汽车| 临夏市| 墨江| 东阿县| 陇南市| 阿拉尔市| 温泉县| 阿荣旗| 南涧| 故城县| 修水县| 宁化县| 镇平县| 黄梅县| 叶城县| 安西县| 平昌县| 平邑县| 鄂托克旗| 双桥区| 吕梁市| 黎城县| 江山市| 闵行区| 安多县|