Don't understand, want to understand. (Server & Client TCP connection)

Yeah I want to understand whats wrong with the code but I don't, so if someone wants to read this and may be able to fix it. It's supposed be a server that creates the exec on the disk with the IP and port inputted. Here is the error for .NET 7.0: Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Private.Corelib, Version=7 .0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified. Ask anything, tag me any time.
12 Replies
Ꜳåąɐȁặⱥᴀᴬ
that's weird try pasting here the csproj
Xeinٴٴٴٴٴٴٴ
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <OutputType>WinExe</OutputType> <TargetFramework>net7.0-windows7.0</TargetFramework> <Nullable>enable</Nullable> <ImplicitUsings>enable</ImplicitUsings> <UseWPF>true</UseWPF> </PropertyGroup> <ItemGroup> <PackageReference Include="Microsoft.CodeAnalysis" Version="4.8.0" /> <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.8.0" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> </ItemGroup> </Project>
Ꜳåąɐȁặⱥᴀᴬ
you can format code with ```cs instead of just ``` are you sure you have .net sdk installed on every machine you need it?
Xeinٴٴٴٴٴٴٴ
```cs instead of just``` wdym? I have only tried on my pc and I have installed .net 6.0, 7.0, and 8.0. I have tried 7.0 and 8.0
Ꜳåąɐȁặⱥᴀᴬ
like this
using System.Windows;

namespace CtepiaServer;

public partial class MainWindow : Window
{
public MainWindow() => InitializeComponent();

#region UI Handlers
private void GenerateButton_Click(object sender, RoutedEventArgs e)
{
string ipAddress = IpAddressTextBox.Text;
int port = int.Parse(PortTextBox.Text);

var saveFileDialog = new Microsoft.Win32.SaveFileDialog
{
Filter = "Executable Files (*.exe)|*.exe",
DefaultExt = "exe",
FileName = "ClientSideBuilt"
};

bool? dialogResult = saveFileDialog.ShowDialog();

if (dialogResult == true)
{
string outputPath = saveFileDialog.FileName;
ClientCodeGenerator.GenerateAndSaveClientExecutable(ipAddress, port, outputPath);
MessageBox.Show("Client generated successfully at " + outputPath);
}
}
#endregion
}
using System.Windows;

namespace CtepiaServer;

public partial class MainWindow : Window
{
public MainWindow() => InitializeComponent();

#region UI Handlers
private void GenerateButton_Click(object sender, RoutedEventArgs e)
{
string ipAddress = IpAddressTextBox.Text;
int port = int.Parse(PortTextBox.Text);

var saveFileDialog = new Microsoft.Win32.SaveFileDialog
{
Filter = "Executable Files (*.exe)|*.exe",
DefaultExt = "exe",
FileName = "ClientSideBuilt"
};

bool? dialogResult = saveFileDialog.ShowDialog();

if (dialogResult == true)
{
string outputPath = saveFileDialog.FileName;
ClientCodeGenerator.GenerateAndSaveClientExecutable(ipAddress, port, outputPath);
MessageBox.Show("Client generated successfully at " + outputPath);
}
}
#endregion
}
this is probably an issue with dependencies or with compilation, but i never used this for compiling, atm i don't know
Xeinٴٴٴٴٴٴٴ
the error were the same. @dont It worked in memory, I changed it a bit so it ran directly in memory and it worked fine. Any ideas? Do you know anyone that would be good at this?
Ꜳåąɐȁặⱥᴀᴬ
🤷 maybe i would just try to compile an empty Program with no dependencies to see how it goes and then go from that
Xeinٴٴٴٴٴٴٴ
like this?:
return @"
using System;

namespace ClientSide
{
public class Program
{
public static void Main()
{
// Empty Main method
}
}
}";
return @"
using System;

namespace ClientSide
{
public class Program
{
public static void Main()
{
// Empty Main method
}
}
}";
Ꜳåąɐȁặⱥᴀᴬ
essentially yes
Xeinٴٴٴٴٴٴٴ
yeah, I got the same error.
Ꜳåąɐȁặⱥᴀᴬ
are you sure you got all the dependencies right? did you took that from an example? maybe you're missing something
Xeinٴٴٴٴٴٴٴ
for sure. but don't know what

Did you find this page helpful?