Calling Communicator.UIAutomation from Silverlight 4 - silverlight

I'm trying to instantiate a COM connection to Communicator 2007 from an Out of Browser Silverlight 4 app. I'm following some sample code - one (slightly different) example of which is here - but I'm getting an error when I run the following line:
dynamic communicator = AutomationFactory.CreateObject("Communicator.UIAutomation");
The error is:
Failed to create an object instance for the specified ProgID.
I've downloaded and installed what I believe is the right SDK, but OLEView isn't showing the DLL's as registered - is there something I need to do to register the DLL's in the SDK? regsvr32 doesn't seem to work.
Am I going about this all wrong? Is there a better option, perhaps with the Unified Communications Client (1.0 or 2.0) SDK?

Is Communicator running at the time? It must be running in order to use the API.
The above code works fine for me, when communicator is running, but I can replicate your error by ensuring that it isn't running when the above line gets hit.
I'm pretty sure the SDK is registered OK, as you'g get a slightly different error if it wasn't:
No object was found registered for specified ProgID.
With regards to the right SDK - it depends on what you're trying to achieve. The automation API (i.e. the one you're using) will allow you to automate the running instance of Communicator, so its great for e.g. obtaining presence info, starting IM conversations, placing phone calls etc uning the Communicator UI. You should only need to look at UCCA if its not guaranteed that Communicator will be running, or if you need to e.g. provide your own UI.
I blogged about the various APIs here
One more thing to bear in mind, if upgrading to Lync is an option, then the SDK has a whole bunch of really useful Silverlight/WPF controls built in - some info here

Related

WPF application crashes when run in Jenkins service but not as a regular user

I am automating some software testing using Jenkins on our in-house test software. It is written in C# with WPF. I am using the version of the program that has no frontend, but it still makes calls to WPF in order to start the service. The test application is launched through python scripts using subprocess.Popen
When running under the Jenkins slave process I get the following error:
Unhandled Exception: System.ComponentModel.Win32Exception: The operation completed successfully
at MS.Win32.UnsafeNativeMethods.RegisterClassEx(WNDCLASSEX_D wc_d)
...
From my research it seems that something is going wrong with the windows atom tables. The weird thing is that I don't run into the same issue when running the python scripts as a local user, it only crashes when it is the Jenkins service running the scripts.
Is there some limitation on the local atom table for windows services?
Is Jenkins hogging atom table entries?
Update 1:
I did some more research on the crash and some resources said for WPF there might be a windows handle leak, so I inserted some power shell calls to check how many active handles there are on the system.
It doesn't look like there is a handle leak from any of the software under test, I am seeing around 50-60k handles while jenkins is running the test scripts, which is consistent with what I was seeing while running it under my user account. It looks like Jenkins is interfering with WPF's ability to construct the program (The full callstack for the error is on the Main() constructor), but I have no idea why it would be doing that.
Update 2:
Some extra information since I think it is relevant, here is the full call stack:
Unhandled Exception: System.ComponentModel.Win32Exception: The operation completed successfully
at MS.Win32.UnsafeNativeMethods.RegisterClassEx(WNDCLASSEX_D wc_d)
at MS.Win32.HwndWrapper..ctor(Int32 classStyle, Int32 style, Int32 exStyle, Int32 x, Int32 y, Int32 width, Int32 height, String name, IntPtr parent, HwndWrapperHook[] hooks)
at System.Windows.Threading.Dispatcher..ctor()
at System.Windows.Threading.Dispatcher.get_CurrentDispatcher()
at System.Windows.Application..ctor()
at <TestingApplication>.ScriptHost.App..ctor()
at <TestingApplication>.ScriptHost.App.Main()
So what appears is happening is the following:
Jenkins calls the python scripts. They perform setup and all pre-condition work such as bringing up the software under test
Python calls the TestingApplication through Popen
The executable starts and attempts to construct the application
WPF checks to see if there is a Dispatcher already on the thread, there is not
WPF attempts to create a Dispatcher since one doesn't already exist
Crash because a Dispatcher cannot be created
Again, this only happens when launched under the Jenkins service user.
So here's what I did to fix the problem:
The software under test also uses WPF to create the displays, so I wanted to see if maybe i'm running out of resources by having too many things open. There are 5 SUT applications. Luckily, one of the pieces of software we run is a console that I don't need open when running tests through Jenkins. Thus I was able to not launch the console application and that freed up enough resources for the test application to run.
What this doesn't answer is:
Why do I have less resources on a service compared to a regular user?
Is this because of Jenkins/Python or because of Windows?
Is there a workaround for this problem?
Those questions could be asked outside of this question so I am answering just so that it is available to someone with a similar problem and to close it. For someone who doesn't have the luxury of closing extra applications, I would ask those questions yourself.

