Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Problem kod kompajliranja iz command linea

[es] :: .NET :: Problem kod kompajliranja iz command linea

[ Pregleda: 262 | Odgovora: 1 ]

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

artriba
Split

Član broj: 158342
Poruke: 109
*.adsl.net.t-com.hr.



Profil

icon Problem kod kompajliranja iz command linea16.01.2008. u 10:52

Imam dva fajla
Program.cs...
Code:
using System;
namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            Class1 obj = new Class1();
            obj.Write();
        }
    }
}

i Class1.cs...
Code:
using System;
namespace Test
{
    class Class1
    {
        public void Write()
        {
            Console.WriteLine("Some shit I wrote");
        }
    }
}

kad ih želim kompajlirat preko command linea dobijem ove greške
Code:
Setting environment for using Microsoft Visual Studio 2008 x86 tools.

C:\Windows\system32>cd c:\

c:\>csc /t:library Class1.cs
Microsoft (R) Visual C# 2008 Compiler version 3.5.21022.8
for Microsoft (R) .NET Framework version 3.5
Copyright (C) Microsoft Corporation. All rights reserved.


c:\>csc /r:Class1.dll Program.cs
Microsoft (R) Visual C# 2008 Compiler version 3.5.21022.8
for Microsoft (R) .NET Framework version 3.5
Copyright (C) Microsoft Corporation. All rights reserved.

Program.cs(8,13): error CS0122: 'Test.Class1' is inaccessible due to its
        protection level
Program.cs(8,30): error CS0122: 'Test.Class1' is inaccessible due to its
        protection level
Program.cs(8,26): error CS0143: The type 'Test.Class1' has no constructors
        defined
Program.cs(9,17): error CS1061: 'Test.Class1' does not contain a definition for
        'Write' and no extension method 'Write' accepting a first argument of
        type 'Test.Class1' could be found (are you missing a using directive or
        an assembly reference?)

c:\>
16.01.2008. u 10:52 

mmix
Miljan Mitrovic
Software Architect
Pancevo, Srbija

Moderator
Član broj: 17944
Poruke: 1600
195.252.78.*



Profil

icon Re: Problem kod kompajliranja iz command linea16.01.2008. u 11:49
Kao sto ti greske i kazu:

1. Da bi Program.Main video klasu Test.class1 moras da je deklarises kao public ili internal
2. Da bi mogao da instanciras Class1 ta klasa mora da ima public konstruktor:

Code:

using System;
namespace Test
{
    public class Class1
    {
        public Class1() {}
        public void Write()
        {
            Console.WriteLine("Some shit I wrote");
        }
    }
}

▪ The word 'politics' is derived from the word 'poly', meaning 'many', and the word 'ticks', meaning 'blood sucking parasites' - Larry Hardiman
▪ If the good guy gets the girl, it's rated PG; if the bad guy gets the girl, it's rated R; and if everybody gets the girl, it's rated X
▪ Illegal aliens have always been a problem in the United States. Ask any Native American
16.01.2008. u 11:49 

[es] :: .NET :: Problem kod kompajliranja iz command linea

[ Pregleda: 262 | Odgovora: 1 ]

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.