// I have used this function still problem persists
protected void killExcel(Microsoft.Office.Interop.Excel.Application exc)
List<microsoft.office.interop.excel.workbook> wbs = new List<microsoft.office.interop.excel.workbook>();
List<microsoft.office.interop.excel.worksheet> wss = new List<microsoft.office.interop.excel.worksheet>();
foreach (Microsoft.Office.Interop.Excel.Workbook wb in exc.Workbooks)
foreach (Microsoft.Office.Interop.Excel.Worksheet ws in wb.Worksheets)
wss.Add(ws); // collect worksheets
wbs.Add(wb); // collect workbooks
for (int i = 0; i < wss.Count; i++)
System.Runtime.InteropServices.Marshal.ReleaseComObject(wss[i]); // release it
wss[i] = null; // null it
for (int i = 0; i < wbs.Count; i++)
wbs[i].Close(null, null, null);
System.Runtime.InteropServices.Marshal.ReleaseComObject(wbs[i]); // release it
wbs[i] = null; // null it
exc.Workbooks.Close(); // so you can close this
exc.Quit(); // so you can quit this
System.Runtime.InteropServices.Marshal.ReleaseComObject(exc); // release it
exc = null;
GC.Collect(); // this sets up the finalizers
GC.Collect(); //apparently this kills it
catch (Exception ex)
// deal with it fool!
I found this in the documentation on one of the COM Release functions:
// Note that COM objects that raise events within a .NET client require two Garbage Collector (GC)
// collections before they are released. This is caused by the reference cycle that occurs between
// COM objects and managed clients. If you need to explicitly release a COM object you should call
// the Collect method twice.
So I do a double GC on the main app object if I've setup any event handlers for it.
Normally not... but the problem is that all language specific char may not be read correctly. For exemple instead of ü i get | ... to solve that problem I have to decode the table (this is already done)
The problem is that some times I get tables that are already encoded correctly... in that case I don't need to decode the table...
Life is not short... the problem is only how you organize yourself
I'm trying to connect remotely from phone to pc. Currently I tested it in cradle mode. When I tried running my program (which is in the phone) it occured an error: Cannot find DbNetlib.dll. However, when I tried a pc to pc wireless connection (using an emulator) it works. It connects to the server just fine. Does anyone know how I can make my PDA phone connect to the server? I'm just copying the .exe file of my project file by the way.
i need to call a c# code in my java program. i followed the approach given in the codeproject link: http://www.codeproject.com/KB/cross-platform/javacsharp.aspx but there are some issues in generating netmodule , which is required to perform further steps. but it is giving an error
"csc /debug /t:module "bin\Debug\\HelloWorld.dll"" exited with code 9009 on using post build event command line.
E:\c#\getOLCont\getOLCont>csc /t:module form1.cs
the error is:
fatal error CS0009: Metadata file 'c:\Program Files\Reference
could not be opened -- 'File is corrupt.'
i have tried the command on different machines but there is same result.
HI, I want to iterate only those rows of excel sheet where the data have written, means if user has filled only first 15 rows then my loop should iterate to 15 only,hO wcan i do that Below is sample code which iterates up to 65536 rows,unnecessarily ,but the data are present only in first 15 or 18 rows. Please give me a solution or an idea
This is my sample code
Microsoft.Office.Interop.Excel.Application Excelobj = new Microsoft.Office.Interop.Excel.Application();
if (Excelobj == null)
MessageBox.Show("Excel couldn't be started", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
i want to create crystal report for access(password protected)database.i do it bu this project run another computer error messege come loginfo.
please help.i want to diploy database datadirectory.i using visual studio 2005 exprees editon.(crystal report for .net framewort 2)
get more example.because i am biginner
I would suggest you buy a beginner book and work through it, start with someting simpler, then work up to this. If you're being paid to do this, let your client know they made a poor choice and they should move on.
No longer a Microsoft MVP, but still happy to answer your questions.
Hi i am sending mail to different ids...,
Everything going on well....,
I am going to make this application to exe and put it in schedular task...,
This things will execute automatically...,
Now my probs is suppose mailserver is down...,
Then it will be probs in mailsend...,
So in that case how to handle the code.., it mean if the mailserver will down or mail didnt send properly...,
Then it have to be fire again, after some minutes or some other condition have to do how to do that?
This is my code:
DirectoryInfo dInfo = new DirectoryInfo(mypath);
DirectoryInfo dInfos = dInfo.GetDirectories();
foreach (DirectoryInfo d in dInfos)
MailMessage mailMessage = new MailMessage();
MailAttachment attach = null;
mailMessage.From = "Magesh@Test.com";
mailMessage.To = d.Name;
mailMessage.Subject = "Hi";
//mailMessage.Body = "Hi This One Is For Testing
FileInfo fInfos = d.GetFiles();
foreach (FileInfo f in fInfos)
attach = new MailAttachment(f.FullName);
mailMessage.To = "";
attach = null;
Thanks & Regards,
please don't forget to vote on the post
Last Visit: 25-May-20 20:31 Last Update: 25-May-20 20:31