❔ 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
CaptainFallawayOP2y 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
phaseshift2y ago
did you add a project reference? ie what's is shown if you expand "> Dependencies" in the console app in your image
CaptainFallaway
CaptainFallawayOP2y ago
no i have not added a project reference, how i do that?
phaseshift
phaseshift2y ago
what ide are you using?
CaptainFallaway
CaptainFallawayOP2y ago
rider
phaseshift
phaseshift2y ago
its probably in the context menu if right-click on the consoleapp item in the tree
CaptainFallaway
CaptainFallawayOP2y ago
looks to be right but it then failed to load my project
phaseshift
phaseshift2y ago
what 'looks to be right'?
CaptainFallaway
CaptainFallawayOP2y 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
phaseshift2y ago
show the whole csproj never seen that before, though 😅
CaptainFallaway
CaptainFallawayOP2y 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
phaseshift2y ago
I dont think itemgroup is meant to be inside propertygroup
CaptainFallaway
CaptainFallawayOP2y 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
phaseshift2y ago
"it depends"
CaptainFallaway
CaptainFallawayOP2y 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
phaseshift2y ago
then sure, makes sense to have the logic in a separate project
CaptainFallaway
CaptainFallawayOP2y 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
SinFluxx2y ago
$close
MODiX
MODiX2y ago
Use the /close command to mark a forum thread as answered
CaptainFallaway
CaptainFallawayOP2y ago
i cannot do it, either permissions error or the bot was not responding. neither modix or accord $close
MODiX
MODiX2y ago
Use the /close command to mark a forum thread as answered
sibber
sibber2y ago
accord seems to be down
Accord
Accord17mo 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.

Did you find this page helpful?