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??
Who is Participating?
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.

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!
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Shaun KlineLead Software EngineerCommented:
What about the Microsoft.SharePoint.Sandbox DLL? Your error message is complaining about it.
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:
Found my own solution
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.