Excel-DNA / Samples

Various sample projects and snippets related to Excel-DNA
MIT License
124 stars 80 forks source link

Samples-master>Logging log missing? #2

Open kennethlou opened 8 years ago

kennethlou commented 8 years ago

Hi,

I tried using the sample logging functionality in the Samples-master but unfortunately no log is created however the solution was built successfully. I did read through the readme and documentation / code and also tried to play with the code but did not have any luck.

Can you kindly give me a hand please?

Regards, Ken

govert commented 8 years ago

With the Logging sample, the check-in version of the .xll.config file enables logging to a file called TextWriterOutput.log. When running the add-in, this file is created next to the .xll file in bin\Debug.

Is this not what you see?

kennethlou commented 8 years ago

Yes I did read the code and the config.

However, after I compiled the code into xll (VS2010), and load the xll into Excel 2010, I did not see the log file being created. I thought the AutoOpen function does not work so I copy and log code into one of the functions then re-compiled everything then load the xll and run the function directly in Excel but still the log file did not appear. Then I thought I need to create the file manually first but still did not work.

Any clue?

govert commented 8 years ago

You can check that the .xll.config file has the right name and is next to the .xll file. If anything was renamed, it might go wrong. I notice that if you have 64-bit Excel, you have to change the .config name to Logging-AddIn64.xll.config (or make another file). The .xll picks up the .config file by matching the name. I just ran the project (F5) as I have it (unchanged from the GitHub version) and the file got created.

jimfoye commented 6 years ago

I'm having a similar problem. When I build and run as is, I don't see any log file.

Actually, at first I could not load the add-in at all because of some kind of XML serialization error. So I updated the dependencies and changed the target .NET framework to 4.6.2. That got rid of the error, but I still saw no log file. Next I tried to debug it, but the breakpoints will not hit because symbols are not loaded. I know that sounds like a stupid VS problem, but I have been debugging my own Excel-DNA add-in without problems for months now, and I cannot figure out why I'm having this problem here.

OK, so i just rolled back to the Github version, and now for some reason the XML serialization error does NOT appear (of course I expected it to come back). I still don't see a log file generated, and I still can't hit a breakpoint in VS.

I'm on VS 2015 and Excel 2010.

Any help appreciated. Also, maybe it would be good to update the project's dependencies to latest Excel-DNA, etc.

jimfoye commented 6 years ago

When I rolled back I of course undid the changes to the Logging-AddIn.xll.config file. I went back in and uncommented the Nlog section.

Ok, now when I load Logging-AddIn.xll I get

There was an error during processing of C:\GitHub\Samples\Logging\bin\Debug\Logging-AddIn.dna: There is an error in XML document (0, 0). The type initializer for 'System.Xml.Serialization.XmlSerializationReader' threw an exception.

I don't get the error when I load Logging-AddIn-packed.xll.

Still not seeing a log file appear in \bin\debug. And still can't debug.