잊지 않겠습니다.

'.NET Framework'에 해당되는 글 131건

  1. 2009.01.07 ADO .NET
  2. 2009.01.07 Access Permissions for Web Applications
  3. 2009.01.07 Remote object의 수명 주기
  4. 2009.01.07 MBV Object
  5. 2009.01.07 MBR-WKO 분산 프로그래밍
  6. 2009.01.07 MBR-CAO 분산 프로그래밍
  7. 2009.01.07 MBR Object
  8. 2009.01.07 .NET Remoting
  9. 2009.01.07 .NET Framework 의 구성
  10. 2009.01.07 .NET Framework In Mono

ADO .NET

.NET Framework 2009. 1. 7. 10:58

ADO .NET에서의 데이터 검색

   1. 기존의 Key를 기반으로 Row를 받는다면 DataTable.Rows.Find를 사용
   2. 검색조건을 만족하는 행을 컨트롤에 바인드 시켜야지 된다면 DataView를 사용
         1. 가장 중요한 내용은 컨트롤에 바인드 되는 내용에 대한 고려
         2. 컨트롤에 바인드를 목적으로 가지고 있다면 DataView를 필수적으로 이용
         3. 키열이 아닌 열의 조합에 대해서 반복적인 검색을 수행할것이라면 DataView.Find를 이용
         4. 그 외의 모든 경우, DataTable.Select 사용

DataSet에서의 데이터의 검색은 DataTable 이나 SELECT 구문에서의 값의 리턴을 통해서 얻어올수 있다.

그러나, Off_Line 데이터를 원칙으로 가지고 있으며, 매번 데이터의 검색시마다 Query문을 넘기게 되는 것은 DB Server에 매우 큰 부하를 가지고 오게 된다. 따라서, Off_Line으로 데이터를 가지고 온 후에, 데이터를 검색, 수정, 추가 후 최종적으로 업데이트 시키는 것이 보다 더 나은 데이터 이용 이라고 할 수 있다.[물론 대부분의 경우, 어떠한 특정한 경우에서는 맞지 않는 말이라고 할 수 있다.

.NET Framework에서의 데이터 검색과 필터링 방법은 다음과 같다.
1. DataTable 상에서의 객체의 검색과 필터링 기능 이용
2. DataView를 이용

* DataView를 이용하는 이유
1) DataView의 주요 기능은 Windows Form과Web Form 모두에서 데이터를 바인딩할 수 있도록 허용
2) 검색의 자유로운 변화[DataTable의 경우에는 Primary Key로만 검색이 가능하다]


CommandBuilder

사용자가 입력하는 텍스트 명령을 사용하는 쿼리 도구를 통해서와 같이 SelectCommand가 런타임에 동적으로 지정되는 경우에는 디자인 타임에 적절한 InsertCommand, UpdateCommand 또는 DeleteCommand를 지정할 수 없습니다. DataTable이 단일 데이터베이스 테이블에 매핑되거나 단일 데이터베이스 테이블에서 생성되면 CommandBuilder 개체를 사용하여 DataAdapter의 DeleteCommand, InsertCommand 및 UpdateCommand를 자동으로 생성할 수 있습니다.

자동 명령 생성이 작동하도록 하려면 최소한 SelectCommand 속성은 설정해야 합니다. SelectCommand에서 검색하는 테이블 스키마에 따라 자동 생성되는 INSERT, UPDATE 및 DELETE 문의 구문이 결정됩니다.

CommandBuilder 는 삽입, 업데이트 및 삭제 명령을 생성하는 데 필요한 메타데이터를 반환하기 위해 SelectCommand를 실행해야 합니다. 결과적으로 데이터 소스에 추가로 이동해야 하므로 성능이 떨어질 수 있습니다. 최적의 성능을 얻으려면 CommandBuilder를 사용하는 대신 명령을 명시적으로 지정합니다.

SelectCommand는 또한 기본 키 열이나 고유 열을 적어도 하나는 반환해야 합니다. 이러한 열이 없으면 InvalidOperation 예외가 생성되고 명령이 생성되지 않습니다.

