locked
Console application with SharePoint client object model crahes when run remotely RRS feed

  • Question

  • I am trying to execute a console application running on SharePoint Client Object code , from a remote computer (see code below). The site http://win2k8-r2-01 has anonymous access enabled and can be browseable from remote machine (where console application is tested)
     
     static void Main(string[] args)
            {
                try
                {
                    Console.WriteLine("Identity:- " + System.Security.Principal.WindowsIdentity.GetCurrent().Name);
                    Console.Write("Step 1");
                    Console.ReadLine();
                    
                    ClientContext ctx = new ClientContext("http://win2k8-r2-01");
                   
                    Site spSite = ctx.Site;
                    ctx.Load(spSite);
                    ctx.ExecuteQuery(); 
    
                }
                catch (System.Exception e)
                {
                    Console.WriteLine(e.ToString());
                }
                finally
                {
                    Console.Write("Press Any key to exit");
                    Console.ReadLine();
    
                }
            }
    The application crahes immediately on a remote machine, but runs without any issues on development envrioment with SharePoint Server 2010installed locally. More over the required assemblies "Microsoft.SharePoint.Client.dll" and "Microsoft.SharePoint.Client.Runtime.dll" are also exists in the same folder as of the console application on the remote machine.

    The configuration of development envrioment , remote envrioment and dump (after application crash) is as follows. Lastly , for checking that console application is running without SharePoint client code , I commented out the SharePoint client side code after  line "Console.Write("Step 1")  and application runs on the remote machine without any error.

    Remote Machine
    OS : Windows Server 2008 Enterprise R2 
    Mcrosoft.NET Framework : .NET 3.5 SP1
    Assemblies : "Microsoft.SharePoint.Client.dll" and "Microsoft.SharePoint.Client.Runtime.dll" , present in the same folder as of console application.


    Development Machine
    OS : Windows Server 2008 Enterprise R2 
    SharePoint Server 2010 Beta (Standalone Installation)
    Visual Studio 2010 Beta 2 

    Application Crash Dump

    Description:
      Stopped working
    
    Problem signature:
      Problem Event Name:	APPCRASH
      Application Name:	ClientOMSample.exe
      Application Version:	1.0.0.0
      Application Timestamp:	4b0fae0c
      Fault Module Name:	KERNELBASE.dll
      Fault Module Version:	6.1.7600.16385
      Fault Module Timestamp:	4a5bdfe0
      Exception Code:	e0434f4d
      Exception Offset:	000000000000aa7d
      OS Version:	6.1.7600.2.0.0.274.10
      Locale ID:	18441
    
    Read our privacy statement online:
      http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0409
    
    If the online privacy statement is not available, please read our privacy statement offline:
      H:\Windows\system32\en-US\erofflps.txt
    



     





     




    http://razi.spaces.live.com/
    Thursday, November 26, 2009 11:24 AM

