The type ' ' has no constructors defined C#

AustinGeorge picture AustinGeorge · Jun 13, 2013 · Viewed 7.4k times · Source

I'm trying to call a method from another cs file. I have created the new instance of the class that the method resides in, but get this error:

The type 'SteamKit2.SteamFriends' has no constructors defined

Can anyone help me understand why this is happening?

The class in which i'm trying to call this method from is as follows

using System;
using SteamKit2;
using SteamTrade;
using System.Collections.Generic;
using SteamBot;

namespace SteamBot
{
public class HarvesterHandler : UserHandler
{
    public int FriendCount = 0;
    public int FriendToTrade = 0;
    SteamFriends me = new SteamFriends(); 

    public override void OnLoginCompleted()
    {
        FriendCount = me.GetFriendCount();
        if (FriendToTrade < FriendCount)
        {
            Bot.SteamTrade.Trade(me.GetFriendByIndex(FriendToTrade));
            Log.Info("Sending Trade Request to Friend " + FriendToTrade + " of " + FriendCount);
            return;
        }
        while (true)
        {
            Log.Warn("Finished trading");
        }
    }
}
}

The referred class is as follows (in a separate cs file)

using System.Collections.Generic;
using System.Linq;
using System.Text;
using SteamKit2.Internal;

namespace SteamKit2
{
public sealed partial class SteamFriends : ClientMsgHandler
{
    object listLock = new object();
    List<SteamID> friendList;
    List<SteamID> clanList;

    AccountCache cache;


    internal SteamFriends()
    {
        friendList = new List<SteamID>();
        clanList = new List<SteamID>();

        cache = new AccountCache();
    }
    public int GetFriendCount()
    {
        lock ( listLock )
        {
            return friendList.Count;
        }
    }
    public SteamID GetFriendByIndex( int index )
    {
        lock ( listLock )
        {
            if ( index < 0 || index >= friendList.Count )
                return 0;

            return friendList[ index ];
        }
    }
}
}

Answer

Manuel Amstutz picture Manuel Amstutz · Jun 13, 2013

the constructor is defined as internal. And therefore it is only accessible from the same assembly. Probably this constructor is only intended to be called by a factory? Is SteamFriends realy in the same project as HarvesterHandler?