http://msdn.microsoft.com/ko-kr/library/s7za025w(VS.80).aspx

방법: Windows Forms DataGridView 컨트롤에 데이터 바인딩

DataGridView 컨트롤은 표준 Windows Forms 데이터 바인딩 모델을 지원하므로 다양한 데이터 소스에 바인딩됩니다. 그러나, 대부분의 환경에서는 데이터 소스와의 상호 작용에 대한 세부 사항을 관리하는 BindingSource 구성 요소에 바인딩합니다.

private void GetData(string selectCommand)
{
    try
    {
        // Specify a connection string. Replace the given value with a
        // valid connection string for a Northwind SQL Server sample
        // database accessible to your system.
        String connectionString =
            "Integrated Security=SSPI;Persist Security Info=False;" +
            "Initial Catalog=Northwind;Data Source=localhost";

        // Create a new data adapter based on the specified query.
        dataAdapter = new SqlDataAdapter(selectCommand, connectionString);

        // Create a command builder to generate SQL update, insert, and
        // delete commands based on selectCommand. These are used to
        // update the database.
        SqlCommandBuilder commandBuilder = new SqlCommandBuilder(dataAdapter);

        // Populate a new data table and bind it to the BindingSource.
        DataTable table = new DataTable();
        table.Locale = System.Globalization.CultureInfo.InvariantCulture;
        dataAdapter.Fill(table);
        bindingSource1.DataSource = table;

        // Resize the DataGridView columns to fit the newly loaded content.
        dataGridView1.AutoResizeColumns(
            DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);
    }
    catch (SqlException)
    {
        MessageBox.Show("To run this example, replace the value of the " +
            "connectionString variable with a connection string that is " +
            "valid for your system.");
    }
}

*참고

BindingSource

구성 요소는 두 가지 용도로 사용됩니다. 먼저 간접 참조 계층, 통화 관리, 변경 알림 및 기타 서비스를 제공하여 폼의 컨트롤을 데이터에 바인딩하는 과정을 단순화합니다. 이 작업은 데이터 소스에 BindingSource 구성 요소를 연결하고 폼의 컨트롤을 BindingSource 구성 요소에 바인딩하는 방식으로 수행됩니다. 탐색, 정렬, 필터링 및 업데이트를 비롯한 데이터와의 추가 상호 작용은 모두 BindingSource 구성 요소를 호출하여 수행됩니다.

BindingSource에서는 내부 데이터에 액세스하기 위한 멤버를 제공합니다. 현재 항목은 Current 속성을 통해 검색할 수 있으며 목록 전체는 List 속성을 통해 검색할 수 있습니다. 현재 항목에 대한 편집 작업은 Current 속성과 RemoveCurrent, EndEdit, CancelEdit, AddAddNew 메서드를 통해 지원됩니다. 통화 관리는 모든 내부 데이터 소스 형식에 대해 자동으로 처리되지만 이 클래스는 사용자 지정할 수 있는 CurrentItemChangedDataSourceChanged 등의 여러 이벤트를 노출합니다.

목록 내의 항목을 탐색하기 위해 VCR과 비슷한 UI(사용자 인터페이스)를 제공하는 BindingNavigator 클래스를 사용하여 BindingSource 구성 요소에 바인딩된 데이터 소스를 탐색하거나 관리할 수도 있습니다. BindingNavigator는 모든 데이터 소스에 바인딩될 수 있지만 BindingNavigator.BindingSource 속성을 통해 BindingSource 구성 요소와 통합되도록 디자인되어 있습니다.

'System.Data.Common.DataRecordInternal' 형식 개체를 'System.Data.DataRowView' 형식으로 캐스팅할 수 없습니다.

 string sqlQuery = "쿼리문";

JdFW.DB.SqlHelper sql = new JdFW.DB.SqlHelper(SiteDeclaration.DBconnString);

SqlCommand comm = sql.CreateCommand(sqlQuery);

comm.Parameters.AddWithValue("@예매번호", p);

SqlDataReader rs = comm.ExecuteReader();

if (rs.HasRows)
{

this.DataList1.DataSource = rs;
DataList1.DataBind();

}

