F# Script SharePoint 2010 API doesn't work - sharepoint

I am trying something really simple in F# to try and test interaction with the SharePoint 2010 API. I think I am running into a general problem with F#. Is there anyway that an F# script can access the SharePoint 2010 API?
I think my problem is due to the F# scripts running 32bit, and the SharePoint API is in 64bit.
An example of the code I'm trying to run is as follows:
#r "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI\Microsoft.sharepoint.dll"
#r "System.ServiceModel.dll"
open System
open Microsoft.SharePoint
let GetListByUrl (listUrl:string) =
use site = new SPSite(listUrl)
use web = site.OpenWeb()
let list =
if not (web = null) then web.GetList(listUrl)
list
In the visual studio editor it says the following error: The Type System.ServiceModel.ChannelFactory`1 is required here and is unavailable. You must add a reference to assembly ...
When the script is ran it gives the message: System.IO.FileNotFoundException: The Web application at... could not be found. Verify that you have typed the URL correctly...
Which is the error message I get if I try to access the SharePoint 2010 API from a 32bit c# console program. If I change the c# console program to Any CPU that message doesn't appear.
However I'm trying to do this in an F# script which I guess is 32bit, so how would I work around that?
Also since this is probably a general problem with F# scripts and 64bit dlls, how would you work around the problem of needing to reference 64bit dlls in F# scripts?
Edit
I used corflags.exe in the visual studio cmd prompt to modify the fsi.exe to 64bit. I followed this guide: http://ig2600.blogspot.com/2010/05/making-fsharp-interpreter-fsi-run-in.html. That seemed to work, though the F# interactive window seemed slower. However when I ran the code above in the now 64bit fsi it said sharepoint does not work with .net 4.0. How would you run the F# interactive window in .net 3.5?
Edit
Because of the answer posted by F.Aquino in which he said I needed to add a reference to System.ServiceModel I have updated the code to add that.
That fixes the visual studio editor complaints that keep appearing with red squiggly lines everywhere. When the script is ran the results are the same, the script cannot access the sharepoint 2010 API which is the problem I am having.

You need to add a reference to System.ServiceModel

Related

Using interop.MSProject.dll without Office installed or creating Project Add-in in Visual Studio

I need to work on Project Server using Microsoft.Office.Interop.MSProject.dll from Visual Studio.
Using gacutil.exe I have registered Microsoft.Office.Interop.MSProject.dll and at folder "C:\Windows\assembly" there is entry for MSProject.dll whose processor architecture is MSIL.
I have created Console Application and when I try to create Application instance it gives error:
Class not registered-HRESULT: 0x80040154 exception. As shown in image.
Target platform for this project is x86(32-bit). What could be the reason for the error?
Is it because office is not installed on local machine? Is there any alternative to using PIA without installing Office?
I have tried creating Project Add-in from Visual Studio, it works successfully, but it requires Project Professional to be open, which I want to avoid. Is it possible to avoid opening of Project Professional application in this case?
You need to have the Application (i.e. MS Project) installed on the PC. Interop files sre used for marshalling property or method calls from a managed code to the host application.

running a vc++ command line application on non development machine,

When I run command line application (executable generated using visual studio 2008) on non development windows 7 machine it gives following run time error "application has requested run time to terminate in unusual way. Please contact application support team for more information". It runs fine on a development machine.
With VS 2005 and VS 2008, Visual C++ used a side-by-side versioning scheme that requires manifest entries embeddded in the EXE to really work correctly in all cases. It's possible you are dealing with one of these. See these articles for details on debugging these side-by-side issues.
Diagnosing SideBySide failures
Part 1: Troubleshooting VC++ Side by Side Problems
Part 2: Troubleshooting VC++ Side by Side Problems
Note that with VS 2010 and later, Visual C++ no longer uses this side-by-side scheme. That said, there are still lots of reasons to use embedded manifests anyhow. See this article.

visual studio express 2012 version control

I have been sent a working project from a coworker to start learning Visual Studio. The project is under version control, however I don't want to have access to final customer product. So when I try to open the solution file I first get a message that the project is under source control:
"Team Foundation Server Version Control
The solution you are opening is bound to source control on the following Team foundation Serer:
http:// . Would you like to contact this server to try to enable source control integration?"
[yes] [no] [help]
I press no, then I get an error:
"The solution appears to be under source control, but its binding information cannot be found. Because it is not possible to recover the missing information automatically, the projects whose bindings are missing will be treated as not under source control."
[ok] [help]
I proceed and press ok, and another message pops up:
"projectname\projectname.tsproj: The application which this project type is based on was not found. Please try this link for further information: http://go.microsoft.com/fwlink/?prd=12395&pver=11&sbp=ProjectTypeDeprecated&plcid=0x409&clcid=0x409&ar=MSDN&sar=ProjectCompatibility&o1=B1E792BE-AA5F-4E3C-8C82-674BF9C0715B"
My coworker tells me he sent the whole project, so I can't figure out why I cant get visual studio to open it. I am new to visual studio, but I have some programming experience.
Any help is much appreciated.
Thank you
It is doubtful that version control has something to do with your problem. There are two possibilities I could think of:
Your coworker uses full version of VS2012 and you are now having problems due to the fact that Visual Studio Express comes in two main flavours - Web and Desktop. It is unable to load Web(or Desktop) project because it just does not have any tools to work with it. Ask your coworker whether they mix web and desktop in their solutions. If it is so you should either use full VS or be given a reduced set of projects.
Nearly the same - your coworker uses some very old or very new version of particular project type (something like ASP.NET MVC that(as I remember) has different project type for each version). Again ask your coworker if it is so. In this case you will just have to install the needed templates and SDKs.
P.S. I was unable to open your link - it opens microsoft.com/default(maybe due to some regional problems). Search by key words brought to me similar problem for VS2010 http://connect.microsoft.com/VisualStudio/feedback/details/728847/could-not-open-vs2010-solution-with-mvc-project - may be it could help you more specifically.

Deploying Com Interop into sharepoint server

I have a com interop dll (zkemkeeper.dll) that i have to register and use, i wonder how can i deploy that to the SharePoint server using SharePoint package?
You cannot deploy COM or COM Interop DLL to SP farm by SP solution. You need to install the component on every SP server in the farm by other means.
Create an MSI installer to be executed on every machine. MSI can be rolled out automatically too.
Provide a PowerShell script to be executed on every machine. PowerShell can be run remotely too.
Deploy a timer job with your solution that would be executed after the installation automatically or manually and would write to the registry the necessary COM stuff.
The first two options are my favourite because they shouldn't cause technical problems at the customer. The third one appears to promise installation without visiting every machine but the Timer Service user identity would need permission to write to the local registry which may not always be granted; and you'd have to resort to 1. or 2. anyway.
You should think about switching over to ASP.NET or .NET components on the long term. There are many components available in pure .NET that can be deployed by SP solutions. You can also consider pure HTML/JavaScript controls. I would probably go for the option 1. and invest the saved time to other architecture without the COM Interop.
--- Ferda
If you are using Sharepoint 2010, see How to: Add and Remove Additional Assemblies.
See also:
Deploying custom dll's in SharePoint 2010
Visual Studio - SharePoint 2010 - Include Assembly > Quick Question
Include 3rd party dll in the Sharepoint project while packaging the wsp
visual studio does not copy assembly into gac
How to install a WSP that has dependant assemblies?
Interop.zkemkeeper.dll regsvr32 error or InitializeComponent
Then you need done the step following:
Go to the website: http://www.zktechnology.com
Download ->Software Download->ZK Access for C3 panels
Extract files
Install
Open visual studio -> Solution Project->references-> Add Interop.zkemkeeper.dll
Good luck

How to write into registry using VC++ 2010?

HKEY CURRENT USER \software \microsoft\ windowsNT \CurrentVersion\ AppCompatFlags "application path" = RUNASXP3
I want to create an application which runs in default XP mode on windows 7 when i run the application so, i want to write into the registry as in the link above.
I am building the application in VC++ 2010, i want to write into the above registry through the program, so that when i run the program it runs in XP mode. How to do this..?
Have you had a look at google? It appears the search results cover your question quite well.
For instance:
Working with the Windows Registry in C++
Microsoft Visual C++ Tutorials - Keeping Values in the Registry
Editing Windows Registry - C++
You can also search on Stackoverflow.

Resources