All replies

  • Wondering why the need to include the four lines on privacy statements ?
    FAQ sites: (SP 2010) http://wssv4faq.mindsharp.com; (v3) http://wssv3faq.mindsharp.com and (WSS 2.0) http://wssv2faq.mindsharp.com
    Complete Book Lists (incl. foreign language) on each site.
    Thursday, November 26, 2009 11:44 AM
  • Wondering why the need to include the four lines on privacy statements ?
    FAQ sites: (SP 2010) http://wssv4faq.mindsharp.com; (v3) http://wssv3faq.mindsharp.com and (WSS 2.0) http://wssv2faq.mindsharp.com
    Complete Book Lists (incl. foreign language) on each site.
    Because I copy the complete dump and thought to keep it as it is , any comments on the issue?
    http://razi.spaces.live.com/
    Thursday, November 26, 2009 12:50 PM
  • Did you check the event log in the client machine? Is something logged?

    What about authentication? Your code you pasted here does not deal with any authentication. May be SharePoint 2010 is expecting authentication?
    Regards,
    Chakkaradeep || SharePoint Developer - MCTS SharePoint Dev, WSS Dev
    http://www.intergen.co.nz || Twitter: http://twitter.com/chakkaradeep || http://www.chakkaradeep.com
    Monday, November 30, 2009 8:08 PM
  • Razi,

    I found a blog post referencing a similar kernelbase.dll fault that has to do with Office Communicator 2007 running on Windows 7.  Details here:
    http://blogs.msdn.com/jasonward/archive/2009/03/16/windows-7-and-office-communicator-2007.aspx

    The fix looks to be to only office communicator, but I wonder if there is a similar underlying issue with SP .dll's on Windows 7.

    VR,
    Dave Milner
    Monday, November 30, 2009 11:09 PM

  • Actually I am running the console application inside Windows 2008 Server R2 Enterprise Edition (as mentioned in orignal post) not on Windows 7.It seems that fix mentioned in blog entry address specific issues related to communicator 2007 as mentioned in KB article http://support.microsoft.com/default.aspx/kb/969694.

    Anyways thats for the response.

    http://razi.spaces.live.com/
    Tuesday, December 1, 2009 9:37 AM
  • What makes you think that this approach should work? You are supposed to work with SharePoint on the machine with SharePoint installed. If you need some remote app accessing sharepoint - you have to use SharePoint web services or your custom web services.
    Paul Shkurikhin blog.sharepointalist.com
    Tuesday, December 1, 2009 10:13 AM
  • >>What makes you think that this approach should work? You are supposed to work with SharePoint on the machine with SharePoint installed

    I think you are probably not aware of the capabilities of the new Client Object Model introduced in SharePoint 2010. Refer to these videos to get an overview of Client Object Model in SharePoint 2010 .
    Regards,
    Chakkaradeep || SharePoint Developer - MCTS SharePoint Dev, WSS Dev
    http://www.intergen.co.nz || Twitter: http://twitter.com/chakkaradeep || http://www.chakkaradeep.com
    Tuesday, December 1, 2009 10:33 AM
  • Paul , I am not sure in what context you are replying, its very well documented that SharePoint 2010 client side object model is design to run from remote machines. A simple reading to MSFT post http://blogs.msdn.com/ericwhite/archive/2009/11/20/using-the-sharepoint-2010-managed-client-object-model.aspx 
    gives good understanding on this. 



    http://razi.spaces.live.com/
    Tuesday, December 1, 2009 10:38 AM
  • Ooops - sorry guys, haven't got into this one yet :)

    Paul Shkurikhin blog.sharepointalist.com
    Tuesday, December 1, 2009 5:42 PM
  • Did you change the target platform to be 64 bit?


    Paul Shkurikhin blog.sharepointalist.com
    Tuesday, December 1, 2009 11:20 PM
  • @Paul Shkurikhin
    Yes , the target platfrom is x64 bit.Its also clear from the orignal post , otherwise this client application will not even run on development machine in the first place.  
    http://razi.spaces.live.com/
    Wednesday, December 2, 2009 9:03 AM
  • By any chance did you try debugging step-by-step (F10) ? Can you tell exactly after what line it fails?


    P.S: VS2010 will default the application's target platform to be 32bit , unless you change it manually. And this is something I have seen many fail to do.

    Regards,
    Chakkaradeep || SharePoint Developer - MCTS SharePoint Dev, WSS Dev
    http://www.intergen.co.nz || Twitter: http://twitter.com/chakkaradeep || http://www.chakkaradeep.com
    Wednesday, December 2, 2009 9:23 AM
  • @Chakkaradeep
    Re-read my orignal post, I mentioned from which line the code starts crashing. Simply commenting these lines will make application run smothly but offcourse then SharePoint Client object model is not utlilized at all.

    Applciation target platfrom is x64 as I mentioned in previous post. 
    http://razi.spaces.live.com/
    Wednesday, December 2, 2009 9:32 AM
  • @Razi - Thanks for clarifying that :)

    I will try a simple solution as yours from a Windows Server 2008 R2 development machine (which is totally off from the SharePoint domain) and let you know how it goes. I have tried it in earlier builds (not Beta2) and they went smooth. I was able to execute from my devleopment machine which WS 2008 R2.

    By any chance, did you try building another Console Application?
    Regards,
    Chakkaradeep || SharePoint Developer - MCTS SharePoint Dev, WSS Dev
    http://www.intergen.co.nz || Twitter: http://twitter.com/chakkaradeep || http://www.chakkaradeep.com
    Wednesday, December 2, 2009 9:40 AM
  • I agree with @Chakkaradeep, you should run a debugger on the client machine and debug your code so that you can see more diagnostic information. AppCrash is just the default exception handler and it doesn't really tell you much.

    Also, although you are outputting the security credentials you don't actually asign them to the Client Context before calling ExecuteQuery. I believe this is required.

    Cheers,
    Paul
    SharePoint Product Manager. Posting is provided "AS IS" with no warranties, and confers no rights
    Sunday, December 13, 2009 1:19 AM
  • @Paul
    I will try that , btw the  site collection has anonymous access enabled and can be browsed from the same machine where I am running the applicaiton (the server and client machines are on different workgroups) , without any credentails . As the application crashes rather than getting unauthorized access exeception it seems its not even connecting to the server. Remote debugging is almost impossible to perfrom due to some reasons , but will try to do it.

     

    http://razi.spaces.live.com/
    Monday, December 14, 2009 3:57 AM
  • Did you try with SharePoint Workspace client to see whether it can fetch the data anonymously or does it still aks for username & password?
    Regards,
    Chakkaradeep || SharePoint Developer - MCTS SharePoint Dev, WSS Dev
    http://www.intergen.co.nz || Twitter: http://twitter.com/chakkaradeep || http://www.chakkaradeep.com
    Monday, December 14, 2009 4:40 AM
  • Hi

    We have exactly the same issue, and are currently troubleshooting it

    Monday, July 5, 2010 2:00 PM
  • The solution is to provide proper credentials using the system.net.NetworkCredential class.

    Take this code as a reference:

    NetworkCredential credentials = new NetworkCredential("username", "pwd", "domain");
    
    ClientContext context = new ClientContext(http://site-url);
    
    context.Credentials = credentials;
    

     

    • Proposed as answer by John Muller Monday, July 5, 2010 3:58 PM
    Monday, July 5, 2010 3:57 PM
  • I can add a reference to the Microsoft.SharePoint.Client.dll and run my application.  If I add a using statement, I can still run my app.  As soon as I add any sort of code that references those objects, I get an error saying that the class I am working in can't be found.

     

    This gives me the error: The type or namespace name 'MyClass' could not be found

        public class MyClass
        {
            public void test()
            {
                string teststring = Microsoft.SharePoint.Client.AddFieldOptions.AddFieldCheckDisplayName.ToString();

    This will compile

        public class MyClass
        {
            public void test()
            {
                //string teststring = Microsoft.SharePoint.Client.AddFieldOptions.AddFieldCheckDisplayName.ToString();

     

    I tried calling this class from win form app, then from a console app and got the same issue.  I am using x86 xp and visual studio 2010.
    Wednesday, July 14, 2010 9:03 PM
  • Try to add reference to Microsoft.SharePoint.Client.Runtime assembly, also make sure that target platform for the project is x64.
    http://razi.spaces.live.com/
    Wednesday, July 14, 2010 11:41 PM
  • Already done on both.
    The thing that confuses me is that I can reference my class library from my form project without issue.

    If I leave the code exactly the way that it is, with a using statement referencing the client object model, my class library still works, but my form can no longer see the class library.

    Thursday, July 15, 2010 1:12 PM
  • Have you tried registering Microsoft.SharePoint.Client.dll and Microsoft.SharePoint.Client.Runtime.dll in GAC on the machine you are trying to execute you console application on? that seemed to do the trick for me

    Dennis Alzoubi
    Wednesday, September 28, 2011 9:33 PM