rs.Close();
sql.CloseSqlConnection();

 

이렇게 했는데

ItemDataBound에서 바인딩 오류가 난다면?

protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
{

if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{

    //System.Data.DataRowView drv = (System.Data.DataRowView)(e.Item.DataItem); 기존코드 오류발생
     System.Data.Common.DbDataRecord drv = (System.Data.Common.DbDataRecord)(e.Item.DataItem); 이렇게 변경해주면된다 
      Response.Write(drv["FloorNumber"].ToString() + "<br>");
}
}

BackgroundWorker 클래스

를사용하면 별도의 전용 스레드에서 작업을 실행할 수 있습니다.


다운로드 및 데이터베이스 트랜잭션과 같은 시간이 많이 걸리는 작업이 실행되는 동안에는 사용자 인터페이스가 응답을 중지할 수 있습니다.


응답성이 뛰어난 사용자 인터페이스가 필요하고 시간이 많이 걸리는 작업을 수행해야 하는 경우 BackgroundWorker 클래스는 간편한 해결책을 제공합니다.

백그라운드에서 작업을 실행하려면 BackgroundWorker를 만듭니다.


그런 다음 작업 진행률을 보고하고 작업이 완료되면 신호를 보내는 이벤트를 수신할 수 있습니다.

백그라운드 작업을 설정하려면 DoWork 이벤트의 이벤트 처리기를 추가한 다음 이 이벤트 처리기에서 시간이 많이 걸리는 작업을 호출합니다. 백그라운드 작업을 시작하려면 RunWorkerAsync 메서드를 호출합니다. 진행률 업데이트에 대한 알림을 받으려면 ProgressChanged 이벤트를 처리합니다.



작업이 완료될 때 알림을 받으려면 RunWorkerCompleted 이벤트를 처리합니다.

<UserControl x:Class="SL_BackgroundWorker_CS.Page"
    xmlns="http://schemas.microsoft.com/client/2007" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Width="400" Height="300">
    <Grid x:Name="LayoutRoot" Background="White">
        <StackPanel Height="30" Orientation="Horizontal" 
                    HorizontalAlignment="Left" VerticalAlignment="Top" 
                    Margin="10" >
            <Button x:Name="buttonStart" Content="Start" Click="buttonStart_Click"
                    Width="80" Height="30"/>
            <Button x:Name="buttonCancel" Content="Cancel" Click="buttonCancel_Click"
                    Width="80" Height="30"/>
        </StackPanel>
        <StackPanel Margin="10,50,0,0" Orientation="Horizontal">
            <TextBlock Text="Progress: "/>
            <TextBlock x:Name="tbProgress"/>
        </StackPanel>
    </Grid>
</UserControl> 


-----------------------------------------------------------------------------------------

cs 코드

using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;

namespace SL_BackgroundWorker_CS
{
    public partial class Page : UserControl
    {
        private BackgroundWorker bw = new BackgroundWorker();

        public Page()
        {
            InitializeComponent();

            bw.WorkerReportsProgress = true;
            bw.WorkerSupportsCancellation = true;
            bw.DoWork += new DoWorkEventHandler(bw_DoWork);
            bw.ProgressChanged += new ProgressChangedEventHandler(bw_ProgressChanged);
            bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bw_RunWorkerCompleted);
        }
        private void buttonStart_Click(object sender, RoutedEventArgs e)
        {
            if (bw.IsBusy != true)
            {
                bw.RunWorkerAsync();
            }
        }
        private void buttonCancel_Click(object sender, RoutedEventArgs e)
        {
            if (bw.WorkerSupportsCancellation == true)
            {
                bw.CancelAsync();
            }
        }
        private void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            for (int i = 1; (i <= 10); i++)
            {
                if ((worker.CancellationPending == true))
                {
                    e.Cancel = true;
                    break;
                }
                else
                {
                    // Perform a time consuming operation and report progress.
                    System.Threading.Thread.Sleep(500);
                    worker.ReportProgress((i * 10));
                }
            }
        }
        private void bw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if ((e.Cancelled == true))
            {
                this.tbProgress.Text = "Canceled!";
            }

            else if (!(e.Error == null))
            {
                this.tbProgress.Text = ("Error: " + e.Error.Message);
            }

            else
            {
                this.tbProgress.Text = "Done!";
            }
        }
        private void bw_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            this.tbProgress.Text = (e.ProgressPercentage.ToString() + "%");
        }
    }
}

  

