'분류 전체보기'에 해당되는 글 744건

  1. 2011.07.18 [iphone] NSMutableArray may not respond to ObjectForKey란 에러메세지
  2. 2011.07.18 [iphone] UITabbarController에서 탭을 선택했을때 항상 Reload, Refresh하기
  3. 2011.07.14 [iphone] string append하기
  4. 2011.07.14 [iphone] Singletone Class만들기
  5. 2011.07.13 [iphone] UITableView에 Data를 넣어보자.
  6. 2011.07.12 [xcode] 간단하게 UITableView를 써보자.
  7. 2011.07.12 바람 입력기와 ecto 블러그 writer
  8. 2011.06.23 [object-c] 컬렉션 사용하기 NSValue NSMutableArray 를 이용
  9. 2011.06.21 [Mac] 맥에서 Home/End 키 사용하기
  10. 2011.06.17 [xcode] 아이폰에서 버튼 이벤트 발생시키기 2
  11. 2011.06.16 [wcf] Service Trace Viewer를 이용하여 디버깅하기
  12. 2011.06.16 [WCF] WCF Rest 에서 Image File Upload 하기 2
  13. 2011.05.31 [wcf] c#에서 프로시저 실행하기
  14. 2011.05.31 [db] 간단한 프로시저 만들기
  15. 2011.05.27 [WP7] Toast Notification 만드는법 4 (Mango Ver)
  16. 2011.05.27 [WP7] Toast Notification 만드는법 3 (Mango Ver)
  17. 2011.05.27 [wp7] Toast Notification 만드는법 2 (Mango Ver) 1
  18. 2011.05.27 [WP7] Toast Notification 만드는법 1 (Mango Ver)
  19. 2011.05.27 [surface] surface 런칭쇼에 내가 만든 프로그램 공개
  20. 2011.05.27 [Surface] FlowDocument 사용하기
  21. 2011.05.19 [surface] WPF에서 VisualState 쓰기
  22. 2011.05.17 [WCF] WCF REST service project 만드는법
  23. 2011.05.03 [wp7] Customizing WP7 Push Notification Tiles
  24. 2011.04.26 [wp7] 모바일 앱에 광고 탑재하는법 2
  25. 2011.04.25 [wp7] 폰에서 유니크한 ID 만들기 1
  26. 2011.04.22 [wp7] 자기가 사용하는 기계 Model명을 얻고 싶을때
  27. 2011.03.31 [wp7] MVVM에서의 Invalid cross-thread access.메세지
  28. 2011.03.31 [wp7] Command를 Behind에서 사용하자
  29. 2011.03.25 [wp7] 윈도우 폰 캡쳐 프로그램
  30. 2011.03.24 [wp7] 어셈블리로부터 버전 정보 받아오기
iPhone App2011. 7. 18. 14:58

코딩을 하다보니 이런 경고가 계속 떠서 짜증났다.

이런 경고를 없애기 위해서 인터넷 찾아보니

for문 in을 쓸때(c#에서는 foreach) NSmutableArray 컬렉션으로

   for(NSMutableArray *item in afd.foodData)

{

NSNumber *calrorie = [NSNumber numberWithInt:[[item objectForKey:@"calrorie"] intValue]];

count = [NSNumber numberWithInt:[count intValue]+[calrorie intValue]];

NSString *name = [NSString stringWithString:[item objectForKey:@"name"]];

[totalName appendFormat:@"%@ (%d) Cal \n",name,[calrorie intValue]];

}


이런식으로 하니 경고가 발생했다 그래서

   for(NSMutableDictionary *item in afd.foodData)

{

NSNumber *calrorie = [NSNumber numberWithInt:[[item objectForKey:@"calrorie"] intValue]];

count = [NSNumber numberWithInt:[count intValue]+[calrorie intValue]];

NSString *name = [NSString stringWithString:[item objectForKey:@"name"]];

[totalName appendFormat:@"%@ (%d) Cal \n",name,[calrorie intValue]];

}


이렇게 수정하니 경고가 사라졌다.
참고 : http://stackoverflow.com/questions/6196688/how-to-resolve-nsmutablearray-may-not-respond-to-objectforkey
Posted by 동동(이재동)
iPhone App2011. 7. 18. 13:39

샘플로 칼로리 계산기를 만들면서 Tab을 클릭하면 항상 새로운 데이터를 다시 로드하는 것을 하고 싶었다.

인터넷 찾아보니

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {

NSLog(@"didSelectViewController : %@",viewController);

}


이런 delegate를 사용하란다. 이것을 호출하기 위해서 헤더에 프로토콜을 추가하고 이렇게

interface CalrorieCalAppDelegate : NSObject <UIApplicationDelegate,UITabBarControllerDelegate> {


IBOutlet UITabBarController *tabBar;

}


이 delegate를 꼭 추가해준다 구현부에
[self.tabBar setDelegate:self];
추가한 곳은 아래와 같다.    

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

{

// Override point for customization after application launch.

//self.window.rootViewController = self.viewController;

self.window.rootViewController = self.tabBar;

[self.tabBar setDelegate:self];

[self.window makeKeyAndVisible];

return YES;

}



하지만 이것보다 더 좋은 방법이 있다. 바로


-(void) viewWillAppear:(BOOL)animated


이걸 이용한 방법이다. view에서 override 해서 쓴다.

tab을 읽기전에 항상 호출된다.


자 이곳에서 refresh를 해주자.


-(void) viewWillAppear:(BOOL)animated

{

AteFoodData* afd = [AteFoodData sharedSingletonClass];

count = [[NSNumber alloc] init];

NSMutableString *totalName = [NSMutableString stringWithString:@"음식 이름\n\n"];

for(NSArray *item in afd.foodData)

{

NSNumber *calrorie = [NSNumber numberWithInt:[[item objectForKey:@"calrorie"] intValue]];

count = [NSNumber numberWithInt:[count intValue]+[calrorie intValue]];

NSString *name = [NSString stringWithString:[item objectForKey:@"name"]];

[totalName appendFormat:@"%@ (%d) Cal \n",name,[calrorie intValue]];

}

  

resultTextView.text = [NSString stringWithFormat:totalName];

resultLabel.text = [NSString stringWithFormat:@"당신이 섭취한 칼로리는? (%d칼로리)",[count intValue]];

}


이렇게 하면 탭을 눌렀을때 항상 값을 읽어온다.
여담이지만 여기서 메모리 에러가 나서 고생했었는데 count를 전역변수로 해서 쓰는데 header에서 NSNumber로 해서정의했지만
count = [[NSNumber alloc] init];

이렇게 count를 초기화를 안해줘서 메모리 에러가 났었다. 항상 초기화를 해주자.!!






Posted by 동동(이재동)
iPhone App2011. 7. 14. 17:07

스트링을 append할때

NSString에 stringAppendingString인가 를 쓰니까 안붙어져서

NSMutableString을 쓰니까 잘 된다.

NSString *name = [NSString stringWithString:[item objectForKey:@"name"]];

[totalName appendFormat:@"%@ "name];


이런식으로
appendFormat을 이용하자
그리고 줄 바꿀려면 \n 을 이용하면 된다.
Posted by 동동(이재동)
iPhone App2011. 7. 14. 11:29

요즘 다이어트 시대를 맞이해 연습차 칼로리 계산기를 만들어 보았다.

근데 칼로리를 지속적으로 저장해야 하는데 c# 같은경우는 그냥 static class 하나 만들어서 저장을 했는데

objective c에서도 있었다.

// SingletonClass.h

#import <Foundation/Foundation.h>

@interface SingletonClass : NSObject

{

}

+ (SingletonClass *)sharedSingletonClass;

@end

일단 이렇게 헤더 class를 만들고

// SingletonClass.m

#import "SingletonClass.h"

@implementation SingletonClass

+ (SingletonClass *)sharedSingletonClass

{

   static SingletonClass *singletonClass = nil;

  

   if(singletonClass == nil)

   {

   @synchronized(self)

   {

   if(singletonClass == nil)

   {

   singletonClass = [[self alloc] init];

   }

   }

   }

  

   return singletonClass;

}

@end

구현부에 이렇게 하면 된다.

사용은

SingletonClass *s = [SingletonClass sharedSingletonClass];

이렇게 하면 된다.

이렇게 하면 클래스 인스턴스를 한번만 생성되어서 어디서나 클래스를 만들어도

스태틱한 class가 되는것이다.

참고 : http://b4you.net/blog/210

Posted by 동동(이재동)
iPhone App2011. 7. 13. 11:10

값을 넣는대는 프로퍼티를 이용해서 값을 return 해주는방법과

- (void)viewDidLoad

{

[super viewDidLoad];

if (data==nil) {

data = [[[NSMutableArray alloc] init ]retain];

[data addObject:[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"핫식스",[NSNumber numberWithInt:7000], nil] forKeys:KEYS]];

}

}


