VS2010 直接 右键解决方案 部署 EventHandler。 GAC里面也有相应的DLL了。但是运行程序无效果。
代码如下,不知道代码是否有问题。。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using System.IO;
namespace abc
{
public class TestEventHandle : SPItemEventReceiver
{
public override void ItemAdded(SPItemEventProperties properties)
{
try
{
SaveLog();
}
catch (Exception ex)
{
properties.ErrorMessage = ex.Message;
properties.Cancel = true;
}
}
public void SaveLog()
{
string path = @"c:\Log.txt";
string text = "Item" + ":" + DateTime.Now.ToString();
StreamWriter writer = new StreamWriter(path);
writer.Write(text);
writer.Close();
}
}
}
在List里面添加了一行数据,但并未在C盘生成相应文件。
------解决方案--------------------
1.Feature有没有激活?
2.你是什么类型的Solution,非Farm级的Solution是不能访问本地资源的。
------解决方案--------------------
囧,这个还真没考虑到,应该直接把解决方案截个图给我们看下,立马就知道了,