CommandBuilder 는 DataAdapter와 연결될 때 DataAdapter의 InsertCommand, UpdateCommand 및 DeleteCommand 속성이 null 참조인 경우 자동으로 이러한 속성을 생성합니다. 속성에 대한 Command가 이미 있으면 기존 Command가 사용됩니다.

테이블을 두 개 이상 조인하여 만든 데이터베이스 뷰는 단일 데이터베이스 테이블로 간주되지 않습니다. 이 경우 CommandBuilder를 사용하여 명령을 자동으로 생성할 수 없으므로 사용자가 명령을 명시적으로 지정해야 합니다. DataSet에 대한 업데이트를 다시 데이터 소스에 적용하기 위한 명령을 명시적으로 설정하는 것에 대한 자세한 내용은 DataAdapter 및 DataSet을 사용하여 데이터베이스 업데이트를 참조하십시오.

출 력 매개 변수를 다시 DataSet의 업데이트된 행에 매핑하려는 경우도 있습니다. 자동 생성된 ID 필드의 값이나 타임스탬프를 데이터 소스에서 검색하는 작업은 일반적인 작업입니다. CommandBuilder는 기본적으로 출력 매개 변수를 업데이트된 행의 열에 매핑하지 않습니다. 이 경우 사용자가 명시적으로 명령을 지정해야 합니다. 자동 생성되는 ID 필드를 삽입된 행의 열에 다시 매핑하는 예제는 Identity 또는 Autonumber 값 검색을 참조하십시오.


 SQL Query를 자동으로 생성해주는 Class..

그런데, Query를 생성하기 위해서 다시 DB를 Access한다는 것이 좀 애매하다는 생각이 든다.


DataTable에서의 Data 검색

  1. 기존의 Key를 기반으로 Row를 받는다면 DataTable.Rows.Find를 사용
  2. 검색조건을 만족하는 행을 컨트롤에 바인드 시켜야지 된다면 DataView를 사용
  • 가장 중요한 내용은 컨트롤에 바인드 되는 내용에 대한 고려
  • 컨트롤에 바인드를 목적으로 가지고 있다면 DataView를 필수적으로 이용
  • 키열이 아닌 열의 조합에 대해서 반복적인 검색을 수행할것이라면 DataView.Find를 이용
  • 그 외의 모든 경우, DataTable.Select 사용

DataView에서의 Data 검색

 DataSet에서의 데이터의 검색은 DataTable 이나 SELECT 구문에서의 값의 리턴을 통해서
얻어올수 있다.

그러나, Off_Line 데이터를 원칙으로 가지고 있으며, 매번 데이터의 검색시마다 Query문을
넘기게 되는 것은 DB Server에 매우 큰 부하를 가지고 오게 된다. 따라서, Off_Line으로 데이터를
가지고 온 후에, 데이터를 검색, 수정, 추가 후 최종적으로 업데이트 시키는 것이 보다 더 나은
데이터 이용 이라고 할 수 있다.[물론 대부분의 경우, 어떠한 특정한 경우에서는 맞지 않는 말이라고
할 수 있다.]

.NET Framework에서의 데이터 검색과 필터링 방법은 다음과 같다.
1. DataTable 상에서의 객체의 검색과 필터링 기능 이용
2. DataView를 이용

* DataView를 이용하는 이유
1) DataView의 주요 기능은 Windows Form과Web Form 모두에서 데이터를 바인딩할 수 있도록 허용
2) 검색의 자유로운 변화[DataTable의 경우에는 Primary Key로만 검색이 가능하다]

Posted by Y2K
,

Access Permissions for Web Applications

Like any applications, Web applications need access to various system resources, such as files or databases. These resources are usually protected by access levels granted to different users and groups.

In a Web application, it might not be the application user who is requesting access directly. Instead, the user communicates to the Web application using a browser, and the Web application then requests the resource. This indirect access can introduce an issue of access permission.

There are several strategies for managing access permissions in a Web application. The sections below provide an overview of each option. Links in the topic will point you to topics that contain more information.

Access through Windows Integrated Security

