I am programatically generating the UI and doing the binding in OnCreateView and there is a noticeable delay before the view renders on screen.
I would like to know if it would be possible to delay the binding so that the controls are rendered first and the binding follows. Please advise suitable function where I can do this.
ORIGINAL CODE:
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
try
{
var fragmentView = base.OnCreateView(inflater, container, savedInstanceState);
var linearLayout = fragmentView.FindViewById<LinearLayout>(Resource.Id.linearLayout1);
BindingContext = new MvxAndroidBindingContext(Activity, new MvxSimpleLayoutInflater(inflater), ViewModel);
using (new MvxBindingContextStackRegistration<IMvxAndroidBindingContext>(
((IMvxAndroidBindingContext)BindingContext)))
{
var set = this.CreateBindingSet<ArticleFragment, ArticleFragmentViewModel>();
// Name field (one of many fields...
set.Bind(InflateEditableText(inflater, linearLayout, "Name"))
.For(v => v.Text)
.To(vm => vm.Item.Name)
.WithConversion("TrimmableString");
InflateAndBindValidationText(inflater, linearLayout, set, "Validator.Messages['Name']");
//
// Other fields follow... same pricinple as Name field
//
set.Apply();
}
return fragmentView;
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
throw;
}
}
I have also refactored the code to do all the bindings in a task, but i'm getting intermittent errors related to some "collection changed" (can't remember the exact error). The idea was to have the layout done by the ui thread and the binding done on a separate thread, and to to task.Wait() before set.Apply(). It works, but intermittently fails.
EDIT: Added trace.
FIRST RUN (2248 ms)
[0:]
mvx:Diagnostic: 16.89 Showing ViewModel ArticleDetailViewModel
[0:] mvx:Diagnostic: 16.89 Showing ViewModel ArticleDetailViewModel
06-04 16:17:35.244 I/mono-stdout(26420): mvx:Diagnostic: 16.89 Showing ViewModel ArticleDetailViewModel
06-04 16:17:35.729 I/Choreographer(26420): Skipped 60 frames! The application may be doing too much work on its main thread.
[0:]
mvx:Diagnostic: 17.70 Attempting to load new ViewModel from Intent with Extras
[0:] mvx:Diagnostic: 17.70 Attempting to load new ViewModel from Intent with Extras
06-04 16:17:36.059 I/mono-stdout(26420): mvx:Diagnostic: 17.70 Attempting to load new ViewModel from Intent with Extras
[0:]
mvx:Diagnostic: 17.72 Adding subscription 0556b442-e560-49d2-934d-74a9e703d43d for ArticleEditDoneMsg
[0:] mvx:Diagnostic: 17.72 Adding subscription 0556b442-e560-49d2-934d-74a9e703d43d for ArticleEditDoneMsg
06-04 16:17:36.069 I/mono-stdout(26420): mvx:Diagnostic: 17.72 Adding subscription 0556b442-e560-49d2-934d-74a9e703d43d for ArticleEditDoneMsg
[0:]
mvx:Diagnostic: 17.73 Nothing registered for messages of type MvxSubscriberChangeMessage
[0:] mvx:Diagnostic: 17.73 Nothing registered for messages of type MvxSubscriberChangeMessage
06-04 16:17:36.094 I/mono-stdout(26420): mvx:Diagnostic: 17.73 Nothing registered for messages of type MvxSubscriberChangeMessage
06-04 16:17:36.249 D/Mono (26420): Remapped public key token of retargetable assembly System from 7cec85d7bea7798e to b77a5c561934e089
06-04 16:17:36.249 D/Mono (26420): The request to load the retargetable assembly System v2.0.5.0 was remapped to System v2.0.0.0
06-04 16:17:36.299 D/Mono (26420): Unloading image System.dll [0x5cfefdc8].
06-04 16:17:36.309 D/Mono (26420): Image addref System[0x5d017280] -> System.dll[0x59d2ab60]: 16
06-04 16:17:36.309 D/Mono (26420): Assembly Ref addref FluentValidation[0x5932fe90] -> System[0x59d2b6e0]: 15
06-04 16:17:36.524 D/Mono (26420): Assembly Ref addref Hlx.Mpos.Core[0x58214730] -> System.Collections[0x58246718]: 5
06-04 16:17:36.614 D/Mono (26420): Assembly Ref addref Hlx.Mpos.Core[0x58214730] -> System.Interactive[0x5935eb78]: 2
06-04 16:17:36.619 D/Mono (26420): Assembly Ref addref System.Interactive[0x5935eb78] -> System.Runtime[0x592cd8d8]: 9
06-04 16:17:36.619 D/Mono (26420): Assembly Ref addref System.Interactive[0x5935eb78] -> System.Resources.ResourceManager[0x592c8c20]: 8
[0:]
mvx:Warning: 18.30 using Inflate with a null parent viewGroup is discouraged - see https://github.com/MvvmCross/MvvmCross/issues/507
[0:] mvx:Warning: 18.30 using Inflate with a null parent viewGroup is discouraged - see https://github.com/MvvmCross/MvvmCross/issues/507
06-04 16:17:36.659 I/mono-stdout(26420): mvx:Warning: 18.30 using Inflate with a null parent viewGroup is discouraged - see https://github.com/MvvmCross/MvvmCross/issues/507
06-04 16:17:36.874 D/Mono (26420): Assembly Ref addref Hlx.Mpos.Droid[0x41c96980] -> Hlx.Net.Extensions[0x5821e218]: 3
[0:]
mvx:Warning: 18.58 using Inflate with a null parent viewGroup is discouraged - see https://github.com/MvvmCross/MvvmCross/issues/507
[0:] mvx:Warning: 18.58 using Inflate with a null parent viewGroup is discouraged - see https://github.com/MvvmCross/MvvmCross/issues/507
06-04 16:17:36.934 I/mono-stdout(26420): mvx:Warning: 18.58 using Inflate with a null parent viewGroup is discouraged - see https://github.com/MvvmCross/MvvmCross/issues/507
06-04 16:17:37.294 W/ResourceType(26420): getEntry failing because entryIndex 66 is beyond type entryCount 1
Thread started: #6
[0:]
mvx:Diagnostic: 19.77 Wait starting for
[0:] mvx:Diagnostic: 19.77 Wait starting for
06-04 16:17:38.134 I/mono-stdout(26420): mvx:Diagnostic: 19.77 Wait starting for
Thread started: #7
[0:]
mvx:Diagnostic: 19.91 Wait starting for
06-04 16:17:38.259 I/mono-stdout(26420): mvx:Diagnostic: 19.91 Wait starting for
[0:] mvx:Diagnostic: 19.91 Wait starting for
06-04 16:17:38.414 W/ResourceType(26420): getEntry failing because entryIndex 129 is beyond type entryCount 1
[0:]
MvxBind:Warning: 20.77 Null values not permitted in spinner SelectedItem binding currently
[0:] MvxBind:Warning: 20.77 Null values not permitted in spinner SelectedItem binding currently
06-04 16:17:39.119 I/mono-stdout(26420): MvxBind:Warning: 20.77 Null values not permitted in spinner SelectedItem binding currently
[0:]
==> Rendered UI in ms 2248
[0:] ==> Rendered UI in ms 2248
06-04 16:17:39.204 I/mono-stdout(26420): ==> Rendered UI in ms 2248
06-04 16:17:40.379 D/AbsListView(26420): unregisterIRListener() is called
06-04 16:17:41.324 D/AbsListView(26420): onVisibilityChanged() is called, visibility : 4
06-04 16:17:41.329 D/AbsListView(26420): unregisterIRListener() is called
SECOND RUN (271 ms)
06-04 16:19:53.624 D/AbsListView(26420): onVisibilityChanged() is called, visibility : 0
06-04 16:19:53.624 D/AbsListView(26420): unregisterIRListener() is called
06-04 16:19:53.649 D/AbsListView(26420): unregisterIRListener() is called
06-04 16:19:54.044 E/ViewRootImpl(26420): sendUserActionEvent() mView == null
[0:]
mvx:Diagnostic:158.89 Showing ViewModel ArticleDetailViewModel
[0:] mvx:Diagnostic:158.89 Showing ViewModel ArticleDetailViewModel
06-04 16:19:57.249 I/mono-stdout(26420): mvx:Diagnostic:158.89 Showing ViewModel ArticleDetailViewModel
[0:]
mvx:Diagnostic:159.32 Attempting to load new ViewModel from Intent with Extras
[0:] mvx:Diagnostic:159.32 Attempting to load new ViewModel from Intent with Extras
[0:]
06-04 16:19:57.664 I/mono-stdout(26420): mvx:Diagnostic:159.32 Attempting to load new ViewModel from Intent with Extras
mvx:Diagnostic:159.32 Adding subscription 4efbcbd0-c623-48ab-9172-108d6ae0b036 for ArticleEditDoneMsg
[0:] mvx:Diagnostic:159.32 Adding subscription 4efbcbd0-c623-48ab-9172-108d6ae0b036 for ArticleEditDoneMsg
[0:]
mvx:Diagnostic:159.33 Nothing registered for messages of type MvxSubscriberChangeMessage
06-04 16:19:57.669 I/mono-stdout(26420): mvx:Diagnostic:159.32 Adding subscription 4efbcbd0-c623-48ab-9172-108d6ae0b036 for ArticleEditDoneMsg
[0:] mvx:Diagnostic:159.33 Nothing registered for messages of type MvxSubscriberChangeMessage
06-04 16:19:57.674 I/mono-stdout(26420): mvx:Diagnostic:159.33 Nothing registered for messages of type MvxSubscriberChangeMessage
[0:]
mvx:Warning:159.35 using Inflate with a null parent viewGroup is discouraged - see https://github.com/MvvmCross/MvvmCross/issues/507
[0:] mvx:Warning:159.35 using Inflate with a null parent viewGroup is discouraged - see https://github.com/MvvmCross/MvvmCross/issues/507
06-04 16:19:57.699 I/mono-stdout(26420): mvx:Warning:159.35 using Inflate with a null parent viewGroup is discouraged - see https://github.com/MvvmCross/MvvmCross/issues/507
[0:]
mvx:Warning:159.36 using Inflate with a null parent viewGroup is discouraged - see https://github.com/MvvmCross/MvvmCross/issues/507
[0:] mvx:Warning:159.36 using Inflate with a null parent viewGroup is discouraged - see https://github.com/MvvmCross/MvvmCross/issues/507
06-04 16:19:57.714 I/mono-stdout(26420): mvx:Warning:159.36 using Inflate with a null parent viewGroup is discouraged - see https://github.com/MvvmCross/MvvmCross/issues/507
Thread started: #8
[0:]
mvx:Diagnostic:159.46 Wait starting for
[0:] mvx:Diagnostic:159.46 Wait starting for
06-04 16:19:57.814 I/mono-stdout(26420): mvx:Diagnostic:159.46 Wait starting for
Thread started: #9
[0:]
mvx:Diagnostic:159.50 Wait starting for
[0:] mvx:Diagnostic:159.50 Wait starting for
06-04 16:19:57.849 I/mono-stdout(26420): mvx:Diagnostic:159.50 Wait starting for
[0:]
MvxBind:Warning:159.62 Null values not permitted in spinner SelectedItem binding currently
[0:] MvxBind:Warning:159.62 Null values not permitted in spinner SelectedItem binding currently
06-04 16:19:57.969 I/mono-stdout(26420): MvxBind:Warning:159.62 Null values not permitted in spinner SelectedItem binding currently
[0:]
==> Rendered UI in ms 271
[0:] ==> Rendered UI in ms 271
06-04 16:19:57.984 I/mono-stdout(26420): ==> Rendered UI in ms 271
06-04 16:19:58.054 D/AbsListView(26420): unregisterIRListener() is called
06-04 16:19:58.279 D/AbsListView(26420): onVisibilityChanged() is called, visibility : 4
06-04 16:19:58.279 D/AbsListView(26420): unregisterIRListener() is called
Related
For some reason, I get exception during instantiation of the home controller. I am very puzzled by it. I am thinking that may be it is caused by the different life time scope of the different dependencies - InstancePerDependency and SingleInstance.
using: Autofac.4.0.0
In my Register(). I have:
builder.Register(x => new DepositEligibilityService()).As<IDepositEligibilityService>().InstancePerDependency();
builder.Register(x => new SemanticExceptionManager()).As<IExceptionManager>().SingleInstance();
builder.Register(x => new SemanticLoggingManager()).As<ILoggingManager>().SingleInstance();
and
public class HomeController : BaseController
{
private readonly IAuthenticationManager _authenticationManager;
LoginInfo _loginInfo;
public HomeController(IDepositEligibilityService depositEligibilityService, IExceptionManager exceptionManager, ILoggingManager loggingManager):base(depositEligibilityService, exceptionManager, loggingManager)
{
// ...
}
}
I sometimes get an exception like the following:
Exception information:
Exception type: DependencyResolutionException
Exception message: An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = HomeController (ReflectionActivator), Services = [DepositEligibility.Web.Controllers.HomeController], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = None, Ownership = OwnedByLifetimeScope ---> An exception was thrown while invoking the constructor 'Void .ctor(DepositEligibility.Web.Services.IDepositEligibilityService, Gdot.Services.SemanticLogging.Interfaces.IExceptionManager, Gdot.Services.SemanticLogging.Interfaces.ILoggingManager)' on type 'HomeController'. ---> Object reference not set to an instance of an object. (See inner exception for details.) (See inner exception for details.)
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters)
at Autofac.Core.Resolving.InstanceLookup.Execute()
at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters)
at Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration registration, IEnumerable`1 parameters)
at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable`1 parameters, Object& instance)
at Autofac.ResolutionExtensions.ResolveOptionalService(IComponentContext context, Service service, IEnumerable`1 parameters)
at System.Web.Mvc.DefaultControllerFactory.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType)
An exception was thrown while invoking the constructor 'Void .ctor(DepositEligibility.Web.Services.IDepositEligibilityService, Gdot.Services.SemanticLogging.Interfaces.IExceptionManager, Gdot.Services.SemanticLogging.Interfaces.ILoggingManager)' on type 'HomeController'. ---> Object reference not set to an instance of an object. (See inner exception for details.)
at Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate()
at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters)
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters)
Object reference not set to an instance of an object.
at DepositEligibility.Web.Controllers.BaseController..ctor(IDepositEligibilityService depositEligibilityService, IExceptionManager exceptionManager, ILoggingManager loggingManage)
at DepositEligibility.Web.Controllers.HomeController..ctor(IDepositEligibilityService depositEligibilityService, IExceptionManager exceptionManager, ILoggingManager loggingManager)
at lambda_method(Closure , Object[] )
at Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate()
I am getting this following error when i am trying to compile my play application. Please anyone help me to fix this error..
[info] Compiling 4 Scala sources and 3 Java sources to /home/decathlon/play/samples/java/myApp/target/scala-2.10/classes...
[error] /home/decathlon/play/samples/java/myApp/app/views/index.scala.html:0: value Context is not a member of object play.mvc.Http
[error] /home/decathlon/play/samples/java/myApp/app/views/main.scala.html:0: value Context is not a member of object play.mvc.Http
[error] two errors found
[error] (compile:compile) Compilation failed
[error] Total time: 1 s, completed 11 May, 2014 9:24:02 PM
Follow the template parameter #(content: Html) in your main template
In the index template you should have something like this
#main() {
<div>..</div>
}
and in the controller something like this
public static Result index() {
return ok(
index.render()
);
}
I have an iOS app built with Xamarin iOS that crashes when loading the class that has DllImport attributes for PInvoke calls. The exception is:
Unhandled managed exception: An exception was thrown by the type initializer for Pazanga.Native.ZzPINVOKE (System.TypeInitializationException)
The app worked fine, but started crashing when the native library grew in size. After cropping some parts of the library it worked again, but after linking a new library it started crashing again. The crash happens before any calls are actually made to the native library.
Here is the device log after the crash: http://pastebin.com/vW3CMXHq
The inner exceptions are:
Aug 23 10:33:40 Outboxs-iPod pazanga[4216] <Warning>: System.TypeInitializationException: An exception was thrown by the type initializer for Pazanga.Native.ZzPINVOKE ---> System.TypeInitializationException: An exception was thrown by the type initializer for SWIGStringHelper ---> System.ExecutionEngineException: Attempting to JIT compile method '(wrapper native-to-managed) Pazanga.Native.ZzPINVOKE/SWIGStringHelper:CreateString (intptr)' while running with --aot-only. See http://docs.xamarin.com/ios/about/limitations for more information.
at (wrapper managed-to-native) object:__icall_wrapper_mono_delegate_to_ftnptr (object)
at (wrapper managed-to-native) Pazanga.Native.ZzPINVOKE/SWIGStringHelper:SWIGRegisterStringCallback_Zz (Pazanga.Native.ZzPINVOKE/SWIGStringHelper/SWIGStringDelegate)
at Pazanga.Native.ZzPINVOKE+SWIGStringHelper..cctor () [0x00017] in /Users/max/Code/pazanga/mobile/ios/bindings/ZzPINVOKE.cs:229
--- End of inner exception stack trace ---
at Pazanga.Native.ZzPINVOKE..cctor () [0x0000a] in /Users/max/Code/pazanga/mobile/ios/bindings/ZzPINVOKE.cs:233
--- End of inner exception stack trace ---
at Pazanga.Native.Zz.locate (System.Byte[] image, image_format format, Int32 width, Int32 height, Int32 x, Int32 y) [0x00009] in /Users/max/Code/pazanga/mobile/ios/bindings/Zz.cs:16
at Pazanga.CaptureDecode.ProcessFrame (System.Byte[] data, Int32 dataWidth, Int32 dataHeight, Boolean isPicture) [0x000cf] in /Users/max/Code/pazanga/mobile/common/CaptureDecode.cs:95
at Pazanga.iOS.CaptureViewController.HandleNewFrame (System.Byte[] data, Int32 width, Int32 height) [0x0003b] in /Users/max/Code/pazanga/mobile/ios/App/CaptureViewController.cs:128
at Pazanga.iOS.CaptureManager.OnNewFrame (System.Byte[] array, Int32 width, Int32 height) [0x00015] in /Users/max/Code/pazanga/mobile/ios/App/CaptureManager.cs:126
at Pazanga.iOS.CaptureManager+OutputDelegate.DidOutputSampleBuffer (MonoTouch.AVFoundation.AVCaptureOutput captureOutput, MonoTouch.CoreMedia.CMSampleBuffer sampleBuffer, MonoTouch.AVFoundation.AVCaptureConnection connection) [0x000c6] in /Users/max/Code/pazanga/mobile/ios/App/CaptureManager.cs:110
Aug 23 10:33:40 Outboxs-iPod pazanga[4216] <Warning>: System.TypeInitializationException: An exception was thrown by the type initializer for SWIGStringHelper ---> System.ExecutionEngineException: Attempting to JIT compile method '(wrapper native-to-managed) Pazanga.Native.ZzPINVOKE/SWIGStringHelper:CreateString (intptr)' while running with --aot-only. See http://docs.xamarin.com/ios/about/limitations for more information.
at (wrapper managed-to-native) object:__icall_wrapper_mono_delegate_to_ftnptr (object)
at (wrapper managed-to-native) Pazanga.Native.ZzPINVOKE/SWIGStringHelper:SWIGRegisterStringCallback_Zz (Pazanga.Native.ZzPINVOKE/SWIGStringHelper/SWIGStringDelegate)
at Pazanga.Native.ZzPINVOKE+SWIGStringHelper..cctor () [0x00017] in /Users/max/Code/pazanga/mobile/ios/bindings/ZzPINVOKE.cs:229
--- End of inner exception stack trace ---
at Pazanga.Native.ZzPINVOKE..cctor () [0x0000a] in /Users/max/Code/pazanga/mobile/ios/bindings/ZzPINVOKE.cs:233
Aug 23 10:33:40 Outboxs-iPod pazanga[4216] <Warning>: System.ExecutionEngineException: Attempting to JIT compile method '(wrapper native-to-managed) Pazanga.Native.ZzPINVOKE/SWIGStringHelper:CreateString (intptr)' while running with --aot-only. See http://docs.xamarin.com/ios/about/limitations for more information.
at (wrapper managed-to-native) object:__icall_wrapper_mono_delegate_to_ftnptr (object)
at (wrapper managed-to-native) Pazanga.Native.ZzPINVOKE/SWIGStringHelper:SWIGRegisterStringCallback_Zz (Pazanga.Native.ZzPINVOKE/SWIGStringHelper/SWIGStringDelegate)
at Pazanga.Native.ZzPINVOKE+SWIGStringHelper..cctor () [0x00017] in /Users/max/Code/pazanga/mobile/ios/bindings/ZzPINVOKE.cs:229
And here is the SWIGStringHelper class (generated by SWIG) that appears in the exception:
protected class SWIGStringHelper {
public delegate string SWIGStringDelegate(string message);
static SWIGStringDelegate stringDelegate = new SWIGStringDelegate(CreateString);
[DllImport("__Internal", EntryPoint="SWIGRegisterStringCallback_Zz")]
public static extern void SWIGRegisterStringCallback_Zz(SWIGStringDelegate stringDelegate);
[MonoTouch.MonoPInvokeCallback(typeof(SWIGStringDelegate))]
static string CreateString(string cString) {
return cString;
}
static SWIGStringHelper() {
SWIGRegisterStringCallback_Zz(stringDelegate);
}
}
Any ideas on how to solve this?
To close the loop... It turned out to be a duplicate of bug 14194 (reverse callback using a string).
A TypeInitializationException was thrown because the exception occurred inside a static constructor.
Can I use the ContactPicker contract when the app is snapped?
var picker = new Windows.ApplicationModel.Contacts.ContactPicker();
picker.CommitButtonText = "Select";
picker.SelectionMode = Windows.ApplicationModel.Contacts.ContactSelectionMode.Fields;
picker.DesiredFields.Add(Windows.ApplicationModel.Contacts.KnownContactField.Email);
var contactInformation = await picker.PickSingleContactAsync();
The above code works when in fullscreen but throws the following exception on the call to PickSingleContactAsync() when snapped to the side of the screen:
System.Runtime.InteropServices.COMException was unhandled by user code
HResult=-2147467259
Message=Error HRESULT E_FAIL has been returned from a call to a COM component.
Source=mscorlib
ErrorCode=-2147467259
StackTrace:
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at TouchToneDtmf.MainPage.d__e.MoveNext()
in
d:\Users\Foo\MainPage.xaml.cs:line
556 InnerException:
It's not working when the app is snapped - you should check the visual state of the app before calling the ContactPicker.
In the official C# sample there is also method EnsureUnsnapped() you might find helpful when implementing this contract.
Every time you call a file[/contact] picker you must first make sure that your
app can show the file[/contact] picker by verifying that your app in not snapped
or, if your app is snapped, that it can be unsnapped in order to show
the file picker. Source - How to save files through file pickers
using Windows.UI.ViewManagement;
//...
internal bool EnsureUnsnapped()
{
bool unsnapped = ((ApplicationView.Value != ApplicationViewState.Snapped) || ApplicationView.TryUnsnap());
return unsnapped;
}
I'm building an application in C# that has a static class which initiate a COM class and handles some event handlers of another class that hooks keyboard.
When I call a method of the COM class from a button event handler in my WPF window, the method works without any problems but when I call it in one of the event callbacks within my static class it throws following exception:
Unable to cast COM object of type 'BLAHBLAH' to interface type
'BLAHBLAH'. This operation failed because the QueryInterface call on
the COM component for the interface with IID
'{9DD6680B-3EDC-40DB-A771-E6FE4832E34A}' failed due to the following
error: An outgoing call cannot be made since the application is
dispatching an input-synchronous call. (Exception from HRESULT:
0x8001010D (RPC_E_CANTCALLOUT_ININPUTSYNCCALL)).
Can you please tell me, what this exception means and how can I solve it?
Wrap your code in a new thread:
Thread thread = new Thread(() =>
{
ManagementObjectSearcher theSearcher = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive");
foreach (ManagementObject currentObject in theSearcher.Get())
{
Debug.WriteLine("Device present: " + currentObject);
ManagementObject theSerialNumberObjectQuery = new ManagementObject("Win32_PhysicalMedia.Tag='" + currentObject["DeviceID"] + "'");
serial = theSerialNumberObjectQuery["SerialNumber"].ToString();
}
});
thread.Start();
thread.Join(); //wait for the thread to finish
Refer this KB http://support.microsoft.com/kb/198996
Looks like it is because of threads(May not be user defined threads)