如何編譯和部署使用linq的C#/ .NET3.5控制檯應用程序?部署C#+ Linq控制檯應用程序?
我在Visual Studio 2008(新建項目> Visual C#> Windows>控制檯應用程序)中編寫了一個控制檯應用程序「ExcelDriver」,它使用Excel.Interop和linq-to-sql。 [1]
Build menu > Clean ExcelDriver
Build menu > Build ExcelDriver
這讓文件在文件夾C:\ dev的\ VisualStudio2008 \ ExcelDriver \ ExcelDriver \ BIN \發佈\
Directory of C:\dev\VisualStudio2008\ExcelDriver\ExcelDriver\bin\Release
03/30/2011 02:17 PM 12,800 ExcelDriver.exe
03/25/2011 12:14 PM 411 ExcelDriver.exe.config
03/30/2011 02:17 PM 26,112 ExcelDriver.pdb
03/30/2011 01:32 PM 1,093,632 Interop.Excel.dll
03/30/2011 01:32 PM 417,792 Interop.Microsoft.Office.Core.dll
5 File(s) 1,550,747 bytes
C:\dev\VisualStudio2008\ExcelDriver\ExcelDriver\bin\Release>ExcelDriver.exe
當我運行它哪個完美的作品。
但是,當我將這5個文件複製到我的同事的計算機並運行時,它失敗並且抱怨它無法找到System.Data.Linq。如果我複製整個項目文件夾,也會發生這種情況。
這裏的同事機
C:\ExcelDriver>ExcelDriver.exe
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or ass
embly 'System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c
561934e089' or one of its dependencies. The system cannot find the file specifie
d.
File name: 'System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b
77a5c561934e089'
at ExcelDriver.Program.Main(String[] args)
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\M
icrosoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure lo
gging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fus
ion!EnableLog].
C:\ExcelDriver>
顯然我失去了一些東西,當我編譯應用程序上的錯誤信息。我必須做些什麼來獲得所有組件以及什麼都不在一個地方,以便我可以部署到其他機器上?
[1]對我來說這是一個非常不愉快的經歷。從我的痛苦中學習...如果有人曾經建議您寫一個C#應用程序來控制Excel RUN AWAY。 (對我來說太遲了,請保存下來!)
他可能缺少.NET 3.5,你需要使用System.Data.Linq程序。 – alexn 2011-03-30 21:02:40
您的同事缺少.net 3.5,它是從Microsoft下載的。 – 2011-03-30 21:02:46
簡單的問題,相同的答案在10秒內3次:-) – Snowbear 2011-03-30 21:04:33