Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 尝试通过LINQ到SQL访问数据时导致WCF服务安全异常_C#_Wcf_Security_Service - Fatal编程技术网

C# 尝试通过LINQ到SQL访问数据时导致WCF服务安全异常

C# 尝试通过LINQ到SQL访问数据时导致WCF服务安全异常,c#,wcf,security,service,C#,Wcf,Security,Service,我目前正在学习WCF,因为它们提供的一些概念和功能看起来很有趣,在我正在进行的项目中也很有用 到目前为止,我一直在遵循一些非常简单的指南来掌握它的窍门,但在创建第一个主机服务之后,我有点不顺利,在尝试从SQL数据库检索一些数据并在使用LINQ to SQL时收到以下错误: Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Cult

我目前正在学习WCF,因为它们提供的一些概念和功能看起来很有趣,在我正在进行的项目中也很有用

到目前为止,我一直在遵循一些非常简单的指南来掌握它的窍门,但在创建第一个主机服务之后,我有点不顺利,在尝试从SQL数据库检索一些数据并在使用LINQ to SQL时收到以下错误:

Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
我环顾四周,看到了一些关于如何修复此问题的建议,但由于我正在创建一个纯粹用于测试的简单WCF服务库,这些建议似乎是适用的

代码将在以下行中跳转:

me = aDb.Messages.ToList();
项目本身保存在远程驱动器上,但当我运行以调试时,它是在本地运行的,然而,数据库是一个位于远程的测试服务器。所有SQL凭据都是正确的,因为连接测试成功,我已经检查了连接字符串。最后,该服务是作为一个基本的运行在下面你可以看到我的所有代码,所以如果你有任何想法,我可以停止错误,将不胜感激

namespace AnnouncementServiceLibrary
{
    [ServiceContract]
    public interface IConnect
    {
        [OperationContract]
        List<Mess> ConnectUser(string userId);
    }
}

namespace AnnouncementServiceLibrary
{
    public class AnnounceService : IAnnounceService
    {
#region IConnect Members

        public List<Mess> ConnectUser(string userId)
        {
                List<Mess> mess = new List<Mess>();
                List<Message> me;
                List<MessageLink> messLink;

                AnnouncementDBDataContext aDb = new AnnouncementDBDataContext();

                me = aDb.Messages.ToList();
                messLink = aDb.MessageLinks.ToList();

                var result = (from a in messLink
                              join b in me
                                  on a.UniqueID equals b.UniqueID
                              where a.UserID == userId
                              select new { b.UniqueID, b.Author, b.Title, b.Body, b.Priority, a.Read, b.TimeRecieved }).
                    DefaultIfEmpty();

                foreach (var a in result)
                {
                    mess.Add(new Mess(a.UniqueID, a.Author, a.Title, a.Body, a.Priority, (bool)a.Read, a.TimeRecieved));
                }
                return mess;
        }
        #endregion
    }
}

这可能与您的应用程序是从网络共享构建的这一事实有关。看看这个:

谢谢,我没看到那个,请给我介绍一下。