If your Web application runs in an intranet environment — if all users will be running Windows and are behind the same firewall — the application can access resources using Windows integrated security. In this strategy, all users are authenticated as soon as they log on to Windows. The authentication process generates a token containing information for that user. (The token does not contain the user's credentials, only a code indicating that the user has been authenticated.) The Web application can use the token when requesting a local resource. For example, a logged-in user requests a Web Forms page in Internet Explorer. The request is passed to Internet Information Services (IIS) and then to ASP.NET, which can use the user's authentication token to request access to a file on the server computer.

Windows integrated security is generally the most secure option for Web access permissions. If it is practical in your application, you should configure the application to use this option.

For details, see ASP.NET Authentication.

Anonymous Access Using the ASP.NET User Account

In most applications, users typically access Web applications anonymously — that is, they do not initially provide authentication credentials. In that case, the Web application has to assume (impersonate) some identity that it can use to request resources.

By default, when ASP.NET allows anonymous access, the application runs in the context of a special local (not domain) account. The user context depends on the operating system. In Windows 2000 and Windows XP, applications run under the account called ASPNET. In Windows Server 2003, the user context is called NETWORK SERVICE. These user accounts are created during the .NET Framework installation process with a unique, strong password, and are granted only limited permissions. The ASPNET or NETWORK SERVICE user can access only specific folders that are required to run a Web application, such as the \bin directory in which a Web application stores compiled files.

Note   IIS has a similar mechanism for mapping anonymous users to a specific local or domain user. You can use the IIS facility to remap anonymous access for all files in your application, not just ASP.NET files (Web Forms pages and controls). For details, see Microsoft Internet Information Server Security Overview.

If your Web application requires access to other resources on the Web server computer, you can grant permissions to the ASPNET or NETWORK SERVICE user as needed. For example, if the application needs to write a file to a directory, you will need to explicitly grant write permissions to the ASPNET or NETWORK SERVICE account in that directory.

Alternatively, you can specify a different user identity for ASP.NET to use when requesting resources. You can specify a user name (a local or domain user) in whose name requests are made. For details, see ASP.NET Process Identity. For details, see <processModel> Element. Or you can specify that ASP.NET instead run in a system (administrator) context.

Caution   Running ASP.NET applications in the system context allows them to run with administration permissions on the server. If users can take control of your application, they will then have free access to many critical resources on the server.

There are some resources that you cannot by default access using the default user context, because they require access to resources that need administrative-level privileges. For example, if your application needs to create a new event log category using methods in the System.Diagnostics namespace, it cannot do so if it is running in the context of the ASPNET or NETWORK SERVICE user. In that case, you need to either change the application context or make changes that will make the event log accessible to the ASP.NET user account.

Caution   Setting the process identity to a specific user name in place of the ASPNET or NETWORK SERVICE user identity requires that you provide a user name and a password that are both stored in the machine.config file. Storing any credential information can represent a security threat, because if someone manages to get access to the machine.config or if they gain administrator privileges on the Web server computer, they might be able to read or change this private information. Make the machine.config file read-only for all but administrative users. For details about setting the username and password in the machine.config file, see <processModel> Element.

Access Using Provided Credentials

Your Web application can also request resources by providing credentials at run time. This is not possible to all resources, but can work for resources that accept a username and password, such as databases that accept a connection string.

Security Note   Accessing SQL Server using a connection string (known as "mixed mode") is less secure than using Windows integrated security. If the Web server and SQL server are running on the same computer, you can easily and securely use Windows integrated security.

You can get the credentials from the user directly, using Basic, Digest, or Forms authentication. For example, your application might prompt the user to supply a username and password when the user wants to access a restricted part of your site. For details about authentication, see IIS Authentication and ASP.NET Authentication.

Security Note   Prompting the user for a username and password in your application is a potential security threat. Credential information must be transferred from the browser to your server, and ordinary HTTP transfers are unencrypted. For best security when prompting users to provide credentials in your application, you should use secure sockets layer (SSL), which encrypts information before sending it from the browser to the server. For details, see Using Secure Sockets Layer.

After getting credentials from a user, you can pass them on when requesting the resource. For databases, you can usually plug the username and password into a connection string when opening a connection. For other resources, you can call a Windows API called LogonUser that establishes a user context for the information you provide and uses it to request access to a resource.

Sometimes it is more convenient to store credentials directly with your application. For example, it is possible to create a database connection string that hard-codes a user name and password into it. For details, see Accessing SQL Server with Explicit Credentials.

Security Note   Hard-coding credentials into an application is generally not advised, because the information can be read, even if it has been compiled. Even if you do hard-code any user credential information into an application, you should never use a user name that would give a user anything but the most minimal access privileges to a resource.

If you do choose to store credentials as part of an application, you should make an attempt to protect them. One possibility is to use the Data Protection API (DPAPI). For details, see the technical article Windows Data Protection on MSDN Online (http://msdn.microsoft.com/library/de...asp?frame=true).

Accessing Remote Resources (Delegation)

Sometimes the resource required by your application is on a computer other than the Web server. This is recommended for some resources, such as a database. In that case, the application must make a request to the remote computer on behalf of the user. This process is called delegation.

As with any request for resources, a request to a remote computer must include appropriate credentials. If your application allows anonymous access, IIS and ASP.NET do not have the user's credentials and therefore cannot use them during delegation to access remote resources. In that case, you can:

  • Get explicit user credentials by prompting for them. The application can then pass these on to the remote computer as needed. If you are working with a SQL Server, you can add the user credentials to a connection string. For an example, see Accessing SQL Server with Explicit Credentials.
  • Change the user context of the Web application from the ASPNET or NETWORK SERVICE user to a specific domain user whose credentials can be passed to the remote computer. For an example, see Accessing SQL Server Using a Mapped Windows Domain User.

Note   If you are running the browser and Web server on the same computer and you are logged on as a domain user, delegation to a remote computer is not a problem, since the IIS computer has your credentials. Although this is a common testing scenario, it is a very rare production scenario. If possible, always test access permissions by running the browser and Web server on separate computers.

Posted by Y2K
,

MBR, Singleton 형식에서만 객체의 수명 임대가 이루어진다.

   COM에서 "singleton"이라는 용어는 클라이언트에서 개체에 대한 참조를 가지고 있는 한 해당 개체는 메모리에서 삭제되지 않음을 의미했습니다. 그러나 .NET Remoting에서 Singleton 개체는 해당 개체에 대해 지정된 수명 임대의 영향을 받으므로 클라이언트에서 현재 해당 개체에 대한 참조를 보유하고 있는 경우라도 개체가 재생될 수 있습니다.MarshalByRefObject의 InitializeLifetimeService 메서드가 null 참조(Visual Basic에서는 Nothing)를 반환하도록 재정의하면 첫 번째 형식의 Singleton 개체를 만들 수 있습니다. 이렇게 하면 호스트 응용 프로그램 도메인이 실행되는 동안은 개체를 메모리에 유지할 수 있습니다. 자세한 내용은 수명 임대를 참조하십시오. 원격 구성 파일에서 초기 임대 기간을 구성하면 두 번째 형식의 Singleton 개체를 만들 수 있습니다.

  

MBR, SingelCall 형식에서는 데이터의 수명에 대한 논의가 이루어지지 않는다.

: 객체가 new 또는 Activator에 의해서 생성이 될때, Deep-Copy가 이루어지고, 클라이언트에서는 Copy본을 사용하게 된다.

: 서버는 객체에 대한 참조를 모두 잃어버린다.

Posted by Y2K
,

MBV Object

.NET Framework 2009. 1. 7. 10:55

 MBV(Marshla-By-Value) 개체 즉, 값으로 마샬링되는 개체는 ISerializable을 구현하여 해당 개체의 serialization을 구현하거나 해당 개체를 자동으로 serialize하도록 시스템에 알리는 SerializableAttribute로 데코레이트되어 개체의 serialization 규칙을 선언하지만 MarshalByRefObject를 확장하지는 않습니다. 

원격 시스템에서는 이러한 개체의 전체 복사본을 만들고 이 복사본을 호출하는 응용 프로그램 도메인에 전달합니다. 호출자의 응용 프로그램 도메인에 복사본이 있으면 해당 복사본에 대한 호출은 이 복사본에 대해 직접 수행됩니다. 

또한 인수로 전달되는 MBV 개체도 값으로 전달됩니다.

클래스 인스턴스를 응용 프로그램 또는 컨텍스트 경계를 넘어 값으로 전달하려는 경우, SerializableAttribute 특성을 선언하거나 ISerializable을 구현하는 것 외에는 어떤 작업도 수행할 필요가 없습니다. 

반면 게시된 개체의 크기가 매우 큰 경우 사용량이 많은 네트워크에서 전체 복사본을 전달하는 것은 응용 프로그램에 최선의 선택이 아닐 수도 있습니다. 또한 복사된 개체의 상태에 대한 변경 내용은 원래 응용 프로그램 도메인의 원본 개체에 다시 전달되지 않습니다. 추상적인 수준에서 이 시나리오는 클라이언트 브라우저에 의해 요청되는 정적 HTML 페이지의 시나리오와 유사합니다. 즉, 서버에서는 파일을 복사하고 스트림에 써서 보낸 다음에는 해당 파일에 대해 잊어버립니다. 후속 요청은 단지 다른 복사본에 대한 다른 요청일 뿐입니다.

Posted by Y2K
,
1.서버 어셈블리
  • 원격 객체를 갖는 일반 어셈블리를 호스트한다.

   1) Channel을 등록한다.

       System.Runtime.Remoting.Channels.Http.HttpChannel c = new HttpChannel(9113);

       ChannelServices.RegisterChannel(c);

   2) WKO 형식을 등록한다.

          RemotingConfiguration.RegisterWellKnownServiceType(typeof(Class Type), "알려진 이름", WellKnownObjectMode.Singleton); 

  • config 파일을 이용한 서버 어셈블리의 등록
    • RemotingConfiguration.Config(<<Config파일 네임>>)

