Declaring object type list in class file giving "missing a using directive or assembly reference” error












0















I am getting the titled error when I declare a list with object type in a class file in my Asp.Net web application. I have other classes running so the class system does work. The same declaration is fine in a webform c# code behind. Any help is appreciated.



using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.Text;

/// <summary>
/// Summary description for TriviaUtilities
/// </summary>
public class TriviaClass
{
public TriviaClass()
{
//
// TODO: Add constructor logic here
//
}

public void getRegistration()
{
List<Activity> sampleREG = new List<Activity>();
}
}


UPDATE: Declaring List<int> sampleREG = new List<int>() or List<string> sampleREG = new List<string>() in the class file poses no problem and this works in a webform also as expected. Declaring the type as an object gives the namespace error in the class file but in the webform it is fine. Since it works on the webform and I have the same namespaces in both the webform and class files, I am suspecting that fixing this is complicated and it needs someone with a higher scope of programming to help with it.










share|improve this question

























  • This doesn’t really help. What’s the full text of the error?

    – stuartd
    Nov 21 '18 at 22:45











  • Maybe you missed including the namespace for your Activity class

    – Quergo
    Nov 21 '18 at 22:46











  • Maybe you need to include any usings for custom classes created within your project

    – Captain Wibble
    Nov 21 '18 at 22:47











  • If the Activity class is defined like this TriviaClass class, then it's in the global namespace. That means it would have to be referenced like global::Activity. But the better solution in that case would be to put your classes inside of a namespace.

    – Rainbolt
    Nov 21 '18 at 22:49






  • 1





    @CaptainWibble Let's just wait for an answer. There's something different about using the class file I suspect.

    – matt2605
    Nov 21 '18 at 23:30
















0















I am getting the titled error when I declare a list with object type in a class file in my Asp.Net web application. I have other classes running so the class system does work. The same declaration is fine in a webform c# code behind. Any help is appreciated.



using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.Text;

/// <summary>
/// Summary description for TriviaUtilities
/// </summary>
public class TriviaClass
{
public TriviaClass()
{
//
// TODO: Add constructor logic here
//
}

public void getRegistration()
{
List<Activity> sampleREG = new List<Activity>();
}
}


UPDATE: Declaring List<int> sampleREG = new List<int>() or List<string> sampleREG = new List<string>() in the class file poses no problem and this works in a webform also as expected. Declaring the type as an object gives the namespace error in the class file but in the webform it is fine. Since it works on the webform and I have the same namespaces in both the webform and class files, I am suspecting that fixing this is complicated and it needs someone with a higher scope of programming to help with it.










share|improve this question

























  • This doesn’t really help. What’s the full text of the error?

    – stuartd
    Nov 21 '18 at 22:45











  • Maybe you missed including the namespace for your Activity class

    – Quergo
    Nov 21 '18 at 22:46











  • Maybe you need to include any usings for custom classes created within your project

    – Captain Wibble
    Nov 21 '18 at 22:47











  • If the Activity class is defined like this TriviaClass class, then it's in the global namespace. That means it would have to be referenced like global::Activity. But the better solution in that case would be to put your classes inside of a namespace.

    – Rainbolt
    Nov 21 '18 at 22:49






  • 1





    @CaptainWibble Let's just wait for an answer. There's something different about using the class file I suspect.

    – matt2605
    Nov 21 '18 at 23:30














0












0








0








I am getting the titled error when I declare a list with object type in a class file in my Asp.Net web application. I have other classes running so the class system does work. The same declaration is fine in a webform c# code behind. Any help is appreciated.



using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.Text;

/// <summary>
/// Summary description for TriviaUtilities
/// </summary>
public class TriviaClass
{
public TriviaClass()
{
//
// TODO: Add constructor logic here
//
}

public void getRegistration()
{
List<Activity> sampleREG = new List<Activity>();
}
}


UPDATE: Declaring List<int> sampleREG = new List<int>() or List<string> sampleREG = new List<string>() in the class file poses no problem and this works in a webform also as expected. Declaring the type as an object gives the namespace error in the class file but in the webform it is fine. Since it works on the webform and I have the same namespaces in both the webform and class files, I am suspecting that fixing this is complicated and it needs someone with a higher scope of programming to help with it.










share|improve this question
















I am getting the titled error when I declare a list with object type in a class file in my Asp.Net web application. I have other classes running so the class system does work. The same declaration is fine in a webform c# code behind. Any help is appreciated.



using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.Text;

/// <summary>
/// Summary description for TriviaUtilities
/// </summary>
public class TriviaClass
{
public TriviaClass()
{
//
// TODO: Add constructor logic here
//
}

public void getRegistration()
{
List<Activity> sampleREG = new List<Activity>();
}
}


UPDATE: Declaring List<int> sampleREG = new List<int>() or List<string> sampleREG = new List<string>() in the class file poses no problem and this works in a webform also as expected. Declaring the type as an object gives the namespace error in the class file but in the webform it is fine. Since it works on the webform and I have the same namespaces in both the webform and class files, I am suspecting that fixing this is complicated and it needs someone with a higher scope of programming to help with it.







