I wanted to use Plugin Registration Tool (from now on referenced as PRT) to debug custom workflow activity with CRM 2016 online. My problem is that whenever I click on "Profile Workflow" button, PRT crashes.
Details on crash are found in event log and are stated below.
Event log entry one:
Faulting application name: PluginRegistration.exe, version: 8.2.1.8676, time stamp: 0x58d073d5
Faulting module name: KERNELBASE.dll, version: 10.0.15063.296, time stamp: 0xa0527b0c
Exception code: 0xe0434352
Fault offset: 0x0000000000069e08
Faulting process id: 0xb70
Faulting application start time: 0x01d2ea6794b7727a
Faulting application path: D:_temp\SDK\Tools\PluginRegistration\PluginRegistration.exe
Faulting module path: C:\WINDOWS\System32\KERNELBASE.dll
Report Id: 21f5bf85-22be-44ca-b884-ef43d9490886
Faulting package full name:
Faulting package-relative application ID:
Event log entry two:
Application: PluginRegistration.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Xml.XPath.XPathException
at MS.Internal.Xml.XPath.XPathParser.CheckToken(LexKind)
at MS.Internal.Xml.XPath.XPathParser.ParsePredicate(MS.Internal.Xml.XPath.AstNode)
at MS.Internal.Xml.XPath.XPathParser.ParseStep(MS.Internal.Xml.XPath.AstNode)
at MS.Internal.Xml.XPath.XPathParser.ParseRelativeLocationPath(MS.Internal.Xml.XPath.AstNode)
at MS.Internal.Xml.XPath.XPathParser.ParsePathExpr(MS.Internal.Xml.XPath.AstNode)
at MS.Internal.Xml.XPath.XPathParser.ParseUnionExpr(MS.Internal.Xml.XPath.AstNode)
at MS.Internal.Xml.XPath.XPathParser.ParseMultiplicativeExpr(MS.Internal.Xml.XPath.AstNode)
at MS.Internal.Xml.XPath.XPathParser.ParseAdditiveExpr(MS.Internal.Xml.XPath.AstNode)
at MS.Internal.Xml.XPath.XPathParser.ParseRelationalExpr(MS.Internal.Xml.XPath.AstNode)
at MS.Internal.Xml.XPath.XPathParser.ParseEqualityExpr(MS.Internal.Xml.XPath.AstNode)
at MS.Internal.Xml.XPath.XPathParser.ParseAndExpr(MS.Internal.Xml.XPath.AstNode)
at MS.Internal.Xml.XPath.XPathParser.ParseOrExpr(MS.Internal.Xml.XPath.AstNode)
at MS.Internal.Xml.XPath.XPathParser.ParseExpresion(MS.Internal.Xml.XPath.AstNode)
at MS.Internal.Xml.XPath.XPathParser.ParseXPathExpresion(System.String)
at System.Xml.XPath.XPathExpression.Compile(System.String, System.Xml.IXmlNamespaceResolver)
at System.Xml.XPath.XPathNavigator.Compile(System.String)
at System.Xml.XmlNode.SelectSingleNode(System.String, System.Xml.XmlNamespaceManager)
at PluginProfiler.Library.WorkflowXamlUtility.GetCustomActivityFullyQualifiedName(System.String, System.Xml.XmlNode, System.Xml.XmlNamespaceManager)
at PluginProfiler.Library.WorkflowXamlUtility.GetCustomActivityFullyQualifiedNames(Microsoft.Xrm.Tooling.Connector.CrmServiceClient, System.Xml.XmlDocument, System.Xml.XmlNamespaceManager)
at PluginProfiler.Library.WorkflowXamlUtility.GetWorkflowActivitySteps(Microsoft.Xrm.Tooling.Connector.CrmServiceClient, System.String)
at Microsoft.Crm.Tools.PluginRegistration.CommonControls.ExistingWorkflow.Refresh()
at Microsoft.Crm.Tools.PluginRegistration.CommonControls.ProfilerSettingsViewModel.set_SelectedWorkFlow(Microsoft.Crm.Tools.PluginRegistration.CommonControls.ExistingWorkflow)
at Microsoft.Crm.Tools.PluginRegistration.CommonControls.ProfilerSettingsViewModel.RefreshWorkflows()
at Microsoft.Crm.Tools.PluginRegistration.CommonControls.ProfilerSettingsViewModel..ctor(Microsoft.Crm.Tools.Libraries.CrmOrganization, PluginProfiler.OperationType, System.Guid, Microsoft.Crm.Tools.PluginRegistration.CommonControls.ProfilerSettingsView)
at Microsoft.Crm.Tools.PluginRegistration.OrganizationControlViewModel.StartProfiler_Clicked()
at Microsoft.Crm.Tools.PluginRegistration.OrganizationControlViewModel.MenuItem_Clicked(System.Object)
at MS.Internal.Commands.CommandHelpers.CriticalExecuteCommandSource(System.Windows.Input.ICommandSource, Boolean)
at System.Windows.Controls.MenuItem.InvokeClickAfterRender(System.Object)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
at System.Windows.Threading.DispatcherOperation.InvokeImpl()
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at MS.Internal.CulturePreservingExecutionContext.Run(MS.Internal.CulturePreservingExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Windows.Threading.DispatcherOperation.Invoke()
at System.Windows.Threading.Dispatcher.ProcessQueue()
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef)
at System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame)
at System.Windows.Application.RunDispatcher(System.Object)
at System.Windows.Application.RunInternal(System.Windows.Window)
at Microsoft.Crm.Tools.PluginRegistration.App.Main()
Both event log entries are created at same time when plugin crashed.
I've spent last our googling, trying to find someone with at least similar problem, but I failed :)
Is there any solution for this?
I've seen behavior like this before with plugins and custom workflow activities depending on the actions taken within the code. For example, if my plugin does an http request I've seen that crash the PRT, I don't know for sure but it may be that the PRT doesn't allow that type of thing if it's debugging in a sandboxed environment.
An alternative to directly debugging the custom workflow activity or plugin is to create a new custom entity with some fields to store information such as the user id the code is running as, the name of the plugin or workflow activity, exception message, etc. and then in the code write to a StringBuilder object in the same way you might write useful information out to the tracing object. In a catch block or always at the end of the code you can create a new record of the custom entity and store the information from the StringBuilder and plugin context, etc. I've used this in a lot of situations where I want to output custom detailed info for debugging or testing as long as the plugin doesn't need to throw an exception which will roll back the transaction. It may seem tedious to add the extra code to output what you want but if debugging isn't an option this will work.
Example code to illustrate what I mean...
Dim tracer As New StringBuilder
Try
tracer.Append("running code ...")
'// do some code here
tracer.AppendLine("done")
tracer.Append("running more code ...")
'// do some code here
tracer.AppendLine("done")
'// Write out some info useful for debugging
tracer.AppendLine(String.Format("value of variable 1 {0}", SomeVariable1))
Catch ex As Exception
tracer.AppendLine(ex.ToString)
End Try
'// Create a new instance of the new custom error entity and save it
'// Where CustomError is the name of your new entity, assuming you're using strongly-typed entity classes
Dim ErrorObj As New CustomError With {
.UserName = "",
.Message = tracer.ToString
}
pluginOrgService.Create(ErrorObj)
I've contacted MS support, exchanged emails with them for couple od days, even had a remote session with their support, then waited couple more days for their support to analyze problem, never got any solution from MS support, and at the end I overcome this by my own.
Problem here is with tool as I wanted to report to MS, but for some reason they are convinced that problem is with my custom code. I managed to narrow down this to one specific custom workflow that I made, lets call it Workflow_A. When plugin registration tool (PRT) try to get list of workflows from CRM (I used Fiddler, there is no order by in that request), Workflow_A was first in that list, PRT could not parse it and crashed. I then, deleted that workflow and recreated it again (same steps and conditions) and voila, it ended as last in workflows list and PRT stop crashing.
AK3800 stated
if my plugin does an http request I've seen that crash the PRT, I don't know for sure but it may be that the PRT doesn't allow that type of thing if it's debugging in a sandboxed environment.
I had to agree with him - PRT is making more problems then it solves (with debugging) so at the end I ended up filling my code with trace logs everywhere and no debugging, just making code changes based on trace logs.
I'd open a support ticket with MS. They offer support for the SDK tools as well.
Related
I had a pyGObject app and I run that. all things work fine until on a button clicked signal I need to run a def. it has a long loop and I run that with the
def on_launch_btn_clicked(self,button):
_thread.start_new_thread(launch,["thread"])
def launch(thread):
lines_list = open("../line.txt").split()
for line in lines_list:
select = machinestate.objects.get(id=1)
if not select.pause:
#my process
else:
def pause_lcd()
return "pause" #it for come out of def and close thread but I don't know it close that or not
this loop is in another .py file
function it works like a charm, next I had a pause button it changes database pause field to True and my loop every iteration check database to saw what is changed. when it saw pause is True it run
def pause_lcd():
app = app_list[0]
app.pause_action()
I run Gtk app in this def
app_list = list()
def main(thread):
app = GUI()
app_list.append(app)
Gdk.threads_init()
Gtk.main()
in my GUI class I have pause_action method
def pause_action(self):
self.pause_btn.set_sensitive(True)
self.pause_btn.hide()
self.resume_btn.show()
when I clicked on pause button some time I got this error
[xcb] Unknown sequence number while processing queen
[xcb] Most likely this is a mulity-threaded client and XinitThreads has not been called
[xcb] Aborting, sorry about that
pyhton: ../../src/xcb_io.c:263 poll_for_event: Assertion '!xcb_xlib_threads_sequence_lost failed.
I had a bunch of thread side this threads like machine info, clock, machine temp and ...
what I do wrongs??
PS: this app run in a Django project and I use Django model in this it is an app of Django but it runs a Gtk app
I suspect that something with the XCB or the X11 server is wrong (bug). I received the same error message from different applications on a specific X server (using X11 over ssh).
Error message with emacs:
[xcb] Unknown sequence number while processing queue
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
emacs: xcb_io.c:263: poll_for_event: Assertion `!xcb_xlib_threads_sequence_lost' failed.
Error message with eclipse:
[xcb] Unknown sequence number while processing queue
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
java: xcb_io.c:263: poll_for_event: Assertion `!xcb_xlib_threads_sequence_lost' failed.
As of Build 8201.2025 there has been an unexpected change to the order of events when loading a VSTO addin with a Ribbon in Word.
Using Office version 16.0.8067.2115 or older. When loading the addin the following order of events is observed (as has always been the case).
Ribbon_Load event
ThisAddin_Startup event
Using Office versions 8201.2025, 8201.2064 or 8201.2075 or newer the order of events is reversed which is an unexpected breaking change.
ThisAddin_Startup event
Ribbon_Load event
I have created a simple VSTO Addin using a Visual Designer Ribbon to demonstrate the issue.
>
Public Class Ribbon1
Private Sub Ribbon1_Load(ByVal sender As System.Object, ByVal e As RibbonUIEventArgs) Handles MyBase.Load
System.Diagnostics.Debug.Write("Ribbon1_Load event called.")
'Pass the Ribbon to the Addin.
ThisAddIn.MyRibbon = Me
End Sub
End Class
Public Class ThisAddIn
Public Shared Property MyRibbon As Ribbon1 = Nothing
Private Sub ThisAddIn_Startup() Handles Me.Startup
Debug.Write("ThisAddin_Startup Called")
If (MyRibbon Is Nothing) Then
Debug.Write("MyRibbon is nothing - the ribbon was not captured.")
Else
Debug.Write("Ribbon captured successfully.")
End If
End Sub
End Class
Debug output for 16.0.8067.2115 32 bit
[7772] Ribbon1_Load event called.
[7772] ThisAddin_Startup Called
[7772] Ribbon captured successfully.
Debug output for 16.0.8201.2075 32 bit
[13556] ThisAddin_Startup Called
[13556] MyRibbon is nothing - the ribbon was not captured.
[13556] Ribbon1_Load event called
I have posted this up on the Microsoft Support forums however they have stopped responding and since released this version to the Current office channel I need help from the dev community.
Has anyone found a successful workaround? This change of timing is causing alot of problems with how we initialise. It would be ideal for Microsoft Support to provide a solution or workaround until they investigate this bug.
I always got Ribbon_Load before ThisAddin_Startup because I use Ribbon XML. Ribbon UI allow less controls ... As the both are "entry" points, I suggest you to use only Ribbon1_Load at startup. Or, if you use the Ribbon XML model and you want the very very first entry point, try its constructor
I am not feeling that issue as a bug, to make Word fast many processes are asynchronous. So, in my opinion, the first of ThisAddin_Startup or Ribbon1_Load to start can accidentally change depending on many factors: System performances, Word started alone, Word started via a doc ...
Hope this helps someone! We used the following workaround successfully to work around the changed office load behavior.
Within ThisAddIn_Startup loop until the Ribbon load event has fired and the ribbon is captured.
While m_oRibbon Is Nothing
If (timeWaited >= MAX_WAIT_TIME) Then
Exit Try
End If
Threading.Thread.Sleep(50)
timeWaited = timeWaited + 50
End While
In Tibco, sometimes warnings are printed to the console, e.g.:
2014-06-25 18:13:22 RV: TIB/Rendezvous Error Not Handled by Process:
{ADV_CLASS="WARN" ADV_SOURCE="RVCM"
ADV_NAME="REGISTRATION.NOT_CERTIFIED.cm.test.subject"
subject="cm.test.subject" sender="cm.sender.cmname"}
I am using the .NET wrappers for Tibco. It appears as if these errors are not actually making it into the .NET, and they can't be caught with try/catch so they can be handled appropriately.
Is there any way to handle this error in .NET? Perhaps some method of registering a handler to handle errors such as this? Or alternatively, is there a method to redirect these warnings into a sink other than the console, e.g. a log file?
The solution is to add a "catch all" handler.
The current subject that I was listening to was:
private readonly string _subjectDeliveryConfirm = "_RV.INFO.RVCM.DELIVERY.CONFIRM.>";
To add a catch all, add another listener on:
private readonly string _subjectDeliveryGlobal = ">";
When you add a new listener, remember to use a separate Listener concrete class per listener, or else Tibco will mysteriously stop working after the first message (see the demo code for how to create multiple listeners).
_confirmListener1 = new Listener(Queue.Default, _netTransport, _subjectDeliveryConfirm, null);
_confirmListener1.MessageReceived += new MessageReceivedEventHandler(OnCertifiedMessageConfirmed);
// Subscribe to error messages, in particular error messages related to remote listener processes
// disappearing.
_confirmListener2 = new Listener(Queue.Default, _netTransport, _subjectDeliveryGlobal, null);
_confirmListener2.MessageReceived += new MessageReceivedEventHandler(OnTibcoCatchAll);
There is lots of sample C# code in the \src\ directory for the Tibco install that illustrates the techniques shown above.
I am using basic4android and I made an application that uses httputils services. Sometimes a remote error occurs (possible server overload or limited internet connection) and the application exits with the error message box. The activity closes but httputils service is still running. While I reopen the activity new error occurs, because of the unfinished job of httputils. Everything is OK only if I choose to stop the activity in the second error.
Is there any way to determine if the httputils service is running by a previous instance of my app? Or better, a way to try to stop this service either its running or not.
HttpUtils errors should not cause your program to exit. You should check IsSuccess to make sure that the call succeeded or not.
You can stop the service from running by calling StopService(HttpUtilsService).
Public Sub StationTransfer_Click
Dim job As HttpJob
job.Initialize("MyJob", Me)
Dim URL As String="https://www.yourserver.com/myjob.asmx/GetData?parameter1=abc"
job.Download(URL)
ProgressDialogShow2("Getting data From Server...", True)
End Sub
Sub JobDone(Job As HttpJob)
Select Job.JobName
Case "MyJob"
HandleMyJob(Job)
End Select
Job.Release
End Sub
Sub HandleMyJob(Job As HttpJob)
If Job.Success = False Then
ToastMessageShow("Error downloading Data", True)
ProgressDialogHide
Return
End If
....
end Sub
if there is an httpjob error you catch it in the handler function by looking at the status. if the status is not success than you catch it and display a message.
I'm writing an application that can be started either as a standard WinForms app or in unattended mode from the command-line. The application was built using the VS 2k5 standard WinForms template.
When the application is executed from the command-line, I want it to output information that can be captured by the script executing the application. When I do this directly from Console.WriteLine(), the output does not appear, although it can be captured by piping to a file.
On the other hand, I can force the application to pop up a second console by doing a P/Invoke on AllocConsole() from kernel32. This is not what I want, though. I want the output to appear in the same window the application was called from.
This is the salient code that allows me to pop up a console from the command line:
<STAThread()> Public Shared Sub Main()
If My.Application.CommandLineArgs.Count = 0 Then
Dim frm As New ISECMMParamUtilForm()
frm.ShowDialog()
Else
Try
ConsoleControl.AllocConsole()
Dim exMan As New UnattendedExecutionManager(ConvertArgs())
IsInConsoleMode = True
OutputMessage("Application started.")
If Not exMan.SetSettings() Then
OutputMessage("Execution failed.")
End If
Catch ex As Exception
Console.WriteLine(ex.ToString())
Finally
ConsoleControl.FreeConsole()
End Try
End If
End Sub
Public Shared Sub OutputMessage(ByVal msg As String, Optional ByVal isError As Boolean = False)
Trace.WriteLine(msg)
If IsInConsoleMode Then
Console.WriteLine(msg)
End If
If isError Then
EventLog.WriteEntry("ISE CMM Param Util", msg, EventLogEntryType.Error)
Else
EventLog.WriteEntry("ISE CMM Param Util", msg, EventLogEntryType.Information)
End If
End Sub
Raymond Chen recently posted (a month after the question was posted here on SO) a short article about this:
How do I write a program that can be run either as a console or a GUI application?
You can't, but you can try to fake it.
Each PE application contains a field
in its header that specifies which
subsystem it was designed to run
under. You can say
IMAGE_SUBSYSTEM_WINDOWS_GUI to mark
yourself as a Windows GUI application,
or you can say
IMAGE_SUBSYSTEM_WINDOWS_CUI to say
that you are a console application. If
you are GUI application, then the
program will run without a console.
The subsystem determines how the
kernel prepares the execution
environment for the program. If the
program is marked as running in the
console subsystem, then the kernel
will connect the program's console to
the console of its parent, creating a
new console if the parent doesn't have
a console. (This is an incomplete
description, but the details aren't
relevant to the discussion.) On the
other hand, if the program is marked
as running as a GUI application, then
the kernel will run the program
without any console at all.
In that article he points to another by Junfeng Zhang that discusses how a couple of programs (Visual Studio and ildasm) implement this behavior:
How to make an application as both GUI and Console application?
In VisualStudio case, there are actually two binaries: devenv.com and devenv.exe. Devenv.com is a Console app. Devenv.exe is a GUI app. When you type devenv, because of the Win32 probing rule, devenv.com is executed. If there is no input, devenv.com launches devenv.exe, and exits itself. If there are inputs, devenv.com handles them as normal Console app.
In ildasm case, there is only one binary: ildasm.exe. It is first compiled as a GUI application. Later editbin.exe is used to mark it as console subsystem. In its main method it determines if it needs to be run as console mode or GUI mode. If need to run as GUI mode, it relaunches itself as a GUI app.
In the comments to Raymond Chen's article, laonianren has this to add to Junfeng Zhang's brief description of how Visual Studio works:
devenv.com is a general purpose console-mode stub application. When it runs it creates three pipes to redirect the console's stdin, stdout and stderr. It then finds its own name (usually devenv.com), replaces the ".com" with ".exe" and launches the new app (i.e. devenv.exe) using the read end of the stdin pipe and the write ends of the stdout and stderr pipes as the standard handles. Then it just sits and waits for devenv.exe to exit and copies data between the console and the pipes.
Thus even though devenv.exe is a gui app it can read and write the "parent" console using its standard handles.
And you could use devenv.com yourself for myapp.exe by renaming it to myapp.com. But you can't in practise because it belongs to MS.
Update 1:
As said in Michael Burr answer, Raymond Chen recently posted a short article about this. I am happy to see that my guess was not totally wrong.
Update 0:
Disclaimer: This "answer" is mostly speculation. I post it only because enough time has passed to establish that not many people have the answer to what look like a fundamental question.
I think that the "decision" if the application is gui or console is made at compile time and not at runtime. So if you compile your application as gui application, even if you don't display the gui, its still a gui application and doesn't have console. If you choose to compile it as console application then at minimum you will have a console windows flashing before moving to gui "mode". And I don't know if it is possible in managed code.
The problem is fundamental, I think, Because a console application has to take "control" of the calling console application. And it has to do so before the code of the child application is running.
If you want to check if your app is started from the command line in .NET, you can use Console.GetCursorPosition().
The reason that this works is that when you start it from the command line, the cursor moves away from the initial point ((0, 0)) because you typed something in the terminal (the name of the app).
You can do this with an equality check (code in C#):
class Program
{
public static void Main
{
if (Console.GetCursorPosition() == (0, 0))
{
//something GUI
}
else
{
//something not GUI
}
}
}
Note: You must set the output type to Console Application as other output types will make Console.GetCursorPosition() throw an exception.