<configuration>
 <system.runtime.remoting>
  <application>     
   <service>
    <wellknown mode = "Singleton" <<서버 등록 모드>> type ="SimpleRemotingAsm.RemoteMessageObject, 
    DistrubuteApp" <<Class의 풀 네임, 파일 이름(dll)>>  objectUri="RemoteMessageObject.soap"/> <<Uri>>
   </service>
   <channels>
    <channel ref ="http" port="32469"/>
   </channels>
  </application>
 </system.runtime.remoting>
</configuration>

   

2. 클라이언트 어셈블리

1) Channel의 생성

HttpChannel c = new HttpChannel();

ChannelServices.RegisterChannel(c);

2) 원격 WKO 형식의 Proxy를 가지고 온다.

object remoteObject = Activator.GetObject(typeof(Class Type), "uri");

3) 원격 객체를 사용한다. : SingleCell형식의 경우, 이때에 객체가 생성된다.

  • config 파일을 이용한 클라이언트 어셈블리에서의 Remote 객체 사용

<configuration>
  <system.runtime.remoting>
    <application>
      <client displayName ="SimpleRemoteObjectClient">
        <wellknown
            type ="Class의 FullName, 파일이름"
            url ="fullURI" />
      </client>
      <channels>
        <channel ref ="http"/>
      </channels>
    </application>
  </system.runtime.remoting>
