Page 1 of 1

The type or namespace name 'Sfs2X' could not be found

Posted: 09 Jul 2023, 23:18
by Sparticus
Hello,

I am trying to add SFS2X to my Unity project. I downloaded the c# client api. I tossed the debug dll in my Assets/Plugins/SFS2X folder.

When I open the code in vscode, it says :

Code: Select all

The type or namespace name 'Sfs2X' could not be found
https://imgur.com/a/UrnTG7o

How do I tell vscode about the dll so it recognized the sfs code?

thanks!

Re: The type or namespace name 'Sfs2X' could not be found

Posted: 10 Jul 2023, 00:58
by Sparticus
More info....

I only copied the debug dll into my project (I assume I replace the debug with the release version later?)

In Unity, clicking on the dll, I selected these settings and applied them :

https://pasteboard.co/6YG8zzgqryLy.png

Re: The type or namespace name 'Sfs2X' could not be found

Posted: 10 Jul 2023, 07:00
by Bax
We have seen this happen sometimes, not only with the SmartFox DLL, but also other DLLs.
When this happens, usually stopping Unity, deleting the .sln file and obj folder does the trick and fixes the issue.

About the DLL settings, you can also select "Ant platforms" if you wish, and then exclude WebGL (for which you need the separate DLL).

Re: The type or namespace name 'Sfs2X' could not be found

Posted: 10 Jul 2023, 13:15
by Sparticus
Ok, after doing what you suggested, I now get this error :

Error: Could not load signature of Controller:OnConnection due to: Could not load file or assembly 'SmartFox2X, Version=1.8.1.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. assembly:SmartFox2X, Version=1.8.1.0, Culture=neutral, PublicKeyToken=null type:<unknown type> member:(null) signature:<none>

Re: The type or namespace name 'Sfs2X' could not be found

Posted: 10 Jul 2023, 13:23
by Sparticus
Also, just a suggestion, I wish your documentation included the "includes" or "using" lines of code so we could see what you were importing to get the code to work.

I downloaded the "connector" project to find the code... which is what I have below. Let me know if that's not correct :

Code: Select all

using Sfs2X;
using Sfs2X.Core;
using Sfs2X.Logging;
using Sfs2X.Requests;
using Sfs2X.Util;

Re: The type or namespace name 'Sfs2X' could not be found

Posted: 10 Jul 2023, 14:08
by Bax
Is the error you reported thrown by your project, or by our connector example?
After following our advice and restarting Unity, did it rebuild the .sln file?

Re: The type or namespace name 'Sfs2X' could not be found

Posted: 10 Jul 2023, 14:39
by Sparticus
Yes, it rebuilt the .sln file.

I didn't try the connector project as it requires a newer version of unity so I cannot run it.

(I am currently using Unity version 2020.3.38f1)

Re: The type or namespace name 'Sfs2X' could not be found

Posted: 10 Jul 2023, 14:51
by Bax
With the Unity Hub you can install multiple copies of Unity side by side if you like.
Anyway, dod you try recreating your project from scratch?

Re: The type or namespace name 'Sfs2X' could not be found

Posted: 10 Jul 2023, 15:00
by Sparticus
Ya, I know. Was hoping to not have to install another version of Unity (which is a few gigs) to test that just to have to delete the unity version later.

Not quite sure what you mean by 'recreate my project from scratch'. I'm adding SFS to an existing game I have in the app stores.

Anyways, I appreciate your help. Clearly it's something odd on my end I need to figure out.

Re: The type or namespace name 'Sfs2X' could not be found

Posted: 10 Jul 2023, 15:05
by Bax
Maybe you can remove the DLL and references from your project, close and reopen Unity, and add the DLL again.
I've seen this kind of behavior in Unity for years unfortunately...

Re: The type or namespace name 'Sfs2X' could not be found

Posted: 11 Jul 2023, 03:02
by Sparticus
Hey @Bax,

I tried removing everything and re-adding it, and it magically worked. Weird, thanks!