部署一个C#和#x2B;Linq控制台应用程序?

部署一个C#和#x2B;Linq控制台应用程序?,c#,linq,deployment,console-application,C#,Linq,Deployment,Console Application,如何编译和部署使用linq的C#/.NET3.5控制台应用程序? 我在VisualStudio2008(新项目>Visual C#>Windows>控制台应用程序)中编写了一个控制台应用程序“ExcelDriver”,它使用Excel.Interop和linq to sql。[1] Build menu > Clean ExcelDriver Build menu > Build ExcelDriver 这会将文件放在文件夹C:\dev\VisualStudio2008\Exce

如何编译和部署使用linq的C#/.NET3.5控制台应用程序?

我在VisualStudio2008(新项目>Visual C#>Windows>控制台应用程序)中编写了一个控制台应用程序“ExcelDriver”,它使用Excel.Interop和linq to sql。[1]

Build menu  > Clean ExcelDriver
Build menu > Build ExcelDriver
这会将文件放在文件夹C:\dev\VisualStudio2008\ExcelDriver\ExcelDriver\bin\Release中\

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,那就赶紧跑吧。(对我来说太晚了。省省吧!)

您需要将.NET Framework 3.5部署到目标机器上


在您同事的计算机上更新到.NET 3.5,您应该被设置。

检查目标计算机是否安装了正确的.NET版本-您可以使用该站点进行检查


它将需要与您为

开发的相同的.Net 3.5版本。我以前遇到过这个问题-似乎System.Core上缺少一个参考

打开.csproj文件并添加一行,如下所示:

然后重新启动visual studio实例-这应该可以工作


paul

他可能缺少.NET 3.5,您需要使用System.Data.Linq。您的同事缺少.NET 3.5,这是从Microsoft下载的。简单问题,10秒内回答3次相同的问题:-)脚注+1!-)确切地如果你想让它“独立”,你可以使用像NSIS这样的安装程序(见url)将它打包在一起,尽管.NET3.5是一个相当大的安装。