이렇게 view가 로드되고 넣어주는 방법이 있다.


내생각에는 후자가 메모리 관리상 나을것 같다.


그뒤에 row를 보여주는곳에는


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

  

static NSString *CellIdentifier = @"Cell";

  

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell == nil) {

cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];

   }

  


cell.textLabel.text = [NSString stringWithFormat:@"%@ (%d칼로리)",

[[data objectAtIndex:indexPath.row] objectForKey:@"name"],

   [[[data objectAtIndex:indexPath.row] objectForKey:@"price"] intValue]];

  


return cell;

}



이렇게 하자.


Posted by 동동(이재동)
iPhone App2011. 7. 12. 18:07

맥은 참 나를 힘들게하는거 같다.

이번에 xcode 4를 깔았는데 이게 더 나은거 같다. 이건 중요하지 않고

일단 xib 에서 tableView를 하나 만들고.. 기존에 View가 있으면 지우고 만든다.

그다음에 오른쪽 버튼으로 연결후

헤더에서

#import <UIKit/UIKit.h>


@interface CalrorieCalViewController : UITableViewController {

NSMutableArray *data;

}


@property (nonatomic, retain) NSMutableArray* data;

@end


이런식으로 바꾼다.


그뒤에


-(NSMutableArray*) data {

if (data==nil) {

data = [[NSMutableArray alloc] init];

[data addObject:[NSMutableDictionary dictionaryWithObject:@"핫식스" forKey:@"name"]];

[data addObject:[NSMutableDictionary dictionaryWithObject:@"NF소나타" forKey:@"name"]];

  

}

return data;

}


이렇게 data를 만들고


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {


return [self.data count];

}


이렇게 몇개 보일지 카운터를 알려주고


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

  

static NSString *CellIdentifier = @"Cell";

  

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell == nil) {

cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];

}

  

cell.textLabel.text = [[self.data objectAtIndex:indexPath.row] objectForKey:@"name"];

return cell;

}


이렇게 row를 돌면서 데이터를 뿌려준다.
마지막으로

- (void)viewDidUnload

{

[super viewDidUnload];

self.data = nil;

// Release any retained subviews of the main view.

// e.g. self.myOutlet = nil;

}


이렇게 해제하자


Posted by 동동(이재동)
Mac2011. 7. 12. 13:05

최근 shift+space 로 한영을 전환하기 위해 별도의 셋팅 없이 바람 입력기로

된다고 해서 깔았다. 최신버전 베타를 깔아야만 했다 레오파드 였기때문에

그리고 지금 쓰고 있는건 블러그 writer ecto이다..

머 그럭저럭 쓸만하다.

계정만들때 MovableType으로 선택하고 그냥 쭉 하면 된다.

Posted by 동동(이재동)
iPhone App2011. 6. 23. 15:02

반 구조체 같은 경우 컬렉션에 넣을수 없다.

예를 들면 NSRect같은것은 바로 array에 addObject로 넣으면 안들어가기때문에 NSValue로 한번 감싸서 넣어준다.

물론 숫자 int,float등도 바로 넣을수 없기떄문에 NSNumber로 한번 감싸서 넣어준다.

