这个例外
System.Runtime.InteropServices.COMException (0x800706BA):
The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
Run Code Online (Sandbox Code Playgroud)
当我在任何机器上运行它时,在我的Windows服务中收到,但是当我在测试应用程序中测试它时,不会抛出任何异常.在我的代码中,我正在做的是将两个.DAT文件转换为.xls文件.当我通过services.msc启动服务并运行服务时,它运行正常一段时间,但在更新某些行后,它会抛出异常,然后没有任何反应.我有两个独立的功能,分别完成工作.示例代码是:
public void SaveData_component(string filename)
{
try
{
string filepath = System.Configuration.ConfigurationSettings.AppSettings["filepath"].ToString() + filename;
filepath_first = filepath;
object missing = Missing.Value;
//string getExtension = Path.GetExtension(filepath);
string getFilename = Path.GetFileNameWithoutExtension(filepath) + "New";
string filepathNew = System.Configuration.ConfigurationSettings.AppSettings["filepath"].ToString() + getFilename + ".xls";
try
{
xlAppNew1 = new Application();
xlAppNew1.DisplayAlerts = true;
workbooks1 = xlAppNew1.Workbooks;
workbook1 = workbooks1.Open(@filepath, 0, true, 1, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0); …Run Code Online (Sandbox Code Playgroud) 我有一张员工表,工资根据年数如下:
Employee_table
-----------------------------------------------------------------------------
emp_ID - FirstName- LstName salary ... year -
001 - xx - yy - 03212 2000
001 - xx - yy - 04212 2001
002 - xxx - yyy - 03425 2000
002 - xxx - yyy - 04425 2001
003 - xxxx - yyyy - 03429 2000
003 - xxxx - yyyy - 04429 2001
------------------------------------------------------------------------------
Run Code Online (Sandbox Code Playgroud)
我想写一个查询,它会在列方面给我一年的员工数据:
tblResults
---------------------------------------------------------------------
emp_ID 2000 2001 .... ....
---------------------------------------------------------------------
01 03212 04212
02 03425 - 04425
03 03429 04429
Run Code Online (Sandbox Code Playgroud)