• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1500
  • Last Modified:

unable to create asp.net application referencing microsoft.sharepoint

Hi experts,
I need to create an ASP.NET application to read and write SharePoint lists.
I can do it with an executable but I've failed to do it with asp.net.
I start a new asp.net project, just write "Hello world" in a div, add a reference to Microsoft.Sharepoint.
When I start the apps I get the following message:
Could not load file or assembly 'Microsoft.Sharepoint.Sandbox, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. An attempt was made to load a program with an incorrect format.

This message normaly says something about a wrong target CPU for one of the Dlls, I've tried every CPU with no success.

I'm using VS 2010 on SharePoint Enterprise 2010, I am SharePoint farm admin.
I develop locally on the server itself.

Any ideas, how to resolve that problem??
1 Solution
Ramkisan JagtapLead DeveloperCommented:
Please check the with Sharepoint DLL, please add it as a reference to your project.
hqdevAuthor Commented:
Has I said in my message, I already have the sharepoint dll for reference and that's what is causing the problem!
Shaun KlineLead Software EngineerCommented:
What about the Microsoft.SharePoint.Sandbox DLL? Your error message is complaining about it.
Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

hqdevAuthor Commented:
There's no such thing as a sharepoint.sandbox dll, it is part of sharepoint.dll.
To use the sharepoint dll you need to target the .net framework 3.5 the sharepoint dll does not work with the framework 4
May be this is your problem.
hqdevAuthor Commented:
My app is 3.5, I knew about the framework issue
hqdevAuthor Commented:
Finnaly I found that we have to use the SharePoint client object model.
So using microsoft.sharepoint.client instead of microsoft.sharepoint and changinf the code did the trick.
The coding is significatly different but it work well.

hqdevAuthor Commented:
Found my own solution

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now