I'm new to the SAP Gui API; but I manage to create a simple program (with C#) to automate data entry into SAP with reference from how-do-i-automate-sap-gui-with-c-sharp.
For the past few days I have tried to enhance the program by putting in error handling mechanism so that the program will able to show friendly message, if connection time or invalid logon info provided during logon. Catch all system/error messages from SAP and display them in my program.
However I have tried many ways to catch the error message via GuiSession.ErrorList and GuiSession.Error but it is not working - either return null or the program failed to compile.
Any help/advice on this will be appreciated. Thanks.
Related
I stumbled upon MantisBT recently and got it set up at my workplace for future bug tracking. I wanted to make a neat little library we can use in our applications so that users can report bugs to us directly from the application in question.
Currently in a sandbox application I made to try and understand MantisConnect. I consumed the webservice successfully and I can make a client. But if I try and do this:
MantisConnectPortTypeClient client = new MantisConnectPortTypeClient();
UserData usrData = client.mc_login("omitted", "omitted");
I get a FaultException and the message "Access Denied"
Currently running Mantis 1.3.rc-dev.02
Any ideas on why this simple call is denied? It doesn't matter what user I use. It gets denied regardless.
Okay I figured it out.
The WSDL file on the server was still pointing to mantisbt.org instead of our local server. Changed it to our local server address and it worked fine.
I have a situation,I have an application which sends mail using OUTLOOK,problem is while I'm trying to send mails from the application which is opened as Administrator it throws exception
Retrieving the COM class factory for component with CLSID
{0006F03A-0000-0000-C000-000000000046} failed due to the following
error: 80080005 Server execution failed (Exception from HRESULT:
0x80080005 (CO_E_SERVER_EXEC_FAILURE)).
Is there any way to solve it programmatically?
You could call Process.GetProcessesByName() passing in OUTLOOK or whatever the actual process name is.
This gets you an array of process. You can then iterate through each of these and check the user that started the process. If the user isn't the ones you want you can call Process.Kill() and terminate the process.
Getting the user might be tricky, you can use WMI for this (you could also use WMI to list the processes).
Check this answer here for getting the user name.
However I would rethink how you send your mail. The last thing I'd want as a user is watching my Outlook disappear because your application is trying to send an e-mail.
Perhaps a little late to the party on this one but there are two possible approaches here.
As highlighted by Lloyd, you can attempt to connect to an existing Outlook process for the 'current' user (if one exists) by calling
Process.GetProcessByName("OUTLOOK");
This gets an array of Outlook processes and you can iterate through these until the instance you're looking for.
Alternatively, (or if no process is found), you can initialize a new instance of the Outlook application, connect to the default MAPI namespace and send your email that way. Presumably you're using objects defined in the Microsoft.Office.Interop.Outlook library?
You may need to call the Logon/Logoff routines against the namespace and proceed that way, remembering to correctly dispose of any new instances after use, even acquiring the process ID of the new app instance and calling .Kill on that.
I have a console application written in C#. This application runs as automation to test a web service.
Flow:
Log in to network share (impersonate user)
copy mp3 file to local disc
convert mp3 to wav
downsample
trim wave
extract some useful data from wav
send http request
delete local files
write out some stuff to tsv
The application will run great for several hours (usually takes about 24 hours to complete the test). but every once and a while I will get this message: "The application has stopped working. I have been running this is VS 2012 in debug mode so, I can see what line throws any error. problem is, that I have not been able to catch the line (or method) that is throwing the error. I originally thought that the Domain controller was causing this issue due to power settings.
How can I capture exactly what error is bubbling its way up the stack?
Does all that run in a loop of some kind? Or on a timer?
Perhaps put a try-catch around the body of the loop or the method that runs all your code, add a logging framework of your choice (log4net or nlog seem good) and then in the catch log the exception. Most logging frameworks allow you to include the exception and will include stacktrace, etc.
Putting debug logging throughout the process can also help to narrow down where it's happening.
You can go to the Event Viewer on the operating system the console application is running on and then click on "Application". Event viewer logs and displays all exceptions thrown on any application running on the operating system.
try
{
// your code
}
catch (Exception e)
{
System.IO.File.WriteAllText(#"Z:\err.txt", e.ToString());
}
Note that access to windows drives are denied for non administrators so replace Z: with your choice.
I recommend you using a logging framework.
I use log4net in almost all applications. Its very simple to use and configure.
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
try
{
// do whatever
}
catch(Exception ex)
{
// Log an error with an exception
log.Error("Exception thrown", ex);
}
By using these kind of libraries you can get your log data output to file, database or even written to the windows event-viewer for instance.
It looks like the exception code you are getting happens when you try to use something that is already been garbage collected. Are you using anything after it is disposed?
Knowledge Base Article for 0xc0000005
I'm trying to move my APN backoffice from PHP to C# for performance issue. Bear with me, I'm new to C# and mono.
I've just downloaded MonoDevelop 2.8.6.4 and APNS-sharp merge 26 on my OSX 10.7.2
I opened the entire solution with all libraries and test executables and built the entire solution without errors. I modified the fields (token id, cert file, ...) in the Program.cs in JdSoft.Apple.Apns.Notifications.Test to meet my specs.
After a few tries I managed to get my certificate file OK and the connection to Apple servers is now up. I see the message saying I'm connected in the output of the application.
Probleme comes now. Everytime the application tries to send a message to Apple I get the error "A Type load exception has occured". I tried a little debug and the error seems to come from the NotificationPayload constructor.
Doing step by step follow up, it appears the NotificationAlert is correctly instantiated inside the NotificationPayload constructor. The error appears when coming back to the Notification constructor where the Payload member appears in the debugger as "A type load exception has occurred." instead of an object.
From there the Notification object ends up with the same behavior.
From my research on the Internet this could come from the version of Newtonsoft.Json.Compact.dll but I have no idea what to do with this piece of information.
For information I can see the same error when running the compiled test on my CentOS server.
And for more information the application message (changed ex.Message to ex.ToString() in the test program to get a full error) :
Notification Queued!
Sleeping 15000 milliseconds before next Notification...
Connecting...
Connected...
Error: System.TypeLoadException: A type load exception has occurred.
at JdSoft.Apple.Apns.Notifications.Notification.ToBytes () [0x0006c] in /Users/laurent/Downloads/Redth-APNS-Sharp-595275f 2/JdSoft.Apple.Apns.Notifications/Notification.cs:90
at JdSoft.Apple.Apns.Notifications.NotificationChannel.Send (JdSoft.Apple.Apns.Notifications.Notification notification) [0x00000] in /Users/laurent/Downloads/Redth-APNS-Sharp-595275f 2/JdSoft.Apple.Apns.Notifications/NotificationChannel.cs:371
at JdSoft.Apple.Apns.Notifications.NotificationConnection.workerMethod () [0x00035] in /Users/laurent/Downloads/Redth-APNS-Sharp-595275f 2/JdSoft.Apple.Apns.Notifications/NotificationConnection.cs:381
I didn't put the code, as I didn't change anything from the one you can see at https://github.com/Redth/APNS-Sharp.
I send an SOS to all mono guru around.
Have a nice day fellow developers and thanks in advance for your help and time. Any suggestion is gladly welcome.
(As the OP can't post the answer himself...)
In this particular case, the solution was to fetch the latest version of Newtonsoft.Json.Compact.dll.
In general, you need to try to get as much information from the exception as possible, to find out what it was trying to load - then check that the problematic library is present, and that you've got the version everything else expects.
We're using Exchange 2007 WS to process mail folders and are hitting various problems if we try and forward a message we've already received. Our process is:
Windows Service monitors mailbox folder, on finding a new mail we process the information and move the item to a 'Processed folder' and store the Exchange Message Id.
Users may opt to forward the mail externally. We use the Exchange API to find the item using the Message Id we stored earlier, and then again use the API to forward.
Except finding the mail again is proving rather flaky. We regularly get the following error:
The specified object was not found in the store.
Is there a better/more reliable way we can achieve the same? The documentation for Exchange WS is rather sparse.
This is a bug in microsoft exchange manage API. here is a link for more information
http://maheshde.blogspot.com/2010/09/exchange-web-service-specified-object.html
Are you saving the Message ID of the newly found message or the message once it has been moved to the 'Processed' folder? The id will change when it moves to a new folder.
The method recommended in the book Inside Microsoft Exchange Server 2007 Web Services is to grab the PR_SEARCH_KEY (0x300B, Binary) of the newly discovered item, then move it to the 'Processed' folder. You can then search for it in the new folder based on the PR_SEARCH_KEY and get it's new Message id to forward it.
I have come to the conclusion that this happens to me is because while my app is processing the emails, someone else is fiddling with an email at the same time.
So to cure the problem, I put it the code in a try catch and see if the exception is == the that object not found in store, if so I just skip it and move on to the next item. So for has no issues.
I wrote a program that reads the emails in inbox downloads attachments to the specified folder, wrote the email info and the saved path to the database, and finally deletes the email. I run this program as a windows service. After all tests are finished I run this program to the main server and run it. Program runs successfully but sometimes I got this error. I checked everything and finally I found that I forgot to stop service on my computer. 2 programs that runs on my computer and on real server checking the same mailbox at the same time. If you get this error make sure that only one program can process at the same mailbox.