SqlClientPermission exception

Posts   
 
    
crashalpha
User
Posts: 3
Joined: 05-Jun-2008
# Posted on: 05-Jun-2008 02:22:11   

We are trying to write a WFC service which leverages an LLBLGen Pro project and are getting a SqlClientPermission-related exception.

Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxx failed

The LLBLGen Pro version is 2.5 Final

As advised by the documentation, we are using the adapter-based modelling.


   // NDA requires that I change names
   DataAccessAdapter adapter = new DataAccessAdapter();
   XyzEntity Xyz = new XyzEntity(12345);
   adapter.FetchEntity(Xyz); // <-- exception here

We are developing in in VS 2008 C#. When we test the service, we use the default ASP.NET Development Server to host the service.

I believe that this is a trust issue (are there trust issues that need to be resolved for LLBLGen-based assemblies for WFC services?) probably having to do with the ASP.NET Development Server and local permissions. The full exception detail is below.

I hope someone recognises this and can help - I am an LLBLGen Pro newbie and would like to get this project moving forward...

Thanks!

Carlo


System.Security.SecurityException was unhandled by user code
  Message="Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."
  Source="mscorlib"
  StackTrace:
       at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)
       at System.Security.PermissionSet.Demand()
       at System.Data.Common.DbConnectionOptions.DemandPermission()
       at System.Data.SqlClient.SqlConnection.PermissionDemand()
       at System.Data.SqlClient.SqlConnectionFactory.PermissionDemand(DbConnection outerConnection)
       at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
       at System.Data.SqlClient.SqlConnection.Open()
       at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.OpenConnection()
       at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.ExecuteSingleRowRetrievalQuery(IRetrievalQuery queryToExecute, IEntityFields2 fieldsToFill, IFieldPersistenceInfo[] fieldsPersistenceInfo)
       at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntityUsingFilter(IEntityFields2 fieldsToFetch, IFieldPersistenceInfo[] persistenceInfos, IRelationPredicateBucket filter)
       at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntityUsingFilter(IEntity2 entityToFetch, IPrefetchPath2 prefetchPath, Context contextToUse, IRelationPredicateBucket filter, ExcludeIncludeFieldsList excludedIncludedFields)
       at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntity(IEntity2 entityToFetch, IPrefetchPath2 prefetchPath, Context contextToUse, ExcludeIncludeFieldsList excludedIncludedFields)
       at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntity(IEntity2 entityToFetch)
       at ERMS.Services.Underwriting.Underwriting.GetDeal(GetDealRequest composite)
       at SyncInvokeGetDeal(Object , Object[] , Object[] )
       at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
  InnerException: 

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 05-Jun-2008 09:57:52   

Did you got the error on you dev machine or when you move to a production server? What are the trust levels at your config? Did you try building your source code with AllowPartiallyTrustedCallers() ?

David Elizondo | LLBLGen Support Team
crashalpha
User
Posts: 3
Joined: 05-Jun-2008
# Posted on: 05-Jun-2008 15:28:41   

Hey, thanks for the interest in my problem!

I'm new to WFC so to be honest, I'm not exactly a genius when it comes to permissions and trust and was hoping to put this all off until MUCH later and concentrate on the business logic right now. When the service DOES go into production, it will run in an environment where it should have full trust for everything (it is an internal service).

daelmo wrote:

Did you got the error on you dev machine or when you move to a production server?

No, we are still running on the development machine - the ASP.NET development server hosts the service - not a specific IIS server.

daelmo wrote:

What are the trust levels at your config?

Do you mean the config of the host server itself (i.e. ASP.NET development server?) If so, I don't know - I can't figure out how one is supposed to configure the instances generated by the ASP.NET development server.

If you mean the web.config of the service, I don't even know where to start to define trust for something as specific as being allowed to even TALK to the SqlClient.

daelmo wrote:

Did you try building your source code with AllowPartiallyTrustedCallers() ?

Sadly, the same answer as above - it sure sounds like even the simplest WCF development (never mind production deployment!) gets you caught up in security, trust and permission issues.

I mean, we have barely written 10 lines of code, and this started with our first attempt to access an LLBLGen entity! disappointed

Carlo

Walaa avatar
Walaa
Support Team
Posts: 14994
Joined: 21-Aug-2005
# Posted on: 05-Jun-2008 16:16:44   
crashalpha
User
Posts: 3
Joined: 05-Jun-2008
# Posted on: 05-Jun-2008 18:10:04   

Walaa wrote:

Please check the following thread: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=655049&SiteID=1

Thanks Walaa - but the problem was found elsewhere. Just for the benefit of anyone else looking I have come back to tell people what happened in our case (threads on this topic always seem to be long and complicated and often ending without resolution):

VSS was checking out to a working folder on a network drive and this raised trust and permission issues. I changed the VSS the working folder to one based on mylocal drive (e.g. C:\VSS...) and it worked. Although this will be problem when we deploy, I'm no longer held up now and can proceed with the LLBLGen programming and business logic.

Thanks for your help!

Carlo