</configuration>

Posted by Y2K
,
  • Singletone, SingleCell 과는 관계가 없다.
    • Client에서 상태를 가지고 있기 때문에, 그 상태를 보고 판단이 가능한 객체를 만들어주게 된다.
    • 단일 메소드 호출을 넘어 항상 살아있게 된다 

1. 서버 어셈블리

[Hard Cording]

RemotingConfiguration.RegisterActivatedServiceType(typeof(Object 이름));

 

[Config]

<configuration>
  <system.runtime.remoting>
    <application>
      <service>
        <activated type ="CarGeneralAsm.CarProvider, CarGeneralAsm"/>
      </service>
      <channels>
        <channel ref ="http" port ="32469"/>
      </channels>
    </application>
  </system.runtime.remoting>
</configuration>

  

  

2. 클라이언트 어셈블리

[Hard Coding]

RemoteConfiguration.GetActivator(ObjectName, URI) <== WKO와 동일

  

[Config]

<configuration>
  <system.runtime.remoting>
    <application>
      <client displayName ="carClient" url ="http://localhost:32469">
        <activated type ="CarGeneralAsm.CarProvider, CarGeneralAsm"/>
      </client>
      <channels>
        <channel ref ="http"/>
      </channels>
    </application>
  </system.runtime.remoting>
