'.NET'에 해당되는 글 2건

  1. 2008/01/08 초 간단 C# 시리즈 첫 번째 이야기!!
  2. 2007/01/23 Assembly Registration Tool (Regasm.exe)
C#2008/01/08 03:45

초 간단 C# 시리즈 첫 번째 이야기!!

Document Comment [ 난이도 : ★☆☆☆☆ ]

 

2008 1 8일 화요일

김대욱(kdw234@naver.com)

http://kdw234.tistory.com

 

녕하세요. 초 간단 C#의 필자 김대욱이라고 합니다. 일단 첫 연재이니만큼 간단한 소개와 인사로 시작하는 것이 좋을 것 같아 인사 드립니다. 저는 현재 아주대학교 정보 및 컴퓨터공학부에 재학 중이며 Microsoft Student Partner 및 삼성소프트웨어멤버십에서 활동하고 있습니다.

 

초 간단 C#은 개발을 하면서 자주 사용되는 기능들을 선정하여 쉬운 설명과 다양한 예제를 통해 활용하는 방법에 대해 알려드리고자 작성하는 문서입니다. 본 문서는 Visual Studio 2005 .Net Framework 2.0을 기반으로 작성될 예정이고,  상황에 따라 누구나 활용할 수 있는 형태의 기술문서 제작이 목표인 만큼 읽으시다가 이해가 되지 않으시는 부분이나 다른 내용의 연재를 원하시면 언제든지 메일(kdw234@naver.com) 또는 블로그(http://kdw234.tistory.com)에 글 남겨주시면 참고 하도록 하겠습니다. 그럼 시작 하도록 하겠습니다.

 

번 장에서는 Document Comment 즉 문서 주석에 대해서 소개해 드리려고 합니다.  문서주석이란 소스 코드 필드에 XML 태그를 포함하는 특수 주석을 포함하여 코드에 대한 설명과 구조를 정리하고 Intellisense를 지원하며  구조를 문서를 만들 수 있는 기능입니다.

 

아직 감이 잘 안 오시나요?  그림을 보시면 이해가 빠르실 겁니다. 아래 그림은 SumValue라는 함수가 Intellisense를 통해 나오는 화면 입니다. 두 그림의 차이가 보이시나요?

 

 

사용자 삽입 이미지

 

똑 같은 함수지만 왼쪽 그림은 함수에 대한 설명이 없고 오른쪽은 함수 설명이 친절하게 되 있습니다..

SumValue라는 함수의 경우 이름 자체에서 값을 더한다 라는 의미가 있으므로 굳이 설명이 없어도 이해하는데 있어 큰 문제는 없겠지만 함수 이름이 a 혹은 b 이런 식으로 함수의 내용을 알 수 없는 함수 일 경우 이해 하기 힘들겠죠?

 

그럼 코드상으로는 어떤 차이가 있는지 보시겠습니다.  먼저 첫 번째 그림의 코드입니다.

 

사용자 삽입 이미지


차이가 보이시나요? 첫 번째 방법은 일반적으로 개발자들이 함수에 대한 주석을 달 때 사용하는 주석 방법입니다. 하지만 위와 같은 형식의 주석은 개발자 마다 모두 다르기 때문에 Intellisense에서는 주석을 인식하지 못하고 함수에 대한 자세한 내용을 제공 할 수 없습니다. 그럼 두 번째 코드의 코드입니다.

 

사용자 삽입 이미지

 

조금 특이하게 주석이 달려 있습니다. 바로 C#에서 권장하는 문서 주석의 형식으로 주석이 작성되어 있는 모습인데요. XML태그로 함수에 대한 기본적인 설명부터 파라미터에 대한 설명, 리턴값에 대한 설명또한 추가 할 수 있습니다. Intellisense가 주석의 내용을 이해하여 코딩 시 즉각적으로 함수, 파라미터 등에 대한 설명을 제공받을 수 있습니다.

 

사용자 삽입 이미지

 