쉐어포인트 다운로드

Windows SharePoint Services 3.0 x64 서비스 2

http://www.microsoft.com/downloads/details.aspx?displaylang=ko&FamilyID=9fb41e51-cb03-4b47-b89a-396786492cba

검색 항목 Windows SharePoint Services 3.0 x64 서비스 2 () 다운로드한 사용자들이 추가로 다운로드한 항목입니다.

  1. Windows SharePoint Services 3.0 x64
  2. Windows SharePoint Services 3.0 서비스 2
  • 서비스팩도 같이 깔아주세요 짜잘한 버그 해결

    (저 같은 경우에는 사이트 만들고 하루정도 지나면 접속이 안되었는데 서비스팩 깔고 해결 )

    (프로젝트 타이틀 클릭해서 홈으로가기가 안되었는데 서비스팩 깔고 해결 )

      

      

      

Microsoft Windows SharePoint Services 3.0의 새로운 기능확인하기

http://office.microsoft.com/ko-kr/sharepointtechnology/HA100738471042.aspx

  

쉐어포인트 더많은 정보 확인하기

http://office.microsoft.com/ko-kr/sharepointtechnology/default.aspx

  

  

  

프로젝트를 진행할 때 커뮤니케이션을 위한 사이트생성 "클릭""클릭"만으로 생성가능

아래와 같은 사이트를 프로젝트 단위로 관리하면 매우 편리합니다.

-기본적으로 사용자 권한 설정이 가능하며

사용자 접근 관리도 가능합니다

예제화면

생성된 화면

 image

  

공유문서 기능

 image

윈도우 탐색기로 열기해서 폴더 통채로 올리면 그 구조로 생성된다

  

공지사항

 image

프로젝트 일정관리

 image

  

변경상태 알림기능

 image

원하는 카테고리에 새로운 게시물이 올라오면 안내메일을 받을 수 있습니다.

이모든게 "클릭""클릭"만으로 가능합니다 – 0 –

윈도우 2008에는 미디어서 서버를 따로 받아서 설치해야 합니다.

아래의 경로에서 다운받으시면 됩니다.


간략한 설명

Microsoft 업데이트 독립 실행형 패키지(MSU) 파일은 Windows Server 2008 운영 체제를 위한 최신 버전의 Windows Media 서비스와 관련 원격 관리 도구를 설치합니다.


다운로드 사이트

http://www.microsoft.com/downloads/details.aspx?displaylang=ko&FamilyID=9ccf6312-723b-4577-be58-7caab2e1c5b7


개요

소프트웨어는 Windows Server 2008 보완하는 옵션입니다. Windows Server 2008 경우 최신 버전의 Windows Media 서비스를 포함하는 스트리밍 미디어 서비스 역할과 원격 관리 도구는 서버 관리자에 포함되어 있지 않습니다. Windows Server 2008 Windows Media 서비스에서 기본 제공 WMS 캐시/프록스 플러그 인과 같은 새로운 기능과 도구를 사용하려면 해당 스트리밍 미디어 서비스 역할 설치 관리자 파일을 가져와 업데이트한 플랫폼에서 실행해야 합니다.

Microsoft 업데이트 독립 실행형 패키지(MSU) 파일은 파일 이름에 표시된 대로 32비트(x86) 또는 64비트(x64) 버전의 다음 기능을 설치합니다.

  • Windows Server 2008 Standard Enterprise 버전의 "전체" 설치에서는 서버 관리자의 Windows Media 서비스 나머지 스트리밍 미디어 서비스 역할
  • Windows Server 2008 Standard Enterprise 버전의 "서버 코어" 설치에서는 스트리밍 미디어 서비스 서버 코어 역할
  • Microsoft Windows Vista Business, Enterprise 또는 Ultimate 운영 체제를 실행하는 컴퓨터의 경우에는 Microsoft Management Console(MMC) Windows Media 서비스 스냅인

