Skip to content

'Assembly with type "....ActionService" is not loaded' #7

@miki-bgd

Description

@miki-bgd

Hello, i have tried to create sample solution, but it crashes on this line...
var service = await factory.CreateInstanceAsync<ActionService, IActionService>();

image

internal class Client
{
	private static bool running;

	static void Main(string[] args)
	{
		Run();
		running = true;
		int counter = 0;
		while (running)
		{
			Thread.Sleep(1000);
			Console.WriteLine("Client ping " + counter++);
		}
	}

	static async void Run()
	{
		await using var factory = new PipeProxyFactory();

		await factory.InitializeAsync(Constants.PipeName);

		var service = await factory.CreateInstanceAsync<ActionService, IActionService>();

		while (running)
		{
			await Task.Delay(1000);
			service.MessageReceived += (_, e) => Console.WriteLine($"Client: message received on server" + e);

			service.SendMessage("Hello from Client");

			string processName = service.GetProcessId();

			Console.WriteLine("Client: Server process name: " + processName);
		}
	}
}
using System;
using H.ProxyFactory;
using RemoteNamedPipe.Shared;

namespace RemoteNamedPipe.Server 
{
	internal class Server
	{
		private static bool running;
		private static PipeProxyServer server;
		static void Main(string[] args)
		{
			Run();
			running = true;
			int counter = 0;
			while (running)
			{
				Thread.Sleep(1000);
				Console.WriteLine("Server ping " + counter++);
			}
		}

		static async void Run()
		{
			server = new PipeProxyServer();

			await server.InitializeAsync(Constants.PipeName);
		}
	}
}
public interface IActionService
{
	event EventHandler<string> MessageReceived;

	void SendMessage(string message);

	void CloseProcess();

	string GetProcessId();
}
public class ActionService : IActionService
{
	public event EventHandler<string> MessageReceived;

	public void CloseProcess()
	{

	}

	public string GetProcessId()
	{
		return Process.GetCurrentProcess().ProcessName;
	}

	public void SendMessage(string message)
	{
		Console.WriteLine("Server: Message received " + message);
		MessageReceived?.Invoke(this, message);
	}
}

And here is Project structure. Client and Server reference Shared project, and both are started as independent processes.
image

Am i missing something?
Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions