|
Hi,
I was trying to Automate MS Excel, I want to check the validity of a COM Object in C#. For Instance, after releasing a sheet Object using "Marshal.ReleaseComObject(m_oSheets)" Sheet object is not equal to null. How to check a COM Object is valid or not.
Thanks in Advance.
Excel._Application m_oApplication;
Excel.Workbooks m_oWorkBooks;
Excel._Workbook m_oWorkBook;
Excel.Sheets m_oSheets;
Excel._Worksheet m_oWorkSheet;
Marshal.ReleaseComObject(m_oSheets);
if (m_oSheets == null)
{
......
}
|
|
|
|
|
KarthikonIT wrote: after releasing a sheet Object using "Marshal.ReleaseComObject(m_oSheets)" Sheet object is not equal to null.
Do the docs say it will be null, or is it your job to set it ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Docs says it will be null for C# Object but it is not null even after releasing the Excel Object with the following code "Marshal.ReleaseComObject(m_oSheets)". I don't want to set it to null. My question is "How do i know the particular Excel Object is valid or not".
Thanks for response
|
|
|
|
|
|
You can write a program that launches other programs, to embed those programs in your app is possible, but hacky and unreliable. I would not try it.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
I guess the simplest way to put it is that I need to figure out how to launch those programs. I've heard of images being able to be shown in pictureboxes...but I really will only have one image. All of the others are going to be some sort of application. How do I make it so when a button is clicked, the application will open. It doesn't have to open within the program though. Also, I'm going to be handing the program out on cds and I need to make sure there will be a way for the program to find the applications on the computer it is in. I'm thinking this can be done by just saving the application onto the cd as well.
|
|
|
|
|
jnwel wrote: How do I make it so when a button is clicked, the application will open.
Process.Start(@"path to application");
Yes, you need to know the full path, or just give a filename if the exes are in the same folder as your exe.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Hello everyone,
Any idea about how to get the content-type for a video file? I am writing an ASP.Net application which writes video binary content back to browser client to invoke related media player, and needs to fill-in the content-type field of response header.
thanks in advance,
George
|
|
|
|
|
You've been here long enough to know where the ASP.NET forum is. There's also tons of websites that list all the known content types. If you're asking how to know what the type is, the file extension is your best bet.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
So sorry, Christian!
Forget that forum, moving there.
regards,
George
|
|
|
|
|
George_George wrote: which writes video binary content back to browser client to invoke related media player
This is determined by the browser and not your ASP.NET application. ASP.NET can't invoke related media player on a client machine.
As CG said, this is wrong forum.
|
|
|
|
|
Thanks Navaneeth,
I will move to ASP.Net forum, let us move there.
regards,
George
|
|
|
|
|
hello all,
i have a c# window application form in which i have made options through the menustrip like file---> Open-----> New----> EXIT .... etc
here i have written the code this.close() for EXIT. and if i run the application and click the EXIT it will close the application
Now i want the same thing to be occured if i press ctrl+x through the Keybord.
How to code this in c#.
Thanks & Regards
TJS
|
|
|
|
|
As far as I know you can set the shortcut from the properties window in visual studio.
|
|
|
|
|
hello Giorgi Dalakishvili,
Thanks a lot
TJS
|
|
|
|
|
You are welcome
|
|
|
|
|
you can also use keydown envent
|
|
|
|
|
Why complicate things that Framework can handle itself?
|
|
|
|
|
Any recommendation for this?
|
|
|
|
|
If a method has no side effects, and fetches something in a fairly straightforward manner (it shouldn't read a database or something), yes, consider using a property instead.
Cheers,
Vıkram.
Stand up to be seen. Speak up to be heard. Shut up to be appreciated.
|
|
|
|
|
Hi Guys,
I want to write to event log with log4net eventlogappender, but could not get the output in event log. Below is my code snippets
<code>Creating root</code>
Hierarchy root=(Hierarchy) log4net.LogManager.CreateRepository("trial");
root.Configured=true;
root.Root.Level=log4net.Core.Level.Warn;
log4net.ILog log=log4net.LogManager.GetLogger("trial",root.Name);
log4net.Repository.Hierarchy.Logger loggerRepo=(log4net.Repository.Hierarchy.Logger)log.Logger;
<code>create layout</code>
log4net.Layout.PatternLayout objPatterLayout=new log4net.Layout.PatternLayout("Date:%d,Thread:[%t]");
<code>add appender to root after setting its properties</code>
EventLogAppender appenderEventLog=new EventLogAppender();
appenderEventLog.MachineName=".";
appenderEventLog.LogName="System";
appenderEventLog.ApplicationName="trial apps";
appenderEventLog.Layout=objPatterLayout;
appenderEventLog.ActivateOptions();
loggerRepo.AddAppender(appenderEventLog);
log4net.ILog log2=log4net.LogManager.GetLogger("trial",typeof(Form1).Name);
if(log2.IsErrorEnabled)
log2.Error("Error from trial apps");
if(log2.IsInfoEnabled)
log2.Warn("info from trial apps");
I use to get IsErrorEnabled as true, but cant see the output. I think I am missing Source, but there is no property to set the source.
Pls let me know, if I miss any properties.
thanx in advance.
Thanks,
Chintan(India)
|
|
|
|
|
Do you have enough permissions to write to event log?
|
|
|
|
|
Hi Giorgi,
Yes, I have full admin permission.
I try the same with .NET EventLog class which was working fine...
Thanks,
Chintan(India)
|
|
|
|
|
Hi,
I have created an entry in a custom event log:
if (!EventLog.SourceExists("TestSource"))
EventLog.CreateEventSource("TestSource", "System");
EventLog evtLog = new EventLog();
evtLog.Source = "TestSource";
evtLog.WriteEntry("This is a test", EventLogEntryType.Information);
I now decide to use my own custom log so I change "System" to "TestLog".
This doesn't do anything. The event is still logged to the "System" log even if I try deleting the source but if I use a different source, it then gets logged correctly to "TestLog"
if (EventLog.SourceExists("TestSource"))
EventLog.DeleteEventSource("TestSource");
If I go into the registry, I find a list of sources for the System event log but even if I delete the TestSource entry from there it still logs events to the System event log.
This MSDN article suggests that you can remove a source association from a log but it's not correct as far as I can tell:
http://msdn.microsoft.com/en-us/library/k57466fc(VS.71).aspx[^]
What's going on? It seems that once a source is associated with a log there's no way of removing that association.
|
|
|
|
|
Restart your machine...Hope it will work.
Thanks,
Chintan(India)
|
|
|
|