Error while compiling project

Asked

Viewed 125 times

1

I am receiving the following message to perform the build in the project.

Error

A namespace cannot directly contain Members such as Fields or methods

Files : Model1.Cs Model1.Context.Cs Line 1 Column 1

You can also view the error by clicking here.

Another thing, I have two hard drives on my machine. Visual Studio is installed on a partition on a different partition of the operating system.

When I add an Entity datamodel to the project it searches the partition C: the Entity DLL reference. Only in the file Model.tt and when compiling the project gives error as it does not find the DLL in the partition path C:.

Does anyone know how to change this reference ?

  • 2

    Can post the code the error is pointing to?

  • So I haven’t even started writing the codes myself. I just created a classlibrary project and added an Entity datamodel

  • @Tarcisiovitor put your code inside a class public class AMinhaClasse { \\ o meu codigo aqui } .

  • @Omni, I’m sorry... I keep switching between the O.R.s and I’m completely confused. Tarcisiovitor, Errors are pointing to two files, Model1.Cs and Mode.Context.Cs. You could put the contents of these files in your question?

1 answer

0


Well, the error message itself already says.

You cannot enter variables or methods outside a class, it hurts the object orientation principle.

Probably your class is too big and you don’t realize you’re trying to insert artifacts out of it. Just make sure that where you are entering is inside the class keys. ( Inside Namespaces, you can enter only classes )

Browser other questions tagged

You are not signed in. Login or sign up in order to post.