Delphi2005学习笔记4——再谈NameSpace和Dll以及Package[1]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 shidongdong 的 blog

今天在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');

本文关键:Delphi2005学习笔记4——再谈NameSpace和Dll以及Package
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top