NSMutableArray *mutableArray= [NSMutableArray arrayWithCapacity:2];

NSRect rect = NSMakeRect (1, 2, 30, 40);

NSValue *value;

value = [NSValue valueWithBytes:&rect objCType: @encode(NSRect)];

[mutableArray addObject: value];

NSValue *value2; NSRect rect2;

value2 = [mutableArray objectAtIndex: 0];

[value2 getValue: &rect2];

NSLog(@"Data %f %f",rect2.size.width,rect2.size.height); 

Posted by 동동(이재동)
Mac2011. 6. 21. 16:48

맥에서는 기본적으로 사용이 되지 않는다 

매일 그냥 커맨드+ 화살표로 깔짝깔짝 되었는데

검색해보니 방법이 있더라...

url만 써 놓자

http://delpini.egloos.com/2259297



Posted by 동동(이재동)
iPhone App2011. 6. 17. 14:34

음 이것저것 해보았지만 역시 잘 정리된 사이트가 별로 없었다.

 

자 내가 한번 해보자.

 

이번 목표는 버튼을 클릭했을 때 웹 페이지를 띄우는 것과 Label Text를 변경하는 것이다.

 

일단 난 돈이 없어서 xcode 3.2로 했다. xcode4 빨리 받아야 될텐데

 

일단 하는법은 View-based Application으로 프로젝트를 하나 만든후

 

확장자가 xib가 되어있는 것을 더블 클릭한다. 그러면 View가 뜰것이다.

 

여기서 Label이랑 Button을 하나씩 추가 한다.

 

자 이제 ViewController.h 헤더 파일에서 label과 button을 설정한다.

 

#import <UIKit/UIKit.h>
 
@interface TestHelloWorldViewController : UIViewController {
    IBOutlet UILabel  *myLabel;        
}
@property (nonatomic,retain) IBOutlet UILabel *myLabel;
 
-(IBAction) onGotoTest;
@end

 

인터페이스에 IBoutlet UILabel 에 myLabel이라는 것을 하나 설정하고

@property로 똑같이 하나 잡는다.

 

Label은 이걸로 끝~

 

버튼은 더 간단하다

-(IBAction) onGotoTest로 버튼 이벤트? Action을 정한다.

 

자 코딩을 마쳤으면 다시 View로 돌아가자 View로 돌아가서 헤더에서 만든것을 연결해보자.

 

xib를 클릭하여 view를 보고 일단 내가 만든 버튼에서 오른쪽 버튼을 누르면 Rounded Rect Button이라는 팝업창이 하나 뜬다. 여기서 우리는 터치를할것이니 Touch Up inside에 옆에 동그라미를 마우스로 끌어서 File’s Owner에 집어 넣자

그럼 아까 내가 헤더에서 만든 onGotoTest Button Action을 선택할수 있다. 그러면  끝이다.

 

이번에는 라벨을 컨트롤 하기 위해서 label에서 오른쪽 버튼을 누른후 new referenciong Outlet 옆에 있는 동그라미를 끌어서 file's Owner에 집어 넣는다. 그러면 다시 헤더에서 만들었던 myLabel이 보일것이다 선택하면 두개의 연결은 끝~

 

자이제 실제로 Controller.m에 직접 코딩을 해보자.

 

@synthesize myLabel;
 
-(IBAction)onGotoTest{
    //NSURL *url = [NSURL URLWithString:@"http://www.naver.com"];
//    [[UIApplication sharedApplication] openURL:url];
    myLabel.text=@"jaedong";
     
}

 

@synthesize로 myLabel을 정의 한후

onGotoTest이벤트가 발생하면 즉 버튼이 클릭되면 myLabel 의 Text를 바꾸 었다.

 

흠… 쓰다보니 기초지식이 너무 없네… 일단 object-c부터 파야겠다.

 

아무튼 20분만에 첫 예제 프로그램을 만들어서 기쁘다…!!

 

참고: http://iphoneappsmaker.tistory.com/713

Posted by 동동(이재동)
wcf2011. 6. 16. 15:57

내가 처한 사항은 이랬다.

 

모든것을 WCF Rest서비스로 구축하고 마지막으로 파일 업로드 를 구현하여 로컬에서 서비스를 돌려서

 

했더니 파일 업로드가 잘 작동 되었다.

 

근데 이게 왜 안되는지 IIS에만 서비스를 올리면 WebRequestError 400 Request 에러가 나는것이였다.

 

구글링을 했지만 너무 많은 경우에 수라 포기… 그렇다면 디버깅은 혹시 될까?

 

예전에 iis process(w3wp)를 잡아서 디버깅을 해본적이 있던터라 그걸로 해볼려고 했지만 까먹어서 실패 ㅋㅋ

 

그러다가 우연히 Microsoft Service Trace Viewer를 보게 되었다.

 

참고 :http://blogs.msdn.com/b/aszego/archive/2010/02/01/tool-of-the-month-servicemodeltraceviewer.aspx

 

이걸 사용하면 서비스에서 어떤일이 일어나는지 자세하게 알수 있겠구나 해서 실행을 해보았다.

 

C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\SvcTraceViewer.exe에서 실행하면 된다(윈7)

 

자 실행을 하고 open을 할려니 svclog 확장자를 가진 파일이 필요하다.. 아이게 로그 파일이구나라고 순식간에 직감했다.

 

일단 web.config 에 이 부분을 추가한다.

<system.diagnostics>
    <sources>
      <source name="System.ServiceModel" switchValue="Information,ActivityTracing"
          propagateActivity="true">
        <listeners>
          <add name="ServiceModelTraceListener"/>
        </listeners>
      </source>
      <source name="System.Net.Sockets" switchValue="Information">
        <listeners>
          <add name="ServiceModelTraceListener"/>
        </listeners>
      </source>
      <source name="System.Net" switchValue="Information">
        <listeners>
          <add name="ServiceModelTraceListener"/>
        </listeners>
      </source>
    </sources>
    <sharedListeners>
      <add initializeData="d:\client_tracelog.svclog"
          type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
          name="ServiceModelTraceListener" traceOutputOptions="LogicalOperationStack, DateTime, Timestamp, ProcessId, ThreadId, Callstack"/>
    </sharedListeners>
    <trace autoflush="true" />
  </system.diagnostics>

 