보기엔 별거 아닌 것처럼 보이겠지만 코드의 길이가 길어지고 선언하는 함수, 속성, 변수 등이 많아 질 경우 주석을 읽어보지 않아도 코딩 시 요약정보를 볼 수 있기 때문에 유용합니다. 그림과 같이 객체 브라우저에서도 요약 정보를 제공합니다.

 

사용자 삽입 이미지



문서 주석은 참조하는 코드블록의 바로 앞에 추가 함으로서 사용 가능합니다. 아래 그림과 같이 함수의 기본적인 구조를 만듭니다.  그 다음 함수의 윗부분으로 커서를 옮기고  /// 이렇게 / 3번 입력해줍니다. 그럼 자동으로 함수의 형태에 알맞은 형태의 주석 구조가 완성되며 해당하는 부분에 설명을 넣어주시면 됩니다.

 

    

사용자 삽입 이미지

 

문서 주석에서는 아래와 같은 태그들을 지원합니다. 각 태그들에 대한 자세한 설명은 MSDN 을 참조하시기 바랍니다.

 

<c> , <para> ,<code> , <example>, <paramref> ,<summary> ,<remarks> ,<typeparamref> ,<list> ,<returns> ,<value>

 

보다 더 자세한 내용은 MSDN홈페이지를 참조하시기 바랍니다.

 

