❔ Cannot import another project

The image is the file structure of the solution. I'm trying to use the PasswordMangerLibrary. But it isn't letting me. Program.cs:
using PasswordManagerLibrary;

namespace PasswordManagerConsoleApp
{
static class Program
{
public static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
using PasswordManagerLibrary;

namespace PasswordManagerConsoleApp
{
static class Program
{
public static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
Manager.cs:
namespace PasswordManagerLibrary
{
public class Manager
{
public static void Trying()
{
Console.WriteLine("Works!");
}
}
}
namespace PasswordManagerLibrary
{
public class Manager
{
public static void Trying()
{
Console.WriteLine("Works!");
}
}
}
I feel like this is something really easy to fix but keep in mind i have a fever and i'm not fully operational 😅 .
23 Replies
CaptainFallaway
CaptainFallawayOP16mo ago
the compiler is giving me "CS0246" if that gives any info The type or namespace name 'PasswordManagerLibrary' could not be found (are you missing a using directive or an assembly reference?)
phaseshift
phaseshift16mo ago
did you add a project reference? ie what's is shown if you expand "> Dependencies" in the console app in your image
CaptainFallaway
CaptainFallawayOP16mo ago
no i have not added a project reference, how i do that?
phaseshift
phaseshift16mo ago
what ide are you using?
CaptainFallaway
CaptainFallawayOP16mo ago
rider
phaseshift
phaseshift16mo ago
its probably in the context menu if right-click on the consoleapp item in the tree
CaptainFallaway
CaptainFallawayOP16mo ago
looks to be right but it then failed to load my project
phaseshift
phaseshift16mo ago
what 'looks to be right'?
CaptainFallaway
CaptainFallawayOP16mo ago
gave me this C:\Users\Alexander\Documents\Programming-git\csharp\PasswordManager\PasswordManager\PasswordManager.csproj at (9:5) That i added the project reference when doing the context menu on dependencies is says that this csproj code is not allowed
<ItemGroup>
<ProjectReference Include="..\PasswordManagerLib\PasswordManagerLib.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PasswordManagerLib\PasswordManagerLib.csproj" />
</ItemGroup>
[MSB4004] The "ItemGroup" property is reserved, and cannot be modified.
phaseshift
phaseshift16mo ago
show the whole csproj never seen that before, though 😅
CaptainFallaway
CaptainFallawayOP16mo ago
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>PasswordManagerConsoleApp</RootNamespace>
<ItemGroup>
<ProjectReference Include="..\PasswordManagerLib\PasswordManagerLib.csproj" />
</ItemGroup>

</PropertyGroup>




</Project>
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>PasswordManagerConsoleApp</RootNamespace>
<ItemGroup>
<ProjectReference Include="..\PasswordManagerLib\PasswordManagerLib.csproj" />
</ItemGroup>

</PropertyGroup>




</Project>
that's off the PasswordManagerConsoleApp though i did some stuff after i posted this But the main question is here, should i import another project or is it just better to have a normal directory within the main project??? what would be more of the "correct approach"
phaseshift
phaseshift16mo ago
I dont think itemgroup is meant to be inside propertygroup
CaptainFallaway
CaptainFallawayOP16mo ago
that's what the context menu thingy did, not me but imma try moving it either way that seems to work nice! but still do you know the answer to the question I wrote before? This question
phaseshift
phaseshift16mo ago
"it depends"
CaptainFallaway
CaptainFallawayOP16mo ago
my case for thinking like this is that i want to make a Console version and a GUI version and i want the Manager to be one thing that both use
phaseshift
phaseshift16mo ago
then sure, makes sense to have the logic in a separate project
CaptainFallaway
CaptainFallawayOP16mo ago
well so everything seems to be working now, it's compiling and Program.cs is calling the Trying function with success does this whole post get deleted or it it saved? Thanks alot for the help tho! 👍
SinFluxx
SinFluxx16mo ago
$close
MODiX
MODiX16mo ago
Use the /close command to mark a forum thread as answered
CaptainFallaway
CaptainFallawayOP16mo ago
i cannot do it, either permissions error or the bot was not responding. neither modix or accord $close
MODiX
MODiX16mo ago
Use the /close command to mark a forum thread as answered
sibber
sibber16mo ago
accord seems to be down
Accord
Accord16mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server