추가 가 끝나면 저위에 경로 d:\client_tracelog.svclog에 기록될것이다.

 

이것을 open 하면 된다. 그럼 이렇게 에러를 잡을수 있다.

 

 

image

 

내가 왜 파일 업로드가 안되었는지 IIS에서만!!! 확인해보니 폴더 권한이 없었던 것이다!!

 

그래서 폴더 권한을 준후 다시 실행하니 잘되었다.

Posted by 동동(이재동)
wcf2011. 6. 16. 11:55

일단 WCF에서 보자

[WebInvoke(UriTemplate = "FileUpload?FileName={fileName}", Method = "PUT")]
       public void FileUpLoad(string fileName, Stream fileStream)
       {
           FileStream fileToupload = new FileStream("d:\\" + fileName, FileMode.Create);
 
           byte[] byteArray = new byte[10000];
           int byteRead, totalByteRead = 0;
           do
           {
               byteRead = fileStream.Read(byteArray, 0, byteArray.Length);
               totalByteRead += byteRead;
           } while (byteRead > 0);
 
           fileToupload.Write(byteArray, 0, byteArray.Length);
           fileToupload.Close();
           fileToupload.Dispose();
       }

 

일단 이렇게 메소드를 작성해서 file 이름과 stream을 받아서 파일을 경로에 쓴다.

 

method는 put으로 한다.

 

자 이제 끝이다. 이제 WPF에서 호출해보자.

 

 

 

public void ImageUpload(string fileName, string filePath)
        {
            using (WebClient webclient = new WebClient())
            {
                webclient.UploadData(new Uri(string.Format(serverUri + "/FileUpload?FileName={0}",fileName)), "put", GetData(filePath));
            }
        }
 
        private byte[] GetData(string filePath)
        {
            FileStream stream = File.OpenRead(filePath);
 
            byte[] data = new byte[stream.Length];
 
            stream.Read(data, 0, data.Length);
 
            stream.Close();
 
            return data;
        }

 

이렇게 filename과 byte로 변환된 스트림을 WCF로 날려주기만 하면 된다.

Posted by 동동(이재동)
wcf2011. 5. 31. 15:45

프로시저를 만들고 이제 WCF 서비스에서 프로시저를 실행을 하기 위해서 DB 연동을 해야 한다.

 

그냥 프로젝트에서 new item 후 Data 에 linq to sql classes를 선택 한다.

image

 

 

그뒤에 생성된 dbml에 Table과 프로시저를 드래그앤 드랍하면 끝~

image

 

호출은 이렇게 하면 된다.

 

public void InsertSubScriber()
        {
            using (DataClassesDataContext context = new DataClassesDataContext())
            {                
                context.sp_WP7Subscribers_Insert(1,"himan",DateTime.Now);
            }
        }

 

쉽다

Posted by 동동(이재동)
database2011. 5. 31. 15:40
USE [WP7NotificationServer]
GO
/****** Object:  StoredProcedure [dbo].[sp_HugeFlowAppManifest_List_Select]    Script Date: 05/31/2011 14:35:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*
Developer : test
Date : 2010/11/18
Desc : test
*/
 
CREATE proc [dbo].[sp_WP7NotificationServer_List_Select]
    @AppID int
AS
BEGIN
    SELECT [Idx]
      ,[Subscriber]
      ,[SubScribeDate]
    From [WP7NotificationServer] 
END
GO

 

이건 그냥 단순한 list select

 

이건 insert

USE [WP7NotificationServer]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
 
Create proc [dbo].[sp_WP7NotificationServer_Insert]
@AppID int
,@SubScriber VARCHAR(255)
,@SubScribeDate datetime
AS
INSERT INTO WP7NotificationSever_Subscribers(AppID , SubScriber, SubScribeDate) VALUES (@AppID , @Subscriber,@SubScribeDate)

 

 

머 이런식으로 하면 된다 쉽다.

'database' 카테고리의 다른 글

[db] DECIMAL 형식이란?  (0) 2010.04.19
[db] DECLARE로 정의한 함수 보기  (0) 2010.04.19
[DB] JOIN에 대한 것  (0) 2010.04.13
[db] query문 에서 변수 설정및 for문 형변환 이용하기  (0) 2010.01.07
[db] db 정보 확인  (1) 2010.01.07
Posted by 동동(이재동)
Windows Phone 72011. 5. 27. 18:43

마지막이다.

 

이제 메세지를 보낼 UI를 만들어보자 관리자를 위한 프로그램이다

 

난 그냥 쉬운 WPF로 만들었다.

 

일단 버튼 하나 만들고

 

private void ToastButton_Click(object sender, RoutedEventArgs e)
      {
          string appId = "1";
          //string baseUri = string.Format("http://localhost:19976/Notifications/GetSubscribers?appId={0}", appId);
          string baseUri = string.Format("http://192.168.10.174:6060/Notifications/GetSubscribers?appId={0}", appId);
 
          GetSubscribers(baseUri);
          
      }

 

 

private void GetSubscribers(string baseUri)
     {
         WebClient webclient = new WebClient();
         webclient.DownloadDataCompleted += new DownloadDataCompletedEventHandler(webclient_DownloadDataCompleted);
         webclient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webclient_DownloadStringCompleted);
         webclient.DownloadStringAsync(new Uri(baseUri));
     }

 

이렇게 WCF 를 호출해서 사용자 URI들을 받는다. (10명이 등록 되어 있으면 서버가 10개가 들어 있는 List를 보내줌)

 

void webclient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
       {                           
           MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(e.Result));
           DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(List<Uri>));
           deserializedListUri = serializer.ReadObject(ms) as List<Uri>;
 
           SendToast();
       }

 

자 다운이 다 되면 List로  Deserialize 한후

 