</configuration>

Posted by Y2K
,

MBR Object

.NET Framework 2009. 1. 7. 10:51
  • WKO (well known object)
    • 서버 응용프로그램 도매인에 의해서 수명이 직접 제어된다.
    • Client에서는 잘 알려진 문자열 이름을 통해서 이 원격 형식을 활성화 시켜준다.
    • 반드시 기본 생성자가 필요하다!!
    • 상태 기반 구성을 가진다.
      • singleton
        • 여러 client에서 요청을 받는 원격 형식의 instance를 하나만 생성한다.
        • 여러 client가 동시에 하나의 메소드를 호출하게 된다.
        • CLR에서 각각의 client의 호출을 새로운 Thread에 위치하게 해서 구현한다.(Thread atomic에 대해서 안전하지 못하다. 프로그래머의 책임)
      • singlecelll
        • 하나의 메소드가 호출될 때에만 존재하는 WKO 형식이다.
        • 단일 호출 객체는 언제나 무상태(statless) 객체이기 때문에 동시 접근에 훨씬 유리하다.
    • Method나 Property가 활성화 될 때에 WKO 객체가 생성되고, Method가 호출되게 된다.

object remoteObj = Activator.GetObject(/*잘 알려진 문자열 이름*/); -- WKO 선언, 생성되지는 않음

RemoteMessageObject simpleObj = (RemoteMessageObject) remoteObj;

Console.WriteLine(simpleObj.ReturnMessage()); -- Method가 수행되면서 WKO의 생성

    

  • CAO (client activated object)
    • Client에서 사용자 지정 생성자가 가능하다.
    • Client에서의 응용 프로그램 도매인에 의해서 제어되는 객체가 된다.
    • 기본 생성자 이외의 생성자로 생성 가능하다.
    • 상태를 갖는 객체가 된다. 따라서, Client에서의 전역변수로서의 객체 사용이 가능하다.
    • new 또는 Activator.GetObject로 호출될 때에 생성된다.
    • 시간에 따른 GC가 이루어진다.
    • Client에서의 객체 사용의 범위를 결정한다. 기본으로 5분동안의 Life cycle을 갖는다. 

클라이언트 활성 개체는 해당 개체가 마치 클라이언트에 대해 로컬인 것처럼 호출하는 응용 프로그램 도메인에서 수명을 제어하는 개체입니다. 클라이언트 활성화를 사용하는 경우, 클라이언트에서 서버 개체의 인스턴스를 만들려고 하면 서버에 대한 라운드트립이 발생하며, 서버에서 원격 개체를 만들 때 반환된 개체 참조(ObjRef)를 사용하여 클라이언트 프록시가 만들어집니다. 클라이언트에서 클라이언트 활성 형식의 인스턴스를 만들 때마다 해당 인스턴스는 임대가 만료되고 메모리가 재생될 때까지 해당 특정 클라이언트에서 해당 특정 참조만 서비스합니다. 호출하는 응용 프로그램 도메인에서 원격 형식의 새 인스턴스를 두 개 만드는 경우 각 클라이언트 참조에서는 참조가 반환된 서버 응용 프로그램 도메인에서 특정 인스턴스만 호출합니다.    

