I have a need to record parameter values of methods been called with in application. A kind of log.
I don't want to touch the code of the running application dll, by adding a row in each method to log it.
Is there any way I can some kind mechanism to capture input/ouput paramert values, by inserting logger code into the dll without touching the main source code? i am trying to achive this in C#
You will achieve this by using AOP. Refer this link for more information.
Also have a look into this stackoverflow link.
Related
My company has an MS Access application, and in the VBA a of this, they have a form with data in the fields. They had me make a C# application that needs to use the data from these fields on the MS Access form.
I could easily send this data to a table and write SQL to access this in the C# application. However, they would like me to make an executable of the C# application and pass the fields in parameters to the executable.
I cannot find anything on this, is it possible? If so, can someone give me an idea of how to do this?
Thanks
No because I cannot find anything on this, and I have no idea how to even start in anyway.
My Excel can download data from a data provider via an AddIn.
From the help pages of the provider, I found out (and tested) that it is possible to "Refresh" the data by calling the following command in VBA:
Application.COMAddIns("PowerlinkCOMAddIn.COMAddIn").Object.RefreshWorkbook
After spending a couple of hours searching on the internet I couldn't find an answer on how I can call exactly the same method by using C#.
As I have many of these spreadsheets that need to be updated regularly, I am trying to automate the process.
One way to probably achieve this would be to inject a new macro every time I open the spreadsheets with the above command and call it, but I would prefer calling it directly with C# if possible.
A second solution would be to use Python or another language to
download the data in CSV format and link my spreadsheets to the CSVs
but this process also seems an overkill.
Many thanks in advance.
You can use the late-biding technology (Reflection in .net) for calling methods and properties without casting an object to the actual type, see Type.InvokeMember for more information.
Application.COMAddIns("PowerlinkCOMAddIn.COMAddIn").Object.GetType().InvokeMember("RefreshWorkbook" ...
Also you may find the HowTo: Communicate with a COM add-in from a standalone application article helpful. A sample code in C# is included.
I have looked at the various levels(application, workbook, and worksheet) of the Excel.Interop libraries to find out how to detect a user sorting data. I have created a class that instantiates an application, workbook, and worksheet. The program has data piped in from another application and then adds it to a worksheet. I am using .NET 4.5, C# compiler version 4.0, and have been testing with Excel 2013 if that makes a difference.
I can detect cell changes and calculation events but neither of those events fire when a column is sorted. I believed that it should work after reading this article.
After having that fail for me, I looked into the table update event but I had no luck. There error I received was along the lines of, "the handler does not exist in the Microsoft.Office.Interop.Excel namespace, are you missing an assembly. I don't think this is the right direction I need to go but I was attempting to see if it would suit my needs.
Using any other method besides the Excel Interop method might set me back a few weeks.
Is there something I am missing in regards to the table update event handler or perhaps the sort event itself?
Introduction: I have qt-opencv-multithreaded - Qt/OpenCv application writen in C++ (running on Windows). But I also have another application written in C#.
C++ app does analysis of video and identifies robots (position, rotation). And stores it in variable inside ProcessingThread.
C# app receives these values and decides where should robots move.
I decided to use C# project as startup project. And I tried to create C++/cli wrapper for qt-opencv-multithreaded .
Questions: Now I have two questions:
How do I run the Qt app from another project? I tried to add include MainWindow.h to wrapper project and create instance from it. I added also directory of qt-opencv-multithreaded to "Additional Include Directories" but it wants also qt directories and I am worried that it is not a right way to do it. So how should I do it?
I know I need to use wrapper. But how do I sent data stored in list of robots in C++ project in processing thread to C# project? (where robot includes cv::Point2i position and cv::Point2i rotation and some other not important inner class) I tried to "pseudoserialize" values into string, send it to C#, and then "deserialize" it to prepared object. But it seems somehow wrong. Is there simple way to do what I need?
Thank you
If you want to run it as a stand-alone process, C# provides facilities for doing so.
If you want to call individual functions of your C++ code from C#, look into P/Invoke
We have a sharepoint doucment library, the site consist media files(like images, word document, .psd file) and then we have a local CME (Alterian) which can be integrated to the SharePoint library in order to share the document library but the site needs to be on http// not an https//, coincidentally current sharepoint site is on https//, so we need to figure out a way/write a module which will work as a scheduled job (possibly using SPJobDefination class) and check on https// site for recently modified/added or deleted documents/records and then will copy them/normalize them to a dev site (hosted on http//, replica of the production https// site).
Experts please share your view's to proceed with a best approach to make this happen. (At an initial stage I'll have to copy over all the existing meta-data from the current https// site aswell)
Thanks a lot in advance for the time.
I would use event handlers on the https document library. Please see the SPItemEventReceiver.ItemAdded Method and SPItemEventReceiver.ItemUpdated Method.
So, every time you will add or modify an item, the code inside the methods is triggered. Inside the code, you may take the library document and copy it to the http site.
Regarding the existing items, you could write a simple console application which will copy the items from one list to the other.
Make sure that you make use of the SPListItem.SystemUpdate Method.
Also, the following excerpt from an answer to the question Moving Documents from library to library deletes version history, how do you retain it? could be helpful for starting:
(...) We can get the “SPFile” and the “SPFileVersion” objects from the
original library and add them to another library one by one. After
copying a file or version, get the original custom property form the
source file or version and use the “SPListItem.SystemUpdate(false)”
method to update the target file or version. This workaround can
persist most of the properties except the “modified time” or “modified
by” field. (...)