Error when using code inside APP_CODE folder

Posted by Community Admin on 04-Aug-2018 07:11

Error when using code inside APP_CODE folder

All Replies

Posted by Community Admin on 03-Oct-2016 00:00

Hi,

I have problem when using code from app_code folder.

So when i set built action=compile to file SBC.cs then i will get Error    CS0433    The type 'Supplier' exists in both 'SBCNEW, Version=9.1.6110.0, Culture=neutral, PublicKeyToken=null' and '1_App_Code, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'    SBCNEW    D:\Program Files (x86)\Telerik\Sitefinity\Projects\SBCNEW\Module\Product\Admin\Product_Admin.ascx.cs    24

But when i set built action=content to file SBC.cs then i will get "The name 'SBC' does not exist in the current context"

 

I checked, there are two "SBCNEW" projects within the object browser.

I've struggling to discover whats the problem for last few days,

please any suggestions could be usefull for me


These are steps to do my project:
1. I created SF project named "SBCNEW" (with property assemby name="SBCNEW" , Default namespace="SBCNEW")
2. I create Dinamic Module using module Builder for type Supplier
3. I Put some code Class named SBC.cs inside the APP_CODE folder
        -----------
           SBC.cs at glance:

            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Web;
            using Telerik.Sitefinity;
            using Telerik.Sitefinity.Model;
            using Telerik.Sitefinity.DynamicModules;
            using Telerik.Sitefinity.Data.Linq.Dynamic;
            using Telerik.Sitefinity.DynamicModules.Model;
            using Telerik.Sitefinity.GenericContent.Model;
            using Telerik.Sitefinity.Utilities.TypeConverters;
            using Telerik.Sitefinity.Security;
            using Telerik.Sitefinity.Lifecycle;
            using System.Web.UI.WebControls;
            using System.Text.RegularExpressions;
            using Telerik.Sitefinity.Modules.Libraries;
            using System.IO;
            using Telerik.Sitefinity.Taxonomies;
            using Telerik.Sitefinity.Taxonomies.Model;
            
            namespace SBC
            
               public class Supplier
              
                    public static IQueryable<DynamicContent> RetrieveCollectionOfSuppliers()
                    
                        ...
                        return myCollection;
                    
            ...
        ------------
    
4. I create user control named "Product_Admin.ascx.cs" inside Module/Product/Admin

        -----------
           Product_Admin.ascx.cs at glance:

            using System;
            using System.Linq;
            using System.Web.UI.WebControls;
            using System.Collections.Generic;
            using System.Data;
            using Telerik.Web.UI;
            using Telerik.Sitefinity.Model;
            using Telerik.Sitefinity.Modules.Libraries;
            using Telerik.Sitefinity.DynamicModules;
            using Telerik.Sitefinity.DynamicModules.Model;
            using Telerik.Sitefinity.Taxonomies;
            using Telerik.Sitefinity.Taxonomies.Model;
            using Telerik.OpenAccess;

            public partial class Module_Product_Admin_Product_Admin : System.Web.UI.UserControl
            
                protected void Page_Load(object sender, EventArgs e)
                
                    ...
                    var supplierList = SBC.Supplier.RetrieveCollectionOfSuppliers();//here is the error occure
                
            ...
        ------------

Posted by Community Admin on 23-Oct-2017 00:00

I am also getting the same error. Could you suggest the resolution!

Posted by Community Admin on 24-Oct-2017 00:00

Can you try moving your class file to another folder and rename it like ~/SBC/Supplier.cs and then try to compile it - that should work.

This thread is closed