COM에서 클라이언트는 개체에 대한 참조를 메모리에 보유합니다. 마지막 클라이언트에서 마지막 참조를 해제하면 해당 개체는 자체를 삭제할 수 있습니다. 클라이언트 활성화를 사용하는 경우 클라이언트에서는 서버 개체의 수명을 동일하게 제어할 수 있지만, 참조를 유지하거나 서버 또는 클라이언트가 계속 존재하는지 확인하기 위해 지속적으로 Ping을 실행해야 하는 복잡함은 없습니다. 대신 클라이언트 활성 개체에서는 수명 임대를 사용하여 해당 개체가 계속 존재할 시간을 결정합니다. 클라이언트에서는 원격 개체를 만들 때 해당 개체가 존재할 기본 시간을 지정할 수 있습니다. 원격 개체는 이 기본 수명 제한에 도달하는 경우 클라이언트에 연결하여 해당 개체가 계속 존재해야 하는지 여부와 계속 존재해야 하는 경우에는 기본 수명을 얼마나 더 늘려야 하는지를 확인합니다. 클라이언트를 현재 사용할 수 없는 경우를 대비해 해당 개체가 가비지 수집되도록 표시되기 전에 서버 개체에서 클라이언트에 연결을 시도하면서 대기해야 하는 기본 시간도 지정됩니다. 클라이언트에서는 서버 응용 프로그램 도메인이 해제될 때까지 원격 개체가 재생되는 것을 효율적으로 방지하기 위해 기본 수명이 무기한으로 설정되도록 요청할 수도 있습니다. 이 클라이언트 활성 개체의 무기한 수명과 서버 활성 개체의 무기한 수명 사이의 차이점은 무기한 서버 활성 개체의 경우 해당 형식에 대한 모든 클라이언트 요청을 처리하는 반면 클라이언트 활성 인스턴스의 경우 해당 클라이언트와 해당 인스턴스를 만든 참조만 처리한다는 점입니다.

Posted by Y2K
,

.NET Remoting

.NET Framework 2009. 1. 7. 10:50

.NET Framework에서 응용프로그램 도매인은 System.AppDomain안에서 움직이는 논리적인 경계로서 나뉘게 된다.

이러한 논리적인 경계내에서 나뉘어진 응용프로그램간의 통신을 일컬여 .NET Remoting이라고 칭한다.

.NET Remoting은 다음과 같이 구성된다.

  1. 동일한 프로세스(같은 컴퓨터안에 있는) 두 응용 프로그램 도매인
  2. 동일한 머신의 개별 프로세스 안에 있는 두 응용 프로그램 도매인
  3. 서로 다른 머신의 개별 프로세스 안에 있는 두 응용 프로그램 도매인

        

.NET Remoting의 이용

System.Runtime.Remoting안에 선언된 형식을 주로 이용한다.각 AppDomain간의 통신은 Channel을 통해서 이루어지며, 이 Channel은 두가지 형식으로 되어 있다.

1) HttpChannel : HttpChannel Class 형식으로 표현되며, SOAP Formatter를 이용해서 데이터가 변환된다.

  • 데이터의 크기가 Binary Formatter에 비하여 크다.
  • 데이터가 방화벽에 막힐 수도 있다.

2) TcpChannel : TcpChannel Class 형식으로 표현되며, Binary Formatter를 이용해서 데이터가 변환된다.

  • 데이터가 크다.
  • 데이터가 방화벽에 막힐 염려가 적다.

2개 이상의 Channel을 같이 사용하는 경우에는 한 AppDomain에서의 Channel은 항시 다른 이름과 Port를 가지고 있어야지 된다. 

각 이름과 Port를 2개 이상 생성을 시켜서 Channel을 항상 다른 상태로 만들어야지 된다.

System.Collections.IDictionary prop = new System.Collections.Hashtable();
prop["name"] = "tcp1";
prop["port"] = "9113";
ChannelServices.RegisterChannel(new TcpChannel(prop, null, null));   

원격 객체의 종류

MBR(marshal by reference)
  • 호출자가 원격 객체에 대한 proxy를 받아준다.
  • 구현 : System.MarshalByRefObject class에서 파생된다.
MBV(marshal by value)
  • 호출자가 원격 객체의 객체 사본을 받는다. (Client copy본을 만들어준다.)
  • 구현 : Serializable 속성으로 구현한다.

Serial되지도 않고, System.MarshalByRefObject에서 상속되지도 않는 class는 만들어진 응용 프로그램 도매인 안에서만 활성화 되며, 사용될 수 있다. (Contextound type이 된다.)  

  • 서버 활성 개체는 필요할 때만 서버에서 만들어집니다. 즉, new 또는 Activator.GetObject를 호출하여 클라이언트 프록시를 만들 때가 아니라 클라이언트에서 해당 프록시에 대한 첫 번째 메서드를 호출할 때 만들어집니다. 자세한 내용은 서버 활성화를 참조하십시오.
  • Singleton 개체는 해당 개체에 대한 클라이언트의 수에 상관없이 항상 하나의 인스턴스만 있으며 기본 수명을 가지는 개체입니다.클라이언트에서는 수명 임대 시스템을 사용하여 Singleton 인스턴스의 수명에 관여합니다. 자세한 내용은수명 임대를 참조하십시오.
  • 개체를 SingleCall 개체로 구성하면 시스템에서는 클라이언트에서 메서드를 호출할 때마다 새 개체를 만듭니다. 클라이언트가 각 호출에서 새 인스턴스에 대한 참조를 얻기 때문에 SingleCall 형식은 수명 임대 시스템에 관여하지 않습니다.        

