Page 1 of 1
Dotnet .dll is using UnityEngine
Posted: 30 Sep 2025, 10:10
by PanagiotisMilios
I'm trying to use sfs client c# api inside a c# .net web api and it seems that inside the namespace Sfs2X.Logging there is a UnityEngine dependency. Is there not supposed to be a separate .dll or is that an error?
https://prnt.sc/KplDaR7ffffP
Re: Dotnet .dll is using UnityEngine
Posted: 30 Sep 2025, 10:41
by Bax
Hello.
This is not expected.
What version of the SFS2X C# API are you using?
How do you trigger the error?
We tested with the very minimal example below, in which we forcefully call the internal logger, and everything works as expected without issues:
Code: Select all
using Sfs2X;
using Sfs2X.Core;
SmartFox sfs = new SmartFox(true);
sfs.ThreadSafeMode = false;
sfs.AddEventListener(SFSEvent.CONNECTION, OnConnection);
sfs.Connect("127.0.0.1", 9933);
Console.ReadKey();
void OnConnection(BaseEvent evt)
{
if ((bool)evt.Params["success"])
{
// Console.WriteLine("Connection was established");
sfs.Logger.Info("Connection was established");
}
else
{
// Console.WriteLine("Connection failed");
sfs.Logger.Error("Connection failed");
}
}
Re: Dotnet .dll is using UnityEngine
Posted: 30 Sep 2025, 10:48
by PanagiotisMilios
I'm using version 1.8.4. I chose to add the .dll from inside SFS2X_API_CSharp_v1.8.4\Release\DotNet directory.
It might be a forgotten reference perhaps inside the Logging namespace because i build a small assembly named Unityengine as shown below, i added it in my project as an assembly reference and now it doesn't crash.
Code: Select all
using System;
namespace UnityEngine
{
public static class Debug
{
public static void Log(object message) => System.Console.WriteLine(message);
public static void LogWarning(object message) => System.Console.WriteLine("[WARN] " + message);
public static void LogError(object message) => System.Console.Error.WriteLine("[ERROR] " + message);
}
}
Re: Dotnet .dll is using UnityEngine
Posted: 30 Sep 2025, 11:01
by PanagiotisMilios
The error is triggered upon starting the api and never runs. Also Smartfox console logs my user as type Unity.
15:11:47,280 INFO [SFSWorker:Ext:4] api.SFSApi - User login: { Zone: Test }, ( User Name: Web-api-server, Id: 3, Priv: 0, Sess: 127.0.0.1:51105 ) , Type: Unity
Re: Dotnet .dll is using UnityEngine
Posted: 30 Sep 2025, 11:54
by Bax
It looks like the issue is in the Release dll only. Our previous test was with the Debug dll.
Not sure how this happened. I guess we didn't rebuild the release dll after the fix.
We will now fix this and let you know as soon as the updated API is available.
Thank you for reporting.
Re: Dotnet .dll is using UnityEngine
Posted: 30 Sep 2025, 14:57
by Bax
The new API version (1.8.5) that fixes the reported issue in now online:
https://www.smartfoxserver.com/download/sfs2x#p=client
Re: Dotnet .dll is using UnityEngine
Posted: 30 Sep 2025, 16:22
by PanagiotisMilios
Great, thanks a lot for the fast response!