문서 주석에 대한 권장 태그(C# 프로그래밍 가이드) : http://msdn2.microsoft.com/ko-kr/library/5ast78ax(VS.80).aspx

 

그럼 이것으로 초간단 C# 첫 번째 시간을 마치도록 하겠습니다. 질문 또는 다음 연재 내용에 대한 제안은 리플,이메일,블로그 등으로 자유롭게 해주시면 감사하겠습니다.


크리에이티브 커먼즈 라이선스
Creative Commons License
Posted by 곡스
knowledge2007/01/23 12:38
 
©2007 Microsoft Corporation. All rights reserved.
.NET Framework Tools 
Assembly Registration Tool (Regasm.exe) 

The Assembly Registration tool reads the metadata within an assembly and adds the necessary entries to the registry, which allows COM clients to create .NET Framework classes transparently. Once a class is registered, any COM client can use it as though the class were a COM class. The class is registered only once, when the assembly is installed. Instances of classes within the assembly cannot be created from COM until they are actually registered.

regasm assemblyFile [options]

Parameters

Parameter Description

assemblyFile

The assembly to be registered with COM.

Option Description

/codebase

Creates a Codebase entry in the registry. The Codebase entry specifies the file path for an assembly that is not installed in the global assembly cache. You should not specify this option if you will subsequently install the assembly that you are registering into the global assembly cache. The assemblyFile argument that you specify with the /codebase option must be a strong-named assembly [ http://msdn2.microsoft.com/en-us/library/wd40t7ad(VS.80).aspx ] .

/registered

Specifies that this tool will only refer to type libraries that have already been registered.

/asmpath:directory

Specifies a directory containing assembly references. Must be used with the /regfile option.

/nologo

Suppresses the Microsoft startup banner display.

/regfile [:regFile]

Generates the specified .reg file for the assembly, which contains the needed registry entries. Specifying this option does not change the registry. You cannot use this option with the /u or /tlb options.

/silent or /s

Suppresses the display of success messages.

/tlb [:typeLibFile]

Generates a type library from the specified assembly containing definitions of the accessible types defined within the assembly.

/unregister or /u

Unregisters the creatable classes found in assemblyFile. Omitting this option causes Regasm.exe to register the creatable classes in the assembly.

/verbose

Specifies verbose mode; displays a list of any referenced assemblies for which a type library needs to be generated, when specified with the /tlb option.

/? or /help

Displays command syntax and options for the tool.

NoteNote

The Regasm.exe command-line options are case insensitive. You only need to provide enough of the option to uniquely identify it. For example, /n is equivalent to /nologo and /t:outfile.tlb is equivalent to /tlb:outfile.tlb.

RemarksRemarks

You can use the /regfile option to generate a .reg file that contains the registry entries instead of making the changes directly to the registry. You can update the registry on a computer by importing the .reg file with the Registry Editor tool (Regedit.exe). Note that the .reg file does not contain any registry updates that can be made by user-defined register functions. Note that the /regfile option only emits registry entries for managed classes. This option does not emit entries for TypeLibIDs or InterfaceIDs.

When you specify the /tlb option, Regasm.exe generates and registers a type library describing the types found in the assembly. Regasm.exe places the generated type libraries in the current working directory or the directory specified for the output file. Generating a type library for an assembly that references other assemblies may cause several type libraries to be generated at once. You can use the type library to provide type information to development tools like Visual Studio 2005. You should not use the /tlb option if the assembly you are registering was produced by the Type Library Importer (Tlbimp.exe [ http://msdn2.microsoft.com/en-us/library/tt0cf3sx(VS.80).aspx ] ). You cannot export a type library from an assembly that was imported from a type library. Using the /tlb option has the same effect as using the Type Library Exporter (Tlbexp.exe [ http://msdn2.microsoft.com/en-us/library/hfzzah2c(VS.80).aspx ] ) and Regasm.exe, with the exception that Tlbexp.exe does not register the type library it produces. If you use the /tlb option to registered a type library, you can use /tlb option with the /unregister option to unregistered the type library. Using the two options together will unregister the type library and interface entries, which can clean the registry considerably.

When you register an assembly for use by COM, Regasm.exe adds entries to the registry on the local computer. More specifically, it creates version-dependent registry keys that allow multiple versions of the same assembly to run side by side on a computer. The first time an assembly is registered, one top-level key is created for the assembly and a unique subkey is created for the specific version. Each time you register a new version of the assembly, Regasm.exe creates a subkey for the new version.

For example, consider a scenario where you register the managed component, myComp.dll, version 1.0.0.0 for use by COM. Later, you register myComp.dll, version 2.0.0.0. You determine that all COM client applications on the computer are using myComp.dll version 2.0.0.0 and you decide to unregister myComponent.dll version 1.0.0.0. This registry scheme allows you to unregister myComp.dll version 1.0.0.0 because only the version 1.0.0.0 subkey is removed.

After registering an assembly using Regasm.exe, you can install it in the global assembly cache [ http://msdn2.microsoft.com/en-us/library/yf1d93sz(VS.80).aspx ] so that it can be activated from any COM client. If the assembly is only going to be activated by a single application, you can place it in that application's directory.

ExamplesExamples

The following command registers all public classes contained in myTest.dll.

regasm myTest.dll

The following command generates the file myTest.reg, which contains all the necessary registry entries. This command does not update the registry.

regasm myTest.dll /regfile:myTest.reg

The following command registers all public classes contained in myTest.dll, and generates and registers the type library myTest.tlb, which contains definitions of all the public types defined in myTest.dll.

regasm myTest.dll /tlb:myTest.tlb
See AlsoSee Also

Reference

.NET Framework Tools [ http://msdn2.microsoft.com/en-us/library/d9kh6s92(VS.80).aspx ]
Type Library Exporter (Tlbexp.exe) [ http://msdn2.microsoft.com/en-us/library/hfzzah2c(VS.80).aspx ]
Type Library Importer (Tlbimp.exe) [ http://msdn2.microsoft.com/en-us/library/tt0cf3sx(VS.80).aspx ]
SDK Command Prompt [ http://msdn2.microsoft.com/en-us/library/ms229859(VS.80).aspx ]

Concepts

Registering Assemblies with COM [ http://msdn2.microsoft.com/en-us/library/h627s4zy(VS.80).aspx ]

 
Community Content

 
Warning: /tlb also registers the type library     Last edit: 11:41 PM by Adam_Nathan  
It's not listed above in the description of the /tlb switch, but it both exports and registers the type library.  If you want to produce a type library without registering it, use tlbexp.exe.
크리에이티브 커먼즈 라이선스
Creative Commons License
Posted by 곡스