Singleton 형식은 한 번에 하나 이상의 인스턴스를 가질 수 없습니다. 하나의 인스턴스가 있는 경우 모든 클라이언트 요청은 해당 인스턴스에서 처리됩니다. 인스턴스가 없는 경우에는 서버에서 인스턴스를 만들며 모든 후속 클라이언트 요청은 이 인스턴스에서 처리됩니다. Singleton 형식에는 기본 수명이 연관되어 있지 않으므로 한 번에 하나 이상의 인스턴스를 사용할 수 없는 경우라도 클라이언트에서 항상 원격화할 수 있는 클래스의 동일한 인스턴스에 대한 참조를 받는 것은 아닙니다.

SingleCall 형식은 항상 클라이언트 요청마다 하나의 인스턴스를 가집니다. 다음 메서드 호출은 시스템에서 이전 인스턴스를 아직 재생하지 않은 경우에도 다른 서버 인스턴스에 의해 처리됩니다. SingleCall 형식은 수명 임대 시스템에 관여하지 않습니다.

Posted by Y2K
,

제목이 너무나도 거창한 제목이 되어버렸지만... 이런 제목 이외에는 적을 내용이 없어서 이런 제목으로 밖에 못적겠다. --;

  

d0037487_489d8a444c8b5.png 

 여기에서 3.5에서 구현된 LINQ, ADO.NET Entity Framework는 결국은 Data의 object화 라는 말로 표현할 수 있다.

MS가 이제는 시스템기반이 아닌 데이터를 어떻게 다루고, 그 데이터를 어떻게 하느냐에 대한 관심으로 넘어가고 있는 단적인 내용이 아닐까 하는 생각을 하게 만든다.

  

먼저, LINQ를 사용해보면서, MS에서 이야기하는 Data의 object화는 ruby on rails에서 나온 개념과 너무나도 유사한 것이 재미있다는 생각도 들고, ruby를 잠시 공부해보면서 이렇게 멋진 내용이 있다는 것에 대해서 감탄을 하고 있었는데. 결국은 MS에서 그대로 따라가는 것이 좋은것은 다들 좋다고 생각하는 것 같다.

  

그리고, 차기 버젼에서 나올 기술들은 둘다 "P"를 가지고 있는데... 

이는 둘다 Parallel의 약자이다.  

  

Task Parallel Library, Parallel Language Integrated Query 둘다 multi-processor 기반의 Library로, 기존 single-processor에서는 큰 성능향상이 나타나지 않음을 MS에서도 제시하고 있다. (“Parallel Performance: Optimize Managed Code For Multi-Core Machines: http://msdn2.microsoft.com/en-us/magazine/cc163340.aspx”)

  

그렇다하더라도.. 무언가 새로운 것은 계속 만들어져가고 있고, 그 새로운 것들을 이용한 막강한 기능은 계속해서 손에 쥐어지고 있다. 보다 더 나은 S/W를 만들기 위한 방법은 계속해서 제시되어가고 있는데... 왜 사람은 계속해서 오래된 생각만을 계속하게 되는 것일까.

  

과연 1+1이 2가 되는 것이 사람일까?  

Posted by Y2K
,

I can't write Hangule on linux system(openSUSE 10.3).

 

with mono 1.9.1(beta)

1) use C# 3.0 feature

2) can use LINQ.

3) can use System.Core like C# 3.5

4) can use visual IDE enviroment.

 

-> It's Excellant! T_T

 

Screenshot.png

: it's mono development.

it can check syntec like visual studio but can't check linq syntex. but it's very fast.

 

download mono-project vm.(VMWare Image)

http://www.go-mono.com/mono-downloads/download.html

Posted by Y2K
,