c# asp.net list class object






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 22 '18 at 0:06







matt2605

















asked Nov 21 '18 at 22:42









matt2605matt2605

105113




105113













  • This doesn’t really help. What’s the full text of the error?

    – stuartd
    Nov 21 '18 at 22:45











  • Maybe you missed including the namespace for your Activity class

    – Quergo
    Nov 21 '18 at 22:46











  • Maybe you need to include any usings for custom classes created within your project

    – Captain Wibble
    Nov 21 '18 at 22:47











  • If the Activity class is defined like this TriviaClass class, then it's in the global namespace. That means it would have to be referenced like global::Activity. But the better solution in that case would be to put your classes inside of a namespace.

    – Rainbolt
    Nov 21 '18 at 22:49






  • 1





    @CaptainWibble Let's just wait for an answer. There's something different about using the class file I suspect.

    – matt2605
    Nov 21 '18 at 23:30



















  • This doesn’t really help. What’s the full text of the error?

    – stuartd
    Nov 21 '18 at 22:45











  • Maybe you missed including the namespace for your Activity class

    – Quergo
    Nov 21 '18 at 22:46











  • Maybe you need to include any usings for custom classes created within your project

    – Captain Wibble
    Nov 21 '18 at 22:47











  • If the Activity class is defined like this TriviaClass class, then it's in the global namespace. That means it would have to be referenced like global::Activity. But the better solution in that case would be to put your classes inside of a namespace.

    – Rainbolt
    Nov 21 '18 at 22:49






  • 1





    @CaptainWibble Let's just wait for an answer. There's something different about using the class file I suspect.

    – matt2605
    Nov 21 '18 at 23:30

















This doesn’t really help. What’s the full text of the error?

– stuartd
Nov 21 '18 at 22:45





This doesn’t really help. What’s the full text of the error?

– stuartd
Nov 21 '18 at 22:45













Maybe you missed including the namespace for your Activity class

– Quergo
Nov 21 '18 at 22:46





Maybe you missed including the namespace for your Activity class

– Quergo
Nov 21 '18 at 22:46













Maybe you need to include any usings for custom classes created within your project

– Captain Wibble
Nov 21 '18 at 22:47





Maybe you need to include any usings for custom classes created within your project

– Captain Wibble
Nov 21 '18 at 22:47













If the Activity class is defined like this TriviaClass class, then it's in the global namespace. That means it would have to be referenced like global::Activity. But the better solution in that case would be to put your classes inside of a namespace.

– Rainbolt
Nov 21 '18 at 22:49





If the Activity class is defined like this TriviaClass class, then it's in the global namespace. That means it would have to be referenced like global::Activity. But the better solution in that case would be to put your classes inside of a namespace.

– Rainbolt
Nov 21 '18 at 22:49




1




1





@CaptainWibble Let's just wait for an answer. There's something different about using the class file I suspect.

– matt2605
Nov 21 '18 at 23:30





@CaptainWibble Let's just wait for an answer. There's something different about using the class file I suspect.

– matt2605
Nov 21 '18 at 23:30












1 Answer
1






active

oldest

votes


















0














Yes, Rainbolt, Captain Wibble, Quergo. The original use of the object type for the list is in a web page that contains 3000 lines. Buried in there was the Activity class that the IDE was looking for, for the Activity object type of the list.
See here to create a class.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53421447%2fdeclaring-object-type-list-in-class-file-giving-missing-a-using-directive-or-as%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Yes, Rainbolt, Captain Wibble, Quergo. The original use of the object type for the list is in a web page that contains 3000 lines. Buried in there was the Activity class that the IDE was looking for, for the Activity object type of the list.
    See here to create a class.






    share|improve this answer




























      0














      Yes, Rainbolt, Captain Wibble, Quergo. The original use of the object type for the list is in a web page that contains 3000 lines. Buried in there was the Activity class that the IDE was looking for, for the Activity object type of the list.
      See here to create a class.






      share|improve this answer


























        0












        0








        0







        Yes, Rainbolt, Captain Wibble, Quergo. The original use of the object type for the list is in a web page that contains 3000 lines. Buried in there was the Activity class that the IDE was looking for, for the Activity object type of the list.
        See here to create a class.






        share|improve this answer













        Yes, Rainbolt, Captain Wibble, Quergo. The original use of the object type for the list is in a web page that contains 3000 lines. Buried in there was the Activity class that the IDE was looking for, for the Activity object type of the list.
        See here to create a class.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 22 '18 at 8:43









        matt2605matt2605

        105113




        105113
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53421447%2fdeclaring-object-type-list-in-class-file-giving-missing-a-using-directive-or-as%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            這個網誌中的熱門文章

            Xamarin.form Move up view when keyboard appear

            Post-Redirect-Get with Spring WebFlux and Thymeleaf

            Anylogic : not able to use stopDelay()