2011-03-30 60 views
4

如何编译和部署使用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。 (对我来说太迟了,请保存下来!)

+2

他可能缺少.NET 3.5,你需要使用System.Data.Linq程序。 – alexn 2011-03-30 21:02:40

+0

您的同事缺少.net 3.5,它是从Microsoft下载的。 – 2011-03-30 21:02:46

+0

简单的问题,相同的答案在10秒内3次:-) – Snowbear 2011-03-30 21:04:33

回答

0

更新到.NET 3.5的你的同事的机器上,你应该设置。

0

检查目标机器已经安装了.NET的正确版本 - 您可以使用smallestdotnet.com现场检查

这将需要您为

0

发展我有这个相同的.Net 3.5版本问题之前 - 这似乎是有上System.Core程序

丢失的引用

打开你的.csproj文件,并添加类似于下面的一行:

然后重新启动您的Visual Studio实例 - 这应该工作

保罗