Azure Kinect: how to find the windows device id

I have been developing a Win application that uses 3 Azure Kinects. Since there is no C# wrapper available yet, I made a C++ app that does what I need and the C# app just grabs its output files.
I now need to figure out which camera is which. In the C# app I can get the windows device id in a form similar to
\\.\USB#VID_045E&PID_097C#001007692912#{A5DCBF10-6530-11D2-901F-00C04FB951ED}
However the C API for the Kinect only provides ways to get the serial number of the device.
I tried to dig into the API, since I'm sure it must be somewhere in the code but, due to my limited C skills, I got lost pretty quickly.
Anybody with the same issue or can help?
Thanks,
Guido
The SDK is designed to use serial number specifically to determine which device or devices you are connected to. If you are just trying to use 2 Kinects with 2 instances of your C# then you will need to open devices until you find the serial number you are looking for. If you are trying to use multiple devices in a master/subordinate configuration then you can query for jack state to determine if you have connected to one or the other.
Also please be aware that we just released our own C# wrapper for the SDK. Checkout https://github.com/microsoft/Azure-Kinect-Sensor-SDK/issues/608 and https://microsoft.github.io/Azure-Kinect-Sensor-SDK/master/namespace_microsoft_1_1_azure_1_1_kinect_1_1_sensor.html for more details.

Codenamone One Online Build Failure

We added new features to our data collection mobile application after two -three months of inactivity, only for the build to keep failing.
This is the stack trace
ll-advised or mistaken usage of a core class (java.* or javax.*)
when not building a core library.
This is often due to inadvertently including a core library file
in your application's project, when using an IDE (such as
Eclipse). If you are sure you're not intentionally defining a
core class, then this is the most likely explanation of what's
going on.
However, you might actually be trying to define a class in a core
namespace, the source of which you may have taken, for example,
from a non-Android virtual machine project. This will most
assuredly not work. At a minimum, it jeopardizes the
compatibility of your app with future versions of the platform.
It is also often of questionable legality.
If you really intend to build a core library -- which is only
appropriate as part of creating a full virtual machine
distribution, as opposed to compiling an application -- then use
the "--core-library" option to suppress this error message.
If you go ahead and use "--core-library" but are in fact
building an application, then be forewarned that your application
will still fail to build or run, at some point. Please be
prepared for angry customers who find, for example, that your
application ceases to function once they upgrade their operating
system. You will be to blame for this problem.
If you are legitimately using some code that happens to be in a
core package, then the easiest safe alternative you have is to
repackage that code. That is, move the classes in question into
your own package namespace. This means that they will never be in
conflict with core system classes. JarJar is a tool that may help
you in this endeavor. If you find that you cannot do this, then
that is an indication that the path you are on will ultimately
lead to pain, suffering, grief, and lamentation.
1 error; aborting
:transformClassesWithDexForRelease FAILED
:transformClassesWithDexForRelease (Thread[Daemon worker,5,main]) completed. Took 11.045 secs.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':transformClassesWithDexForRelease'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Error while executing java process with main class com.android.dx.command.Main with arguments {--dex --verbose --force-jumbo --num-threads=4 --output /tmp/build8570106392456281219xxx/Application/build/intermediates/transforms/dex/release/0 --min-sdk-version 15 /tmp/build8570106392456281219xxx/Application/build/intermediates/transforms/proguard/release/0.jar}
You or one of the cn1libs you are using included a javax.xml package as part of the code. We migrated to build target 27 over the weekend and I'm guessing that Google made checks for this sort of problem more rigid.
I see a lot of keep statements in your build hints so I'm guessing this was done intentionally.

Parent window not receiving window's messages (Key Events)

