ã¯ããã«
ãSilverlight 4ã®ä¿¡é ¼ãããã¢ããªã±ã¼ã·ã§ã³ã¯ãããã¾ã§ã®RIAã«ã¯ãªãå¤ãã®æ©è½ãæä¾ãã¦ãã¾ããååã®è¨äºã§ã¯ããã¼ã«ã«ãã¡ã¤ã«ã¢ã¯ã»ã¹ãããªã·ã¼ãã¡ã¤ã«ãå¿ è¦ã¨ããªããããã¯ã¼ã¯ã¢ã¯ã»ã¹ãã¦ã¼ã¶ã¼ã¨å¯¾è©±ãå¿ è¦ã¨ããªãããã¤ã¹ã¸ã®ã¢ã¯ã»ã¹ã«ã¤ãã¦è§£èª¬ãã¾ããã
ãä»åã¯ãå¼ãç¶ãä¿¡é ¼ãããã¢ããªã±ã¼ã·ã§ã³ã®ãã¤ãã£ãçµ±åã«ã¹ããããå½ã¦ã¦ã解説ãè¡ã£ã¦ããã¾ãã
ãã¤ãã£ãçµ±å
ãSilverlight 4ã®ä¿¡é ¼ãããã¢ããªã±ã¼ã·ã§ã³ã§ã¯ãSilverlightãåä½ããã¯ã©ã¤ã¢ã³ãã«ãããããã¤ã³ã¹ãã¼ã«ããããªã¼ãã¡ã¼ã·ã§ã³ãªãã¸ã§ã¯ããå©ç¨ãã¦ãExcelãèµ·åããããVisual Basic 6ï¼ä»¥ä¸ãVB6ï¼ã§ä½æããã¢ããªã±ã¼ã·ã§ã³ãSilverlightããå©ç¨ã§ãã¾ãã
ãªã¼ãã¡ã¼ã·ã§ã³
ããªã¼ãã¡ã¼ã·ã§ã³ã¯ãä½æããã¢ããªã±ã¼ã·ã§ã³ãã¹ã¯ãªãããä»ã®ã¢ããªã±ã¼ã·ã§ã³ããå¼ã³åºãããã®æ©è½ã§ãããªã¼ãã¡ã¼ã·ã§ã³ã®æè¡ãã®ãã®ã¯ãWindows以å¤ã®OSã§ãå©ç¨ã§ããæè¡ã§ãããSilverlightã®ãã¤ãã£ãçµ±åã§ã¯Windowsã®ã¿ã§å©ç¨ã§ãã¾ãã
ããªã¼ãã¡ã¼ã·ã§ã³ãªãã¸ã§ã¯ãã«ã¤ãã¦ã¯ã次ã®URLã§è©³ãã解説ããã¦ãã¾ãã
ãSliverlightã§ãªã¼ãã¡ã¼ã·ã§ã³ãªãã¸ã§ã¯ããä½æããããã«ã¯ãSystem.Runtime.InteropServices.Automation.AutomationFactoryã¯ã©ã¹ã®CreateObjectã¡ã½ãããå©ç¨ãã¾ãããªã¼ãã¡ã¼ã·ã§ã³ãªãã¸ã§ã¯ããä½æããå ´åã¯ãç¾å¨ã®åä½ç°å¢ããªã¼ãã¡ã¼ã·ã§ã³ããµãã¼ããã¦ããããIsAvailableããããã£ã§ç¢ºèªããå¿ è¦ãããã¾ãã
ããããªã¼ãã¡ã¼ã·ã§ã³ããµãã¼ããããªãç°å¢ã§ãCreateObjectã¡ã½ããã使ç¨ãã¦ãªã¼ãã¡ã¼ã·ã§ã³ãªãã¸ã§ã¯ããä½æãããã¨ããã¨ãNotSupportedExceptionã®ä¾å¤ãçºçãã¾ãã
ããªã¹ã1ã¯AutomationFactoryã¯ã©ã¹ãå©ç¨ãã¦ãExcelãªãã¸ã§ã¯ããä½æãã¦ããä¾ã§ãã
// ãªã¼ãã¡ã¼ã·ã§ã³ãå©ç¨å¯è½ãã確èªãã if (!AutomationFactory.IsAvailable) return; // Excelã®ãªã¼ãã¡ã¼ã·ã§ã³ãªãã¸ã§ã¯ããä½æããã dynamic excel = AutomationFactory.CreateObject("Excel.Application")
ãC#4.0ã§ã¯ãdynamicãã¼ã¯ã¼ããå©ç¨ãã¦ãAutomationFactoryã¯ã©ã¹ã®CreateObjectã¡ã½ãããè¿ããªãã¸ã§ã¯ãã«å¯¾ãã¦ãåçãªããã°ã©ãã³ã°ãè¡ããã¨ãã§ãã¾ãã
ãdynamicãã¼ã¯ã¼ããå©ç¨ããããã«ã¯ãMicrosoft.CSharp.dllã¸ã®åç §ãå¿ è¦ã§ããä¸è¨ã®ã¢ãã¬ã¹ããåç §è¨å®ãè¡ã£ã¦ãã ããã
- %ProgramFiles(x86)\Microsoft SDKs\Silverlight\v4.0\Libraries\Client\Microsoft.CSharp.dll
ãããã°ã©ã IDã¯ããªã¼ãã¡ã¼ã·ã§ã³ã¨ãã¦ã¤ã³ã¹ãã¼ã«ãããããã°ã©ã ã«å²ãå½ã¦ãããååã§ããã¬ã¸ã¹ããªã¨ãã£ã¿ã¼ï¼REGEDIT.exeï¼ããHKEY_LOCAL_MACHINE\SOFTWARE\Classesã«è¿½å ããã¦ããã¨ã³ããªã¼ï¼å³1ï¼ã調ã¹ããã¨ã§ç¢ºèªã§ãã¾ãã
ãVisual Studio 2010ãã¤ã³ã¹ãã¼ã«ãã¦ããå ´åã¯ãOLE/COM Object Viewerï¼å³2ï¼ã§ã確èªã§ãã¾ãã
ãCreateObjectã¡ã½ããã§æå®ããã代表çãªããã°ã©ã IDã表1ã«ç¤ºãã¾ããCreateObjectã¡ã½ããã§ãã¯ã©ã¤ã¢ã³ãã«ã¤ã³ã¹ãã¼ã«ããã¦ããªãããã°ã©ã IDãæå®ããå ´åãSystem.Exceptionã®ä¾å¤ãçºçãã¾ãã
ããã°ã©ã ID | çæããããªã¼ãã¡ã¼ã·ã§ã³ãªãã¸ã§ã¯ã |
WbemScripting.SWbemLocator | WMIï¼Windows Management Instrumentationï¼ |
WScript.Shell | WSHï¼Windows Scripting Hostï¼ |
Scripting.FileSystemObject | ãã¡ã¤ã«ã·ã¹ãã |
Excel.Application | Excel |
Word.Application | Word |
ADODB.Connection | ADOã®ãã¼ã¿ãã¼ã¹ã³ãã¯ã·ã§ã³ |