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

Post here your questions about the Unity / .Net / Mono / Windows 8 / Windows Phone 8 API for SFS2X

Moderators: Lapo, Bax

Post Reply
Sparticus
Posts: 227
Joined: 27 Feb 2006, 17:44
Location: Canada
Contact:

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

Post 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!
Sparticus
Posts: 227
Joined: 27 Feb 2006, 17:44
Location: Canada
Contact:

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

Post 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
User avatar
Bax
Site Admin
Posts: 4626
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

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

Post 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).
Paolo Bax
The SmartFoxServer Team
Sparticus
Posts: 227
Joined: 27 Feb 2006, 17:44
Location: Canada
Contact:

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

Post 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>
Sparticus
Posts: 227
Joined: 27 Feb 2006, 17:44
Location: Canada
Contact:

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

Post 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;
User avatar
Bax
Site Admin
Posts: 4626
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

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

Post 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?
Paolo Bax
The SmartFoxServer Team
Sparticus
Posts: 227
Joined: 27 Feb 2006, 17:44
Location: Canada
Contact:

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

Post 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)
User avatar
Bax
Site Admin
Posts: 4626
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

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

Post 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?
Paolo Bax
The SmartFoxServer Team
Sparticus
Posts: 227
Joined: 27 Feb 2006, 17:44
Location: Canada
Contact:

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

Post 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.
User avatar
Bax
Site Admin
Posts: 4626
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

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

Post 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...
Paolo Bax
The SmartFoxServer Team
Sparticus
Posts: 227
Joined: 27 Feb 2006, 17:44
Location: Canada
Contact:

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

Post by Sparticus »

Hey @Bax,

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