Ajax Toolkit 을 이용한 실시간 (페이지 전환없이) 파일업로드 구현하기

 

 image

최신버전 아작스 툴킷(http://www.asp.net/ajax/)을 다운받습니다

 

 

화면구성부분

image 

페이지에 ScriptManager 와  AsyncFileUpload 를 끌어놓습니다.

AsyncFileUpload를 아래와 같이 구성합니다.

 image

Onclientuploadstarted 등을 설정하면각각의 상태에 맞는 자바스크립트가 실행됩니다.

<script>

 

function alertMsg() {

 

alert("파일 업로드시작 ");

}

</script>

 

 

 

<asp:UpdatePanel ID="UpdatePanel1" runat="server">

<ContentTemplate>

&nbsp;<table class="style1">

<tr>

<td class="style2">

<cc1:AsyncFileUpload ID="AsyncFileUpload1" runat="server" ThrobberID="Image1"

onuploadedcomplete="AsyncFileUpload1_UploadedComplete1" />

</td>

<td>

<asp:Image ID="Image1" runat="server" ImageUrl="ajax-loader.gif" />

</td>

</tr>

</table>

<br />

<br />

</ContentTemplate>

</asp:UpdatePanel>

ThrobberID를 설정하면 업로드중에서는 이미지가 노출되고 완료되면 사라집니다. (업로드 상태표시)

 

 

비하인드 소스부분


파일을 셀렉트하고 나면 파일업로드를 진행해줍니다.

protected void AsyncFileUpload1_UploadedComplete1(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)

{

System.Threading.Thread.Sleep(5000);

string savePath = MapPath("~/FileUpload/") + Path.GetFileName(e.filename); 

AsyncFileUpload1.SaveAs(savePath); //실질적인 파일업로드

}

 

 

 

실행화면

image

파일첨부를 하면 찾아보기 옆에 보시면 로딩이미지가 실행되고 있습니다

완료가 되면..

image

완료상태는 알수 있으므로 완료표시라든지 해주면 더 깔끔~

 

1 웹콘피그 설정

wsHttpBinding 를  basicHttpBinding 변경

   <service behaviorConfiguration="TESTSliverlight.Web.Service1Behavior"
    name="TESTSliverlight.Web.Service1">

    <endpoint address="" binding="basicHttpBinding" contract="TESTSliverlight.Web.IService1">
      <!--
      <endpoint address="" binding="wsHttpBinding" contract="TESTSliverlight.Web.IService1">
      -->
     <identity>
      <dns value="localhost" />
     </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
   </service>
  </services>
 </system.serviceModel>

2. wcf 웹서비스로 전달할 클래스 만들기

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ServiceModel;
using System.Runtime.Serialization;
namespace TESTSliverlight.Web
{
    [DataContract]
    public class WCFBook
    {
        public WCFBook(string BookTitle) {

            this.BookTitle = BookTitle;
        }
        [DataMember]
        public string BookTitle { get; set; }

    } 

}

3.웹서비스 만들기

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace TESTSliverlight.Web
{
    // NOTE: If you change the class name "Service1" here, you must also update the reference to "Service1" in Web.config.
    public class Service1 : IService1
    {
        public void DoWork()
        {
        }

        public  List<WCFBook> GetBookData()
        {

         //하나의 값만 보내고 싶으면  return WCFBook 하면된다 

        //실버라이트에서 받을땐 e.result.BookTitle 이런씩으로 받으면 됩니다

            List<WCFBook> li = new List<WCFBook>();
            li.Add(new WCFBook("1111"));
            li.Add(new WCFBook("2222"));
            li.Add(new WCFBook("3333"));

            return li;
        }
    }
}

실버라이트에서 처리하기

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ServiceModel.Channels;
using System.ServiceModel;
using System.Collections.ObjectModel;
namespace TESTSliverlight
{
    public partial class DataList : UserControl
    {
        ServiceBook.Service1Client sclient;
        EndpointAddress defaultAddress;
        public DataList()
        {
            InitializeComponent();
            Binding defaultBinding = new System.ServiceModel.BasicHttpBinding();
            defaultAddress = new System.ServiceModel.EndpointAddress("http://localhost:62711/Service1.svc");

            sclient = new TESTSliverlight.ServiceBook.Service1Client(defaultBinding, defaultAddress);
            sclient.GetBookDataCompleted += new EventHandler<TESTSliverlight.ServiceBook.GetBookDataCompletedEventArgs>(sclient_GetBookDataCompleted);
            sclient.GetBookDataAsync();
        }

        void sclient_GetBookDataCompleted(object sender, TESTSliverlight.ServiceBook.GetBookDataCompletedEventArgs e)
        {
                        this.ListWCF.ItemsSource = e.Result; //리스트 박스에 데이터 바인딩
        }

    }
}

-----------------------------------------------------------------------------------------------------------------------

<UserControl x:Class="TESTSliverlight.DataList"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Width="440" Height="392" xmlns:TESTSliverlight="clr-namespace:TESTSliverlight"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             mc:Ignorable="d"
             xmlns:SB="clr-namespace:TESTSliverlight.ServiceBook">
<UserControl.Resources>
  <SB:WCFBook x:Key="WCFBookDS" d:IsDataSource="True"/>
  <DataTemplate x:Key="BookTitleTemplate">
            <StackPanel Orientation="Horizontal">
   <TextBlock Text="{Binding Path=BookTitle}" />
            <TextBlock Text="{Binding Path=BookTitle}" />
            <TextBlock Text="{Binding Path=BookTitle}" />
                </StackPanel>
  </DataTemplate>
</UserControl.Resources>

    <Grid x:Name="LayoutRoot" Background="White">
     <TextBlock Height="48" HorizontalAlignment="Left" Margin="8,8,0,0" VerticalAlignment="Top" Width="192" Text="DATA LIST" TextWrapping="Wrap"/>
     <ListBox  Name="ListWCF" Margin="64,96,184,120" DataContext="{StaticResource WCFBookDS}"
                  ItemsSource="{Binding WCFBook}" ItemTemplate="{StaticResource BookTitleTemplate}"/>

    </Grid>
</UserControl>

할당량을 늘리려면 적합한 바인딩 요소에서

MaxReceivedMessageSize 속성을 사용하십시오.

실버라이트에서 웹서비스로 데이터를 불러올때 용량(?)초과로 인한오류 발생

해결방법입니다.

 

실버라이트 ServiceReferences.ClientConfig 파일

<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="LargeBuffer" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
                    <security mode="None" />
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address=""
                binding="basicHttpBinding" bindingConfiguration="LargeBuffer"
                contract="ServiceRef.ISilverlightService" name="LargeBuffer" />
        </client>
    </system.serviceModel>
</configuration>

 

 

Web.config 파일

....
  <system.serviceModel>
   
    <!--Jaedoo 최소용량때문에 추가한거임-->
    <bindings>
      <basicHttpBinding>
        <binding name="LargeBuffer" receiveTimeout="00:01:00" openTimeout="00:01:00" sendTimeout="00:01:00"
                       closeTimeout="00:010:00"
                      maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
                        maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
       
        </binding>
      </basicHttpBinding>
    </bindings>

    <!--최소용량때문에 추가한거임-->

   
   
    <behaviors>
      <serviceBehaviors>
        <behavior name="클래스.Web.SilverlightServiceBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
          <!--Jaedoo 최소용량때문에 추가한거임-->
          <dataContractSerializer maxItemsInObjectGraph="6553600"/>
       
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service behaviorConfiguration="클래스.Web.SilverlightServiceBehavior"
       name="클래스.Web.SilverlightService">
        <endpoint address="http://localhost:56445/SilverlightService.svc" binding="basicHttpBinding"

contract="클래스.Web.ISilverlightService"                
                  name="LargeBuffer"  >
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
  </system.serviceModel>
</configuration>

SQL Server Compact Edition 사용 했을때 오류 해결방법 및 SQLServerCompact 3.5 설치

*비주얼스튜디오 2008와 SQLServerCompact 3.5로 개발했으며 옴니아에서 테스트 하였습니다.

 

오류화면

image

위의 오류는 와 SQLServerCompact 3.5 사용했는데 스마트폰에 System.Data.SqlServerCe 파일이 참조가 안되 있어서 나는 오류입니다.

 

해결방법

image

image

실제로 빌드 했을 때 System.Data.SqlServerCe.dll 이 파일도 함께 복사를 하셔야 합니다.

로컬복사 False 를 True로 주시면 빌드 될 때 참조한dll도 같이 복사됩니다.

 

요렇게 했는데도 아래와 같이 오류가 난다면..스마트폰에 SQLServerCompact 3.5가 설치 안되어져 있는겁니다.

 image

 

설치파일경로

C:\Program Files\Microsoft SQL Server Compact Edition\v3.5\Devices\wce500\armv4i
안의 파일설치

기본적으로 Core만 설치해도 돌아가는걸로 알고 있습니다.

sqlce.dev.KO.ppc.wce5.armv4i.CAB 깔면 스마트폰에서 SQLServerCompact 3.5 데이터 쿼리조회도 가능합니다.

image

 

제 핸드폰은 옴니아라서 ppc 만 설치해줬습니다

-sqlce.dev.KO.ppc.wce5.armv4i.CAB

-sqlce.ppc.wce5.armv4i.CAB

-sqlce.repl.ppc.wce5.armv4i.CAB

http://msdn.microsoft.com/ko-kr/library/ak58kz04.aspx

[클릭원스 배포시  프로젝트(dll)을 필요 시 다운로드 하는 방법]

모듈A

image

 

부모프로젝트

image

 

[작성방법]
1.우선 모듈A를 참조한다
2.그리고 배포시 부모프로젝트에서 모듈A를 빼고 배포한다 (제외(?))시키는 방법은 아래 참고

image

어플리케이션 파일을 선택한다
 image

모듈A를 include하고 다운로드 그룹 이름을 지정한다

추후에 다운 받을 때 다운로드 그룹 이름을 이용해서 다운받는다

[부모프로젝트에서 모듈A를 요청할때 ]

Dictionary<String, String> DllMapping = new Dictionary<String, String>();
private int childFormNumber = 0;

public MDIParent1()
{
    InitializeComponent();
    DllMapping["ClickOnceLibrary"] = "ClickOnceLibrary";
    AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
}

 

 

//클릭이벤트 여기서 호출
       private void toolStripButton4_Click(object sender, EventArgs e)
       {

           try
           {
               Insa_module.TestClass dc = new Insa_module.TestClass();
               Insa_module.Insa2 insa = new Insa_module.Insa2();
               insa.Show();
               MessageBox.Show("Message: " + dc.Message);
           }
           catch (Exception ex) {

               MessageBox.Show(ex.Message);
           }
       }

/*
* Use ClickOnce APIs to download the assembly on demand.
*/
       Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
       {
           Assembly newAssembly = null;

           if (ApplicationDeployment.IsNetworkDeployed)
           {
               ApplicationDeployment deploy = ApplicationDeployment.CurrentDeployment;

               // Get the DLL name from the Name argument.
               string[] nameParts = args.Name.Split(',');
               string dllName = nameParts[0];
               string downloadGroupName = DllMapping[dllName];

               try
               {
                   deploy.DownloadFileGroup(downloadGroupName);
               }
               catch (DeploymentException de)
               {
                   MessageBox.Show("Downloading file group failed. Group name: " + downloadGroupName + "; DLL name: " + args.Name);
                   throw (de);
               }

               // Load the assembly.
               // Assembly.Load() doesn't work here, as the previous failure to load the assembly
               // is cached by the CLR. LoadFrom() is not recommended. Use LoadFile() instead.
               try
               {
                   newAssembly = Assembly.LoadFile(Application.StartupPath + @"\" + dllName + ".dll");
               }
               catch (Exception e)
               {
                   throw (e);
               }
           }
           else
           {
               //Major error - not running under ClickOnce, but missing assembly. Don't know how to recover.
               throw (new Exception("Cannot load assemblies dynamically - application is not deployed using ClickOnce."));
           }

           return (newAssembly);
       }
   }

+ Recent posts