private void SendToast()
       {
 
           HttpWebRequest sendNotificationRequest = (HttpWebRequest)WebRequest.Create(deserializedListUri[0]);
 
           // We will create a HTTPWebRequest that posts the toast notification to the Microsoft Push Notification Service.
           // HTTP POST is the only allowed method to send the notification.
           sendNotificationRequest.Method = "POST";
 
           // The optional custom header X-MessageID uniquely identifies a notification message. 
           // If it is present, the // same value is returned in the notification response. It must be a string that contains a UUID.
           // sendNotificationRequest.Headers.Add("X-MessageID", "<UUID>");
 
           var title = "test Title";
           var subtitle = "test SubTitle";
           // Create the toast message.
 
 
           string toastMessage = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
           "<wp:Notification xmlns:wp=\"WPNotification\">" +
              "<wp:Toast>" +
                   "<wp:Text1>" + title + "</wp:Text1>" +
                   "<wp:Text2>" + subtitle + "</wp:Text2>" +
              "</wp:Toast> " +
           "</wp:Notification>";
 
           // Sets the notification payload to send.
           byte[] notificationMessage = Encoding.Default.GetBytes(toastMessage);
 
           // Sets the web request content length.
           sendNotificationRequest.ContentLength = notificationMessage.Length;
           sendNotificationRequest.ContentType = "text/xml";
           sendNotificationRequest.Headers.Add("X-WindowsPhone-Target", "toast");
           sendNotificationRequest.Headers.Add("X-NotificationClass", "2");
 
           using (Stream requestStream = sendNotificationRequest.GetRequestStream())
           {
               requestStream.Write(notificationMessage, 0, notificationMessage.Length);
           }
 
           // Send the notification and get the response.
           HttpWebResponse response = (HttpWebResponse)sendNotificationRequest.GetResponse();
           string notificationStatus = response.Headers["X-NotificationStatus"];
           string notificationChannelStatus = response.Headers["X-SubscriptionStatus"];
           string deviceConnectionStatus = response.Headers["X-DeviceConnectionStatus"];
 
           // Display the response from the Microsoft Push Notification Service.  
           // Normally, error handling code would be here.  In the real world, because data connections are not always available,
           // notifications may need to be throttled back if the device cannot be reached.
 
           resultTextBlock.Text = notificationStatus + " | " + deviceConnectionStatus + " | " + notificationChannelStatus;
       }
 
이렇게 보낸다 xml 형식으로 만들어서 보내면 되며
 
상태들도 header정보를 받아서 볼수 있다.

Posted by 동동(이재동)
Windows Phone 72011. 5. 27. 18:37

자 이번에는 WCF Rest Service를 만들어 보자.

 

이것도 역시 WCF Rest Service 프로젝트 생성해서

 

