Error in Application.Run(DisplayLoginForm) and Remote Authentication in SharePoint Online Using the Client Object Model

Hi guys
I Think that is a simple error, but I don’t have enough knowledge in .NET apps.
I make an console app that use Remote Authentication in SharePoint Online Using the Client Object Model, that a I downloaded from MSDN.
This App run ok.
But when I like to make a Windows From App. This component send me an error in Application.Run(DisplayLoginForm)
This err msg :
 An unhandled exception of type 'System.InvalidOperationException' occurred in System.Windows.Forms.dll
Additional information: Starting a second message loop on a single thread is not a valid operation. Use Form.ShowDialog instead.
Is there any way to use a form inside a windows form?
Thank in advance
Ramiro
Ramiro B

Hi,
Based on the error message, please do as following:
1. Check your code logic below:
void btn_Click(object sender, System.EventArgs e)
Thread t = new Thread(StartMyForm);
t.TrySetApartmentState(ApartmentState.STA);
t.Start();
public static void StartMyForm()
Application.Run(new MyForm(..));
2.Try to add the following code line in your code.
Application.Restart();
If the issue still exists, please provide your requirement and code for a further research.
Best Regards
Dennis Guo
TechNet Community Support

Similar Messages

  • My 2011 MBP has begun running slow with frequent 'spinning beach ball' events. I'm running Yosemite and wondered if I should of use the original install disk for maintenance.

    My 2011 MBP has begun running slow with frequent 'spinning beach ball' events. I'm running Yosemite and wondered if I should of use the original install disk for a maintenance reinstall. I presume I'd have to download Yosemite again, though I'd be happy just using Snow Leopard again too.
    Thanks for the help.

    When you see a beachball cursor or the slowness is especially bad, note the exact time: hour, minute, second.  
    These instructions must be carried out as an administrator. If you have only one user account, you are the administrator.
    Launch the Console application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad and start typing the name.
    The title of the Console window should be All Messages. If it isn't, select
              SYSTEM LOG QUERIES ▹ All Messages
    from the log list on the left. If you don't see that list, select
              View ▹ Show Log List
    from the menu bar at the top of the screen.
    Each message in the log begins with the date and time when it was entered. Scroll back to the time you noted above.
    Select the messages entered from then until the end of the episode, or until they start to repeat, whichever comes first.
    Copy the messages to the Clipboard by pressing the key combination command-C. Paste into a reply to this message by pressing command-V.
    The log contains a vast amount of information, almost all of it useless for solving any particular problem. When posting a log extract, be selective. A few dozen lines are almost always more than enough.
    Please don't indiscriminately dump thousands of lines from the log into this discussion.
    Please don't post screenshots of log messages—post the text.
    Some private information, such as your name, may appear in the log. Anonymize before posting.

  • The remote server returned an error: (401) Unauthorized. while running client context using sharepoint client object model

    Hi,
    I have started using the client object model so that i do not have to go to sharepoint admins to perform some basic operations on remote server. While assigning list item level permission i am getting following error, could you please help. thanks.
    The remote server returned an error: (401) Unauthorized.
       at
    System.Net.HttpWebRequest.GetResponse()
       at
    Microsoft.SharePoint.Client.SPWebRequestExecutor.Execute()
       at
    Microsoft.SharePoint.Client.ClientContext.EnsureFormDigest()
       at
    Microsoft.SharePoint.Client.ClientContext.ExecuteQuery()
       at
    SetDowntimeItemPermission.SetPermission.Main(String[] args) in

    it seems your request was unauthenticated i'm not sure are you using a web application with FBA or desktop application my suggestion would be try to impersonate your request by passing network credentials (COM works on network credentials )
    NetworkCredential credentials = new NetworkCredential("username", "pwd", "domain");
    ClientContext context = new ClientContext("http://site-url");
    context.Credentials = credentials;
    Best Regards, Ashutosh | SharePoint World

  • Attach a custom content type and set as default for picture library using client object model

    Hi,
    How to associate custom content type to a picture libraray and set it as default using the client object model?
    Thanks

    Hello,
    Here you go:
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/b1de0697-0006-4f89-8909-1b94aa18ad89/how-to-reorder-content-types-in-list-with-client-context
    http://www.niteenbadgujar.com/2013/05/change-default-content-type.html
    Hope it could help
    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

  • Powershell and Client Object Model - no error thrown if user is added more than once to same site or group

    Hello All -
    I am trying to add a user to a SharePoint site using PowerShell like below:-
    New-SPUser -UserAlias MyDomain\jan20a -Web http://SPServer/sites/MySite
    If I execute the above more than once, SharePoint does not throw that user already exists or something. This is not the same behavior in AD/Exchange PowerShell cmdlets.
    Also, even the client object model behaves the same way.
    Another interesting thing I noticed, I tried to remove a user from group in which the user was not part of it at all and still no error..!!
    Looks like SharePoint does not care of invalid input and just ignores it.
    Can anyone please confirm this and also the reason behind it ?

    It's not really invalid input, since the user exists and that is how SharePoint behaves (will behave same way in browser).  Try to input a user that and misspell the name, e.g. say you didn't have a MyDomain\Jan21a, then try to use same script above,
    only with invalid data.  It will bark at you.  Or try using a web that it cannot find, one that does not exist.  You'll get what I like to call, the red badge of courage if you enter invalid data.
    you can test that sharepoint will let you enter a user twice in the browser, and nothing bad comes from it.  Powershell is just unable to tell that the user was not in the site, when you removed it the second time. 
    Hope that confirms it, if it does please mark this reply accordingly.  thanks
    Stacy Simpkins | MCSE SharePoint | www.sharepointpapa.com

  • Conflict between Client object model and Item Updated Event Receiver in sharepoint 2010

    Hello All,
    As per my requirement I have a two custom list.
    Agent Details
    Port Name
    Agent Details contains Agent code, Port Name,  email, address and phone of Agent. Its possible that one Agent Code is connected with multiple Port Name.
    Basically what I am doing is I am getting port name connected with Agent code, using jquery and bind those values with check box(using javascript created dynamically) and bind all with Div tag.
    Now when my custom edit form of Agent list open up it shows me different port name binding with checkbox group.
    when user select the check box and click confirm button my clicent object model script will run and add this selected value into Port Name list. 
    After confirm one more button named Save will enable asking user to edit the email, phone or address value and when I click on save my Item updated event fires which update the values of the selected port name(These port name I am getting from port
    name list) to Agent Details custom list.
    Now when I am trying to update the values my event receiver fires or some times it got stuck(not firing). So could you please help me the possible alternative for this requirements.
    Can we user the Ecma Script(Client object model to preserve the value of selectec port) and Item updated event receiver on the same time?
    Is anything am doing wrong then please guide me.

    Hi,
    As I understand, when you updated values in the agent details list the Item updated event receiver got stuck sometimes.
    The item update event receiver will fire after the item has been saved, and the client object model script or the Ecma Script runs before the item is saved, so there is no conflict between the client object model script and item update event receiver.
    You could find out the reason about the item update event receiver gets stuck by debugging the event receiver.
    When you want to debug your event receivers, you have to attach to OWSTIMER.EXE and wait till they are executed. You can control this behavior using the Synchronization attribute. Also, if you’re looking for an easy way to debug an event receiver without
    having to manually attach a debugger to your code, you can use the System.Diagnostics.Debugger.Launch() method.
    The articles below are about how to debug in the event receiver in SharePoint 2010.
    http://sharepoint-kings.blogspot.jp/2013/02/debugging-event-receivers-in-sharepoint.html
    http://chakkaradeep.com/index.php/event-receivers-in-sharepoint-2010/
    http://sharesaint.com/?p=77
    Best regards,
    Sara Fan
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • Sharepoint authentication Client object model for direct links

    We have a Sharepoint 2010 site and another website [ASP.Net Web API 2] which uses Client object model to get data from Sharepoint, this is an intranet environment.
    The Client object model part of it is working fine, if any user logs in, it works with that user credentials. But when a user tries to access a direct SP link, ex: a link to a document from a document library, it pops up a credentials window.
    How to get rid of this pop up window, or how to set the authentication for the entire server when the user logs in to our web api.

    Hi,
    The prompt for credential can be seen as a behavior by designed for the sake of safe and there are no solutions to avoid it at this moment per my knowledge. 
    Here is a similar thread will provide more information:
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/85b5d22a-88ed-4975-8de9-1d65df293aeb/avoiding-prompting-for-authentication-when-accessing-the-aspx-page-in-layouts-folder-from-my?forum=sharepointdevelopmentprevious
    Thanks
    Patrick Liang
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Patrick Liang
    TechNet Community Support

  • REP-0177: An error occurred while running in a remote server.

    I am getting the following errors while trying to run a report script.  The report was created in Report Builder.
    REP-0177: An error occurred while running in a remote server.
    Reference parameter OT_RUN_DATE in the distribution list is invalid.
    OT_RUN_DATE is a static field converting SYSDATE to a string (TO_CHAR(SYSDATE, 'YYYYMMDD')).  Unfortunately, I inherited this report and did not create it.  I do not know what purpose it serves but would like more insight into what the reference parameter and distribution list mean.
    REP-0177: An error occurred while running in a remote server.
    Too many errors pushed on the stack
    I assume this is related to the first error but am not certain.
    Any help is greatly appreciated...

    Michel,
    It appears that in the past few days you have not received a response to your
    posting. That concerns us, and has triggered this automated reply.
    Has your problem been resolved? If not, you might try one of the following options:
    - Do a search of our knowledgebase at http://support.novell.com/search/kb_index.jsp
    - Check all of the other support tools and options available at
    http://support.novell.com.
    - You could also try posting your message again. Make sure it is posted in the
    correct newsgroup. (http://support.novell.com/forums)
    Be sure to read the forum FAQ about what to expect in the way of responses:
    http://support.novell.com/forums/faq_general.html
    If this is a reply to a duplicate posting, please ignore and accept our apologies
    and rest assured we will issue a stern reprimand to our posting bot.
    Good luck!
    Your Novell Product Support Forums Team
    http://support.novell.com/forums/

  • I am trying to install an update of Microsoft office and I get a message that says.  This application must be closed ETC.....   I am running Parralell and I think it is there.  The two programs are "Microsoft Database Daemon" "SyncServicesAgent"....

    I am trying to install an update of Microsoft office and I get a message that says.  This application must be closed ETC.....   I am running Parralell and I think it is there.  The two programs are "Microsoft Database Daemon" "SyncServicesAgent".  How do I close these programs?

    If the Office updates have to be run through Win in Parallels, there's not really a section here that covers that , because Neither Office or Parallels are Apple products. There is only a small chance that you'll find someone with BOTH your conditions who just happend to look into a forum on older iMacs.
    Parallels has a forum here:
    http://forum.parallels.com/forum.php
    I think you'll get a faster response there.

  • I am facing problems while openin an application in facebook and other places.when i go to the application,an error shows and firefox closes autmatically either i send error reports or dont.....plz help

    i am facing problems while openin an application in facebook and other places.when i go to the application,an error shows and firefox closes autmatically either i send error reports or dont.....plz help

    Notes:
    1) Please use the code tags when posting code or JNLP/HTML. It helps to retain indentation and avoids asterisks and plus sings being interpreted as formatting marks. To do that, select the code/JNLP etc. and click the CODE button seen on the Plain Text tab of the message posting form.
    2) That launch file is invalid. You might check it (and the project in general) using JaNeLA.
    3) The only place that SimpleSerial class could be, that the JRE would find, is in the root of aeon.jar. Is it actually there?

  • Help IP restore error 21 (DFU ) running DFU  and error 1600. I need help

    I restore error 21 ( DFU ) >>> running DFU and error 1600. >>> I need help ?

    ip 4, 32g is me. I running FW up ios 6.0 >> error 21 ( DFU ) >>  mode DFU  >>>> error 1600 ( recovery mode )

  • I backed up my movies and rebuild my computer, and after making sure i'm using the latest version of itunes and quicktime and and making sure i still had spare computer authorizations, i still get error 23132.  Please help.

    I backed up my movies and rebuild my computer, and after making sure i'm using the latest version of itunes and quicktime and and making sure i still had spare computer authorizations, i still get error 23132.  Please help.

    I had this exact issue.  Spent over an hour on the phone with apple support, they couldn't resolve.  Here is what I ended up doing, that worked.
    1.  Turned iTunes match off on all my iOS devices
    2.  Deleted the offending playlists from the iOS device they originated on
    3.  Started iTunes, let it run (literally) for an hour before it became responsive.  First thing I did, before clicking anywere else was disable iTunes match.  If I clicked anywhere, it would clock for another hour.
    4.  Let iTunes run overnight, by morning it had cleaned out the repeating play lists.  This got my Mac/iTunes back to an operable state.
    5.  Restore iPhones from backup in iTunes.
    What was causing my issue was a single playlist that was created on an iPhone, then suddenly showed up with several thousand duplicates on my other iPhone.  The culprit playlist did not, for some reason, duplicate itself on my two iPads.  Apple support seemed to think it was because the problem iPhone tried to sync the playlist to iCloud over and over again unsuccessfully, then it finally went through and populated the thousands of blank/failed playlists which then tried to propigate to iTunes and my other iOS devices.  Seems like a reasonable theory.
    I have not yet re-enabled iTunes match.  So, no idea what will happen if I decide to go back down that rabbit hole.

  • HT2409 I'm getting "can't add volume. Unknown error occured" when I try and add my Mac hard drive to the privacy settings

    I'm getting "can't add volume. Unknown error occured" when I try and add my Mac hard drive to the privacy settings

    Launch the Console application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Console in the icon grid.
    Make sure the title of the Console window is All Messages. If it isn't, select All Messages from the SYSTEM LOG QUERIES menu on the left. If you don't see that menu, select
    View ▹ Show Log List
    from the menu bar.
    Click the Clear Display icon in the toolbar. Then try the action that you're having trouble with again. Select any messages that appear in the Console window. Copy them to the Clipboard (command-C). Paste into a reply to this message (command-V).
    When posting a log extract, be selective. In most cases, a few dozen lines are more than enough.
    Please do not indiscriminately dump thousands of lines from the log into this discussion.
    Important: Some private information, such as your name, may appear in the log. Anonymize before posting.

  • Remote server returned an error: (401) Unauthorized. in Client Object Model

    Hi
    I'm facing below error when using Client object model to access the sharepoint extended site which is windows authentication.'
    The
    remote server returned an error: (401) Unauthorized
    The COM code was working fine, suddenly we get this error, so I'm sure nothing to fix in code. Please help what might cause this issue which was working well.
    Subbu

    Can you post your code to understand how you are authenticating with SharePoint?
    Bala

  • TS1277 iTunes is unable to run. I tried to run iTunes and a message comes up that says "the iTunes library.itl file is locked, on a locked disk, or you do not have write permission for this file." what is the solution to unlock it ?!

    iTunes is unable to run. I tried to run iTunes and a message comes up that says "the iTunes library.itl file is locked, on a locked disk, or you do not have write permission for this file." what is the solution to unlock it ?!

    I have tried both suggestions, unfortunately neither fixed this for me. Hoping there's another possible fix. Thanks in advance. 
    Empty/corrupt iTunes library after upgrade/crash and/or Repair security permissions for iTunes for Windows.

Maybe you are looking for

  • Nokia Software Updater for N71

    I have a Nokia PC-Suit installed with Nokia software updater, I was able to update my firmware till latest version, Recently when I started Nokia Software Updater, it asked me that an update is available (for the updater), When I selected to download

  • CLASSIC will not recognize my zip drive

    classic will not recognize my zip drive...i have one program that roland will not update and it only runs in os9...so the program opens but will not let me select the zip drive as a option...please advise if classic can detect zip drives etc...thanks

  • HR PAYROLL POSTING

    Hi all, How to assign more than one employee vendors to one symbolic account? While assigning two or more employee vendors to one symbolic account, Error staes that Account Key already exists. Regards.

  • Plugins result in no audio

    I'm running the latest version of GB, and when I install a plugin, and use it, after using the plugin for about five to ten seconds the sound for it will completely stop working. The only way to get sound in BG back is to change instruments, then If

  • Gprs settings for iphone 3g version 2.1

    can not set up gprs connection on my iphone 3g ... software version is 2.1 pls advise how can I set this up