CodeSmith Community
Your Code. Your Way. Faster!

Data Source control - ASP.NET Design View problem

Latest post 03-19-2008 7:01 AM by C#Bob. 7 replies.
  • 03-06-2007 9:21 PM

    • dvd
    • Top 100 Contributor
    • Joined on 01-10-2007
    • Posts 48
    • Points 925

    Data Source control - ASP.NET Design View problem

    I have a problem with a simple Data Source control:

    <data:UserDataSource ID="dataUser" runat="server" SelectMethod="GetAll" EnableSorting="true" EnablePaging="true" >

    </data:UserDataSource>

    Works fine, BUT in design view this control does not render  properly: 

    Error Creating Control               -  dataUser

    The type initializer for 'Access2Net.Services.UserServiceBase' threw an exception.

    Data, UI controls are registered in web.config. In fact I'm even getting intellisence when typing SelectMethod in source view. Why I'm getting this exception and how to get rid of it?

    BTW, this is happening with any xxxxxDataSource based on tables. Data Sources based on views render themselves properly in design view.

    • Post Points: 5
  • 03-07-2007 2:15 PM In reply to

    • dvd
    • Top 100 Contributor
    • Joined on 01-10-2007
    • Posts 48
    • Points 925

    Re: Data Source control - ASP.NET Design View problem

    Since nobody replied, I figured out how to debug it and narrowed it down. The following generated line of code (from UserServiceBase.generated.cs) throws the exception:

    private static SecurityContext<User> securityContext = new SecurityContext<User>();

    System.IO.FileLoadException occurred
      Message="Could not load file or assembly 'Microsoft.Practices.EnterpriseLibrary.Security, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Exception from HRESULT: 0x80131052"
      Source="Access2Net.Services"
      FileName="Microsoft.Practices.EnterpriseLibrary.Security, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"
      FusionLog=""
      StackTrace:
           at Access2Net.Services.SecurityContext`1..ctor()
           at Access2Net.Services.UserServiceBase..cctor() in C:\_Projects\Access2Net\App\Access2Net.Services\UserServiceBase.generated.cs:line 77

    'Microsoft.Practices.EnterpriseLibrary.Security.dll is in bin folder and no problems occur at runtime.

    I'm stuck. Any ideas? BTW, I'm using custom role based security provider, configured in web.config, could it be somehow related? 

     

    • Post Points: 5
  • 03-08-2007 10:34 AM In reply to

    • dvd
    • Top 100 Contributor
    • Joined on 01-10-2007
    • Posts 48
    • Points 925

    Re: Data Source control - ASP.NET Design View problem

    up

    • Post Points: 35
  • 03-08-2007 11:27 AM In reply to

    Re: Data Source control - ASP.NET Design View problem

    Well, at Design Time, the control will try and retrieve data, and so if you have authorization turned on, when this call is made, it will try to authorize your machines user.  If you're application can not compiled at that point, or is unable to discover that assembly, then it will not be able to load the assemblies at that time.

    Robert Hinojosa
    -------------------------------------
    Member of the Codesmith Tools, .netTiers, teams
    http://www.nettiers.com
    -------------------------------------
    • Post Points: 60
  • 03-08-2007 1:30 PM In reply to

    • dvd
    • Top 100 Contributor
    • Joined on 01-10-2007
    • Posts 48
    • Points 925

    Re: Data Source control - ASP.NET Design View problem

    To check this, I turned off roleManager and allowed full access:

    <authentication mode="Windows"/>

    <authorization>

    <allow users ="*"/>

    No difference, same exception at design time.

    Application compiles, no problems here. As for "unable to discover Microsoft.Practices.EnterpriseLibrary.Security.dll" - well, it's in the bin folder. What other reasons Visual Studio can have for not loading this assembly? And also, I mentioned already that view-based DataSource components do not produce this problem, only table-based ones. Obviousely there is some difference in their loading behavior that could give me some cues. Maybe somebody can point to those differences?

    • Post Points: 5
  • 03-08-2007 2:36 PM In reply to

    • dvd
    • Top 100 Contributor
    • Joined on 01-10-2007
    • Posts 48
    • Points 925

    Re: Data Source control - ASP.NET Design View problem

    I have just generated a clean solution in separate folder. Nothing custom. And the same effect when trying to place DataSource control on the Default.aspx:

    <data:UserDataSource ID="qqq" runat="server" SelectMethod="GetAll"/>

    Error Creating Control               -  qqq

    The type initializer for 'TestDB.Services.UserServiceBase' threw an exception.

    EntityDataSource and view-based DataSource controls do not throw exceptions on the same page. What the hell is going on??? Crying 

    • Post Points: 35
  • 03-18-2008 7:14 AM In reply to

    • C#Bob
    • Not Ranked
    • Joined on 01-03-2006
    • Knoxville, TN
    • Posts 8
    • Points 100

    Re: Data Source control - ASP.NET Design View problem

    I feel your pain. Have you found anything yet.Angry

    Sincerely, C#BOB
    • Post Points: 5
  • 03-19-2008 7:01 AM In reply to

    • C#Bob
    • Not Ranked
    • Joined on 01-03-2006
    • Knoxville, TN
    • Posts 8
    • Points 100

    Party!!! [<:o)] Re: Data Source control - ASP.NET Design View problem

    I am using VS2008, and ALL generated DataSource Controls in design view say: "Error Creating Control ..." 

    I found a fix: Here

    In DataRepository,  GetDesignTimeConfig, change

    EnvDTE80.DTE2 dte = (EnvDTE80.DTE2) System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE.8.0");

    to

    EnvDTE80.DTE2 dte = (EnvDTE80.DTE2) System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE.9.0");


    Now, to fix the EntityGridView, you have to but a try catch around the OnInit and OnSorting events in the EntityGridView.cs.

     

    Sincerely, C#BOB
    • Post Points: 5
Page 1 of 1 (8 items) | RSS
Copyright © 2008 CodeSmith Tools, LLC
Powered by Community Server (Commercial Edition), by Telligent Systems