I have a GUI application that is written using win API's
and we need to launch a new GUI application when the user selects some command menu items.
We decided to write the new application in PyQt and launch the PyQt application usig Python C Api.
Everything is working fine except that the Parent window, through which we launch the PyQt Application, is not responding to some of the events when PyQt application is open. Once we close the PyQt Application it starts responding again to the key events.
I guess, that once the PyQt Gui application is launched, somehow the messages are not passed to the Parent window.
Inspecting with Spy++ I've found the following result:
Receives messages for:
- ALT key
- F1, F2 keys
- Mouse events
Does NOT receive messages for:
- CTRL key
- All other Fn keys
- All letter keys
- SHIFT, CAPS keys
Any thoughts to solve this problem would be appreciated
I believe what you are trying to do -- operate two separate GUIs within a single process -- is not supported by any major operating system. A while back, I searched for a long time for ways to do this and never came up with any advice except "don't".
I'm surprised that missing keys are the only problem you have.. I recommend finding a different solution before you discover more trouble (unless you can find some good evidence that this is at least supposed to work).
Could you perhaps spawn a new process to run the Qt event loop instead? Since you already have python embedded in the main process, this should be fairly easy--use python's built-in IPC to handle the communication between processes.
One solution is to build the QtWinMigrate module to create a QWinHost which supports parenting to a native HWND but unfortunately it is not part of the PyQt distribution.
You can find some sources here: https://github.com/glennra/PyQtWinMigrate.
This is what had to be done for Python integration in 3ds Max by Blur studio. I am currently studying the C++ source code of QWinWidget too see if I can work out an alternative solution using Win32 calls.

How do you debug Share Picker extensions?

I have registered my Phone 7 app as a Share Picker Extension. It works—my app is in the list of Share options and it gets launched and I can load the chosen image. Okay, great.
But then things go wrong in my code. I would like to be able to debug the issues, but I can't seem to keep the debugger attached.
I cannot debug this in the simulator, since the Pictures app (and thus the Share Picker functionality) is not present in the simulator.
I cannot debug this on the phone because as soon as I pick my app from the Share list, the debugger detaches... right as my app is "launching" again.
Is it possible to attach the debugger to a running WP7 app? Is it possible to keep the debugger attached? Am I doing it wrong? Any suggestions, advice or guesses are welcome because I'm tearing my hair out.
When doing M+V hub integration (sorry, haven't done any pictures hub integration yet) I initially used a crude debug technique (Messagebox.Show, etc. - like Justin mentioned) to verify what was being passed to the NavigationEventArgs of OnNavigatedTo and wrapped the whole method in a try..catch block to learn what was going on. I then refactored the code when I knew what could be expected. (Remember OnNavigatedTo will be called when your app is launched normally too and so e won't be populated in the same way.)
When the app is launched from a/the hub it creates a new instance of the app and there is currently no way to connect to this for debugging while the main page is being navigated to.
Great question. I'm unsure if that's possible. As far as I know, there's no way to attach the debugger to when the WP7 O/S starts an app (which wasn't triggered by the debugger).
Photo Share picker extensibility, music+Video hub extensibility and other O/S extensibility points seem to not play nicely with the VS debugger. Normally I resort to MessageBox.Show to debug any problems with WP7 O/S integration.
1) Connect the Device
2) Turn off Zune
3) Start C:\Program Files\Microsoft SDKs\Windows Phone\v7.1\Tools\WPConnect\x86\WPConnect.exe
To properly debug your application that uses the Media Library, you'll need to use the Windows Phone Connect Tool (WPConnect.exe) as described on MSDN. Jaime has some additional tips on his blog.
Once you are connected, you should be able to debug your application. Fingers crossed anyway. If that doesn't help, I'll dig a bit further.
It's not so much about the WPConnect tool. The nature of your application means that you have to have it closed and the user should pick a photo. Only after that the data is returned to the application.
You should read about the application execution model on Windows Phone 7. Also a good explanation is available here.
Initially, I would say that you should look at tombstoning (a good explanation here) but then again, the image returned will re-start the app and won't allow you to directly attach the debugger.
Yeah, looks like this is impossible...
All the answers above seem to be missing the point: I presume you're able to debug your app in the "standalone" mode (when it's launched normally), but not when it's launched via the Share Picker Extension. Am I write? This is the wall I'm hitting... :-(
I thought the proper way would be to attach to the process once it's launched.
I tried to use Debug > Attach to Process, then select Smart Device as the Transport and Windows Phone Device as the Qualifier... But in return I get the ugly "Unable to connect to 'Windows Phone Device'. Not implemented" message.
Bummer :-(

Resources