[ServiceContract]
   [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
   [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
   public class Notifications
   {
       private static Dictionary<string,List<Uri>> subscribers = new Dictionary<string,List<Uri>>();
       private static object obj = new object();
 
       [WebInvoke(UriTemplate = "register?uri={uri}&appId={appId}", ResponseFormat = WebMessageFormat.Xml, Method = "GET")]
       public void Register(string uri,string appId)
       {            
           Uri channelUri = new Uri(uri, UriKind.Absolute);
           Subscribe(channelUri,appId);
       }
 
       private void Subscribe(Uri channelUri,string appId )
       {
           lock (obj)
           {
               if (subscribers.ContainsKey(appId) == false)
               {
                   subscribers.Add(appId, new List<Uri>());
               }
 
 
               if (!subscribers[appId].Exists((u) => u == channelUri))
               {
                   subscribers[appId].Add(channelUri);
               }
           }
           //OnSubscribed(channelUri, true);
       }
 
       [WebInvoke(UriTemplate = "GetSubscribers?appId={appId}", ResponseFormat = WebMessageFormat.Json, Method = "GET")]
       public List<Uri> GetSubscribers(string AppId)
       {
           return subscribers[AppId];
       }

 

귀찮아서 소스만 썻다 보면 알듯이

클라이언트가 Register 메소드를 호출하여 URI와 AppID(구분을 위해)

를 주면 그걸 그냥 List에 저장하는 형식이다.

나중에 이걸 DB로 저장하게 바꾸기만 하면 된다.



 

 

Posted by 동동(이재동)
Windows Phone 72011. 5. 27. 18:31

그냥 여러개로 나누어서 적어보았다.. ㅋㅋ 웬지 그게 더 멋있어 보여서 (헐…)

 

요즘엔 다 이렇게 하더라 ㅋㅋ

자 이제 윈폰 클라이언트 프로그램을 만들어보자..

 

일단 윈폰 프로젝트를 열고

 

private HttpNotificationChannel httpChannel;
  const string channelName = "TestAppUpdatesChannel";
  // Constructor
  public MainPage()
  {
      InitializeComponent();
 
      //Create the channel
 
      //만약 채널이 이미 있으면 
      httpChannel = HttpNotificationChannel.Find(channelName);
 
      //이벤트 등록
      if (httpChannel == null)
      {
          httpChannel = new HttpNotificationChannel(channelName, "HugeFlowAppTestService");
          httpChannel.Open();
          httpChannel.BindToShellToast();
      }           
 
      SubscribeToChannelEvents();
      SubscribeToService();
      
  }

 

채널을 등록하고 open하고 bind 한다.

bindToshellToast()는 망고버전에 나온 좋은 기능이다 더 편리해졌다 ㅋ

 

만약 이미 등록되어있다면

그냥 이벤트만 연결하고 클라이언트 URI를 서버에 전달한다.

 

private void SubscribeToChannelEvents()
       {
           httpChannel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(httpChannel_ChannelUriUpdated);
           httpChannel.ShellToastNotificationReceived += new EventHandler<NotificationEventArgs>(httpChannel_ShellToastNotificationReceived);
       }

 

이렇게 이벤트 연결하고

void httpChannel_ShellToastNotificationReceived(object sender, NotificationEventArgs e)
       {
           StringBuilder message = new StringBuilder();
           string relativeUri = string.Empty;
 
           message.AppendFormat("Received Toast {0}:\n", DateTime.Now.ToShortTimeString());
 
           // Parse out the information that was part of the message.
           foreach (string key in e.Collection.Keys)
           {
               message.AppendFormat("{0}: {1}\n", key, e.Collection[key]);
 
               if (string.Compare(
                   key,
                   "wp:Param",
                   System.Globalization.CultureInfo.InvariantCulture,
                   System.Globalization.CompareOptions.IgnoreCase) == 0)
               {
                   relativeUri = e.Collection[key];
               }
           }
 
           // Display a dialog of all the fields in the toast.
           Dispatcher.BeginInvoke(() => MessageBox.Show(message.ToString()));
       }
       

 

이건 이제 메세지를 받았을때 프로그램에 보여주기 위한 이벤트이다. 메세지를 받았을때 메세지 박스로 띄워준다.

 

 

/// <summary>
 /// MS에서 받아온 url을 서버(WCF Service)에 보낸다.
 /// </summary>
 private void SubscribeToService()
 {
     string appid = "1";
     
     //string baseUri = "http://localhost:19976/Notifications/Register?uri={0}&appId={1}";
     string baseUri = "http://192.168.10.174:6060/Notifications/Register?uri={0}&appId={1}";        
 
     string theUri = String.Format(baseUri, httpChannel.ChannelUri.ToString(),appid);
 
     WebClient client = new WebClient();
     client.DownloadStringCompleted += (s, e) =>
         {
              if (e.Error == null)
              {
                  Dispatcher.BeginInvoke(() => UpdateStatus("Registration Success"));
              }
              else 
              {
                  Dispatcher.BeginInvoke(() => UpdateStatus(e.Error.Message));
              }
 
         };
     
     client.DownloadStringAsync(new Uri(theUri));
 }

 

이렇게 서버에게 URI를 보내 준다. WCF Rest 서비스니 웹처럼 파라미터를 넣어서 전달

 

이렇게 해서 클라이언트 완성


NotificationToastClient.zip

Posted by 동동(이재동)
Windows Phone 72011. 5. 27. 18:21

Surface 프로젝트를 들어가기 하루 이틀전(망고 업데이트가 되기전에) 이미 조금 만들어 놓았던

 

Notification 프로젝트였다. 근데 다행히(?) surface 시연이 끝나고 바로 망고가 나왔다 ㅋㅋ

 

조금밖에 안해 놨었기때문에 크게 수정안해도 됬었다..(어짜피 다시 제작 ㅋㅋ)

 

자 그럼 망고버전에서는 어떻게 Toast Notification을 사용하는지 알아보자 이전버전은 이제 무시하자 미리 포스팅 안하길 잘했다 ㅋㅋ

 

망고 버전 샘플이 있음으로 참고 및 많은 수정을 해서 더 쉽게 만들어 보았다.

 

일단 시작하기위해  3가지를 만들어야 한다.

 

-첫번째 윈폰 클라이언트 프로그램

이건 당연히 만들어야 하는것이다

HttpNotificationChannel을 이용하여 MS으로부터 ChennelUri를 얻어 온다. 이 얻어온 URI을 가지고

클라이언트에게 메세지를 보낸다 클라이언트 고유의 ID라 생각하자.

자 이것을 Notification Server에 보내야 한다.

 

-두번째 WCF Rest Service(그냥 WCF 를 써도 돼지만 난 범용으로 사용 하기 위해서 Rest 사용)

자 이제 아까 만든 클라이언트로부터 URI를 받을것이다.

이것을 저장해 놓자.. 서비스가 절대 멈추지 않을꺼라 생각하면 그냥 저장해도 돼지만

리셋될것을 대비해 DB에 저장해 놓는것이 안전하다.(영구적 서비스라면?)

 

-세번째 메세지를 보내는 관리자를 위한 클라이언트

서버랑 클라이언트가 준비되어 있다면 보낼 메세지를 입력하는 UI를 만들어서 관리자가 메세지를 쓰는

프로그램을 만들어야 한다. 이것역시 서버에 저장된 URI들을 받아서 메세지들을 전달한다.

 

자 이제 두번째 부터는 소스와 같이 윈폰 클라이언트 부터 만들어 보자

Posted by 동동(이재동)
Surface2011. 5. 27. 11:15

휴 힘들었다. 거의 이틀만에 만들으라고해서 아직 surface 개념이 없던 나에게 철야까지 하면서

 

힘들게 만들었다. 기계가 바로 전날 와서 테스트를 못해봐서.. 에물레이터에 맞추어서 만들었는데

 

태그 인식이 잘안되고 됐다가 안됐다가를 반복해서 행사 바로 전날 다시 전체 수정을 했다..

 

Tagvisualizer를 이용해서 멋있게 만들었지만 약간 보여주기 용으로 급수정을 해서 마음이 안좋았다..

 

기계만 좋았어도 ㅠㅠ

 

간략하게 소개를 하자면

 

처음 기계를 켜면 이런 화면이 나온다.

 

image

 

그다음에 책을 올리면

 

image

 

 

 

 

image

 

image

 

image

 

이런식으로 책을 넘길때마다 화면이 바뀌고 동영상이 뜬다.

 

마지막에 Develope에 내이름이 써있다. ㅋㅋ

 

많은 사람들에게 시연하는것이라 긴장도 되었지만 재미 있었다. ㅋㅋ

 

실제 시연 동영상은 여기서 볼수 있다.

 

http://www.youtube.com/watch?feature=player_detailpage&v=ruZvqF9ynJY

Posted by 동동(이재동)
Surface2011. 5. 27. 11:06

WPF에서 이런식으로 스토리를 보여주고 싶었다.(이건 완성된버전 ㅋㅋ)

 

image

 

이건 그냥 TextBlock으로 되는것이 아니다.

 

그래서 FlowDocument를 사용하였다..

 

일단 xaml에서 이렇게 코딩을 했다.

 

<FlowDocumentScrollViewer Grid.Row="1" Grid.ColumnSpan="2" VerticalScrollBarVisibility="Hidden" >
    <FlowDocument Background="Transparent">                                        
        <Paragraph FontFamily="Bell MT" FontSize="24" x:Name="DescriptionParagraph">
            <Floater Width="500"  HorizontalAlignment="Left">                            
                <BlockUIContainer>
                    <Rectangle Height="250" />
                </BlockUIContainer>
            </Floater>
            One Day, most of the town’s roads are ruined by the heavy rain. On that day, school bus-Schoobi happens to be late because of constructions on the road. Worrying that children may be waiting at the bus stop, Schoobi drives through the traffic with full speed, even though other cars are starring at him in a disapproving manner. Schoobi gets to a costal road, however, the road condition there is also messy. Dilly-dallying and regreting to go back. Schoobi ends up ramming into the guardail. Schoobi is now in the danger of falling down the cliff. Can Robocar Poli and his team save Schoobi?
        </Paragraph>
    
    </FlowDocument>
   
</FlowDocumentScrollViewer>
 
보면 알겠지만 FlowDocument에서 Paragraph를 사용하고 안에 Floater를 이용해서 안에 투명한 사각형을 왼쪽에 정렬하고 바깥쪽에 글을 입력하였다.
 
그럼 이제 안에 내용 Text를 계속 유동적으로 바꿔야 한다.
그럼 어떻게 해야할까? behind에서 수정하면 된다.
 
paragrah의 x:name을 DescriptionParagraph를 정의 했으니 이걸 변경하면 된다. 소스를 보자
 
private void SetDescriptionPlaceholder(string param)
        {
            DescriptionParagraph.Inlines.Remove(DescriptionParagraph.Inlines.Where(c => c is System.Windows.Documents.Run == true).Select(c => c).FirstOrDefault());
            DescriptionParagraph.Inlines.Add(param);
        }
 

이렇게 inline을 삭제하고 다시 추가하는 형식으로 바꾸었다.

 

이렇게 하면 끝~

Posted by 동동(이재동)
Surface2011. 5. 19. 16:06

아 이것때문에 시간 아까운데 2시간이나 까먹었다…

 

실버라이트랑 다르게 이상하게

 

Blend로 VisualState를 만들고

 

VisualStateManager.GoToState(this, "Title", true);

 

이렇게 state간의 전환을 할려고 했으나 계속 false를 return 했다. ㅡ.ㅡ!!!

 

인터넷 찾아보니…

 

WPF 버그라던데…

 

해결법은

 

VisualStateManager.GoToElementState(this.Content as FrameworkElement, "Title", true);

 

이렇게 element단위에서 해야한다.. 내참 인터넷에 왜 이런거 해결하는 법 하나도 없는거야?

Posted by 동동(이재동)
wcf2011. 5. 17. 15:57

자 Rest Service를 만들어 보자

 

RestService의 최대강점은  멀티 플랫폼할때 좋다는거다..

 

인자도 그냥 URL형식으로 Get,Post 방법으로 보내면 되고 그렇게 되면 언어나 플랫폼에 상관없이

 

쓸수 있는 아주 편한 진정한 RIA 서비스가 된다.

 

첫번째

 

new-project 해서 새로운 프로젝트를 만들고

 

Online Templates로 간다.. 아마 비쥬얼 스튜디오 2010을 깔았다면 그냥 wcf service가 있을것이다.

 

하지만 우리는 WCF REST Service를 만들것이기때문에 online Template으로 가서 프로젝트를 만든다.

 

image

 

만든뒤에

 

Service1.cs가 보일것이다.

 

물론  이걸써도 돼지만 새롭게 만드는것도 나쁘지 않다.

 

나는 윈폰에서 쓸 Notification Server를 만들꺼기때문에 Notifications.cs란 class를 새로 만들었다.

 

[ServiceContract]
   [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
   [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
   public class Notifications
   {
       private static List<Uri> subscribers = new List<Uri>();
       private static object obj = new object();
 
       [WebInvoke(UriTemplate = "register?uri={uri}", ResponseFormat = WebMessageFormat.Json, Method = "GET")]
       public void Register(string uri)
       {
           // TODO: Return the instance of SampleItem with the given id
           Uri channelUri = new Uri(uri, UriKind.Absolute);
           Subscribe(channelUri);
       }

 

그리고 클래스위에 ServiceContract를 정의 하였으며

 

저렇게 메소드를 만들어서 인자를 받게 만들었다..

 

그리고 중요한 Global.aspx.cs에서

 

 

private void RegisterRoutes()
{
    // Edit the base address of Service1 by replacing the "Service1" string below
    RouteTable.Routes.Add(new ServiceRoute("Service1", new WebServiceHostFactory(), typeof(Service1)));
    RouteTable.Routes.Add(new ServiceRoute("Notifications", new WebServiceHostFactory(), typeof(Notifications)));
}

 

 

이렇게 추가하고 컴파일한후

 

http://localhost:19976/notifications

 

컴파일 뒤에 notifications를 붙여서 접속하면 접속이 잘된다.

 

이제 머 메소드를 붙여 넣든 마음대로 요리하면 된다.

 

아참 이 Registor 메소드를 부르는쪽에서는 이렇게 호출한다.

 

/// <summary>
/// MS에서 받아온 url을 서버(WCF Service)에 보낸다.
/// </summary>
private void SubscribeToService()
{
    string baseUri = "http://localhost:19976/Notifications/Register?uri={0}";        
 
    string theUri = String.Format(baseUri, httpChannel.ChannelUri.ToString());
 
    WebClient client = new WebClient();
    client.DownloadStringCompleted += (s, e) =>
        {
             if (e.Error == null)
             {
                 Dispatcher.BeginInvoke(() => UpdateStatus("Registration Success"));
             }
             else 
             {
                 Dispatcher.BeginInvoke(() => UpdateStatus(e.Error.Message));
             }
 
        };
    client.DownloadStringAsync(new Uri(theUri));
}

 

 

쉽다.

Posted by 동동(이재동)
Windows Phone 72011. 5. 3. 10:15

일단 링크로 대신 나중에 포스트

http://chriskoenig.net/2010/08/16/customizing-wp7-push-notification-tiles/

Posted by 동동(이재동)
Windows Phone 72011. 4. 26. 16:22

윈폰용도 폰인지라.. 모바일 광고를 넣을수가 있다.

 

일단 Microsoft Advertising SDK for wp7을 깔자

 

http://msdn.microsoft.com/en-us/library/ff973720(v=msads.10).aspx

 

그리고

 

레퍼런스에 참조하고 이런식으로 그냥 컨트롤을 xaml에 넣고

 

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <ad:AdControl x:Name="AdControl" AdUnitId="29398 " ApplicationId="b1bc2b62-4f51-4f85-a69c-d28119424405"  VerticalAlignment="Bottom" AdModel="Contextual" Width="420" Height="80" Margin="11,0,25,234" />
        </Grid>

 

Behind코드에

 

메인에 꼭 이걸 써넣자

// Constructor
       public MainPage()
       {
           InitializeComponent();
           Microsoft.Advertising.Mobile.UI.AdControl.TestMode = false;
       }

 

저걸 하지 않았을 경우 광고가 나왔다가 바로 사라진다..

Posted by 동동(이재동)
Windows Phone 72011. 4. 25. 15:16

일단 폰 정보를 얻기 위해서

WMAppManifest.xml에 이걸 추가하고

 

<Capability Name="ID_CAP_IDENTITY_USER" />

<Capability Name="ID_CAP_IDENTITY_DEVICE" />
 
private string GetPhoneANID()
{
    object anid = UserExtendedProperties.GetValue("ANID");
    if (anid == null)
    {
        byte[] deviceId = (byte[])DeviceExtendedProperties.GetValue("DeviceUniqueId");
 
        string id = BitConverter.ToString(deviceId).Replace("-", "");
        anid = id;
    }
    else
    {
        anid = anid.ToString();
    }
 
    return anid as string;
}

이렇게 해서 얻어오면 된다.
Posted by 동동(이재동)
Windows Phone 72011. 4. 22. 13:50

WMAppManifest.xml 에

 

<Capability Name="ID_CAP_IDENTITY_DEVICE"/>

 

를 추가하고

 

string model = null;
object theModel = null;
 
if (Microsoft.Phone.Info.DeviceExtendedProperties.TryGetValue("DeviceName", out theModel))
    model = theModel as string;
MessageBox.Show(model);

 

를 코딩하면 된다.

 

출처 : http://www.nickharris.net/2011/01/finding-the-device-model-on-windows-phone-7/

Posted by 동동(이재동)
Windows Phone 72011. 3. 31. 17:54

이란 에러 메세지를 자주 본다.

 

만약 behind코드(xaml.cs)라면

 

Dispatcher.BeginInvoke(() =>
                                    {
                                        NavigationService.Navigate(new Uri("/Views/RecordView.xaml", UriKind.RelativeOrAbsolute));
                                    });

 

이렇게 쓰면 되겠지만

 

ViewModel 이나 Service에서는 어떻할까?

 

Deployment.Current.Dispatcher.BeginInvoke( ()=>
                       {
                           ServiceLocator.Current.LocationPermissionViewModel.NoButtonClick(null);
                       });

 

이렇게 쓰면 된다.

 

참조 : http://social.msdn.microsoft.com/Forums/en/adodotnetdataservices/thread/43177228-1ab2-4489-afea-89b0bf61bdd7

Posted by 동동(이재동)
Windows Phone 72011. 3. 31. 15:13
xaml 상단에 이렇게 datacontext를 연결하고
 
DataContext="{Binding BookViewModel, Source={StaticResource Locator}}"
 
<phone:PhoneApplicationPage
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:controls="clr-namespace:HugeFlow.FortuneCoins.Controls"
    xmlns:uc="clr-namespace:HugeFlow.FortuneCoins.Controls"
    xmlns:wp="clr-namespace:HugeFlow.Phone.Controls;assembly=HugeFlow.Phone.Controls"
    xmlns:Custom="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:HugeFlow_CommandPattern_Interactivity="clr-namespace:HugeFlow.CommandPattern.Interactivity;assembly=HugeFlow.MVVM" 
    x:Class="HugeFlow.FortuneCoins.Views.BookView"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="480"    
    shell:SystemTray.IsVisible="False" DataContext="{Binding BookViewModel, Source={StaticResource Locator}}">
 
behind에서 datacontext를 연결한후
 
private LocationPermissionViewModel _viewModel;
 
     public LocationPermissionView()
     {
         InitializeComponent();
         _viewModel = this.DataContext as LocationPermissionViewModel;
     }
 
그리고 커맨드를 사용할 버튼 이벤트에 이렇게

private void NoButton_Click(object sender, RoutedEventArgs e)
      {
          _viewModel.NoButtonClickCommand.Execute(null);
      }
Posted by 동동(이재동)
Windows Phone 72011. 3. 25. 17:23

 

다운 받을수 있는 url

http://www.innovativetechguy.com/?p=13

 

 

image

 

이렇게 생겼는데 2가지 모드를 지원한다. 마켓 플레이스 모드로 찍으면 마켓플레이스에 올릴 480 680

 

으로 짤라서 찍고 other로 하면 에뮬레이터 자체를 찍는다.

 

유용한듯?

Posted by 동동(이재동)
Windows Phone 72011. 3. 24. 16:07
 about페이지에 버전을 적어야 할때 프로젝트에서 버전정보를 입력하고
 
Properties의 AssemblyInfo.cs에서 AssemblyVersion을 입력하 곤하는데
 
이걸 빼오는 법이다.
 
Assembly assem = System.Reflection.Assembly.GetExecutingAssembly();
           AssemblyName assemblyName = new AssemblyName(assem.FullName);
 
           Version = assemblyName.Version.ToString(3);
 
 

간단하다..

Posted by 동동(이재동)