Results 1 to 4 of 4

Thread: Running Application From Network Drive

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2007
    Posts
    97

    Running Application From Network Drive

    Need help from the guru's out there,

    I am trying to run a .net application from a network drive, the application starts up fine but as soon as the application accesses SQL Server for data I get the following error.

    System.Exception: System.Security.SecurityException: Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
    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()
    ......etc

    The application works fine on my local computer and also runs fine when running directly from the machine hosting the network share folder. The only time it won't work is if I try to run the app accross the network (Shortcut to exe file stored on mapped drive) and try to access the database.

    I'm currently running SQL Server 2005 on sbs server 2003, visual studio 2008, vb.net framework 2.0

    I have tried the following links and multiple other links but still no success. Also tried the "Caspol.exe" links. but with no success.
    http://weblogs.sqlteam.com/jhermiz/a.../14/60284.aspx

    If someone has solved this problem before please help.


    Thanks in advance.
    Last edited by Developer2007; Oct 13th, 2008 at 09:11 PM.

  2. #2
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Running Application From Network Drive

    Hey,

    From what I understand when you run an application, the .Net Framework decides what code group the assembly should run in based on the evidence that is provided to it, and based on that, your assembly is assigned a permission set. It looks like your assembly is being assigned a permission set which does not include the SqlClientPermission, and as a result, it is not able to execute the commands within your application.

    In order to give your assembly more permissions, you need to change the evidence associated with your assembly, and one way of doing this, as described in the link that you provided, is to provide a strong name for your assembly.

    Have you done this?

    I would have thought after doing this that it should have worked.

    Gary

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2007
    Posts
    97

    Re: Running Application From Network Drive

    thanks for the quick reply,

    I tried the two methods listed on that link to the best of my knowledge but by the sounds of things I didn't implement them correctly.

    when I tried to add this line to the assembly

    <Assembly: AssemblyKeyFile("\\ServerName\MyFolder\mykey.snk")>

    It was underlined in green and I get this warning message.

    Use command-line option '/keyfile' or appropriate project settings instead of 'System.Reflection.AssemblyKeyFileAttribute'.

    The application still built fine tho. So I must have went wrong somewhere.

    So I tried adding this in the Project ---> properties --> signing. But still no luck.

    Can you point me in the right direction.
    Last edited by Developer2007; Oct 13th, 2008 at 09:47 PM.

  4. #4

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width