---
title: "compilera C#"
type: "forum-thread"
url: "https://www.webforum.nu/amne/dotnet/171452-compilera-c"
topic: ".NET"
topic_url: "https://www.webforum.nu/amne/dotnet"
author: "firstchoice"
published: "2008-05-14T07:40:03.000Z"
updated: "2008-05-14T10:56:02.000Z"
replies: 5
views: 495
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/dotnet/171452-compilera-c"
---

# compilera C#

## #1 — firstchoice, 2008-05-14T07:40Z

Lyckas inte compilera förljande kod

```
using Microsoft.SharePoint;

using System;

namespace test
{

    class TestEventReceiver : SPItemEventReceiver
    {

        public override void ItemUpdated(SPItemEventProperties properties)
        {

            DisableEventFiring(); // in ValidateItem it will fire an event, so disable here

            ValidateItem(properties);

        }

        public override void ItemAdded(SPItemEventProperties properties)
        {

            DisableEventFiring(); // in ValidateItem it will fire an event, so disable here

            ValidateItem(properties);

        }

        protected bool ValidateItem(SPItemEventProperties properties)
        {

            SPSite siteV = null;

            SPWeb webV = null;

            if (properties.ListItemId > 0 && properties.ListId != Guid.Empty)
            {

                try
                {

                    siteV = new SPSite(properties.WebUrl);

                    webV = siteV.OpenWeb();

                    SPList spList = webV.Lists.GetList(properties.ListId, false);

                    SPListItem Item = spList.GetItemById(properties.ListItemId);

                    // The internal number ist stored in _UIVersion

                    //    1 for V0.1

                    //  512 for V1.0

                    //  513 for V1.1

                    // 1024 for V2.0

                    //Item["WSSVNumber"] = Item["_UIVersion"];

                    // I'm using the string value

                    Item["WSSVersion"] = Item["_UIVersionString"];

                    Item.SystemUpdate();

                }

                catch // You will run into an exception in case the Column does not exist
                {

                    // Put your exception code here

                }

            }

            return true;

        }

    }

}
```

får bla. följande felmeddelande:

> Error	1	The type or namespace name 'SharePoint' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)	\\\\Server1\\Users\\Felix\\My Documents\\Visual Studio 2008\\Projects\\FeatureTest.dll\\FeatureTest\\Class1.cs	1	17	FeatureTest

hittar ingen referens till Sharepoint
vad göra?

Permalänk: https://www.webforum.nu/p/171452

## #2 — Zaiman, 2008-05-14T07:57Z

Är det någon PIA som du använder till Sharepoint? I så fall måste den vara installerad där du kompilerar.
Felmeddelandet tyder på att den inte finns under Microsoft.SharePoint iaf..

Permalänk: https://www.webforum.nu/p/2109963

## #3 — firstchoice, 2008-05-14T08:33Z

PIA?

trodde jag skulle kunna göra en dll utan att ha sharepoint på datorn
skall prova att compilera på en server med sharepoint, få se om det går

Permalänk: https://www.webforum.nu/p/2109973

## #4 — Zaiman, 2008-05-14T08:35Z

PIA = Program Interop Assembly (tror jag det heter).

Permalänk: https://www.webforum.nu/p/2109974

## #5 — Zaiman, 2008-05-14T08:41Z

Kollat in denna sida? http://msdn.microsoft.com/sv-se/sharepoint/aa905690(en-us).aspx

Permalänk: https://www.webforum.nu/p/2109977

## #6 — firstchoice, 2008-05-14T10:56Z

löste det genom att kopiera "Microsoft.SharePoint.dll" från SharePoint servern och refererade till denna i VS.
kan inte köra dll'en på datorn, men coplilera går bra

Permalänk: https://www.webforum.nu/p/2110008

---

Tråden på webben: https://www.webforum.nu/amne/dotnet/171452-compilera-c
