Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by PommPoirAbricot · Jun 18, 2013 at 10:25 AM · reflectionassemblycompilationsmartfoxserver2x

FileNotFoundException (System.reflection) when using SmarFox2.dll

Hi everyone I compiled scripts via monoruntime and i got automatically their referenced assemblies (the 'usings') and its work but when i am using "Using Sfs2X" i got FileNotFoundException

I have only one library (SmartFoxServer2.dll) and it is driving me crazy. I am using in Unity 4.0 the "smartfox2.dll" which is in a folder named "Plugins". I am working with visual studio 2010. I can use it in my C# script :

 public class ThisIsMyClass : MonoBehaviour
 {
     Sfs2X.SmartFox _smartFoxSession = null;//This causes an exception
     [...]
 }


And in another script in charge to compile "ThisIsMyClass.cs" into "ThisIsMyClass.dll" :

 public class CompileTheseScripts : MonoBehaviour
 {
     List<string> locationsOfAssemblies = new List<string>();
     void OnGUI()
     {
         if (GUILayout.Button("Compile")) { Compilation(); }
         [...]
     }    
     void Compilation()
     {
         //Get the referenced assemblies in the given type 
         locationsOfAssemblies.AddRange(GetReferencesAssembliesPaths(typeof(ThisIsMyClass)));
         [...]        
     }    
     public static IEnumerable<string> GetReferencesAssembliesPaths(Type type)
     {
         AssemblyName[] asns = type.Assembly.GetReferencedAssemblies();
         foreach (AssemblyName an in asns)
         {
             yield return Assembly.ReflectionOnlyLoad(an.FullName).Location;
             //This instruction causes the FileNotFoundException 
             //when using Sfs2X in ThisIsMyClass.cs
         }
     }
 }

This is the Exception i got when using Sfs2X in ThisIsMyClass.cs :

FileNotFoundException: Could not load file or assembly 'SmartFox2, Version=0.9.4.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

This is the SmartFox2.dll view:

 #region Assembly SmartFox2.dll, v2.0.50727
 // C:\Users\usrlocal\Desktop\shell\Assets\Plugins\SmartFox2.dll
 #endregion    
 using Sfs2X.Bitswarm;
 using Sfs2X.Core;
 using Sfs2X.Entities;
 using Sfs2X.Entities.Managers;
 using Sfs2X.Logging;
 using Sfs2X.Requests;
 using Sfs2X.Util;
 using System;
 using System.Collections.Generic;    
 namespace Sfs2X
 {
     public class SmartFox : IDispatchable
     {
         public SmartFox();
         public SmartFox(bool debug);    
         public IBuddyManager BuddyManager { get; }
         public int CompressionThreshold { get; }
         public ConfigData Config { get; }
         [...]
     }    
 }

Is someone have an idea of how to solve this exception please ?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by PommPoirAbricot · Jun 18, 2013 at 12:42 PM

For those having a similar problem i finally find another way :

 public static IEnumerable<string> GetReferencesAssembliesPaths1(Type type)
 {
     AssemblyName[] asns = type.Assembly.GetReferencedAssemblies();
     AppDomain domain;
     foreach (AssemblyName an in asns)
     {
         domain = AppDomain.CurrentDomain;
         yield return domain.Load(an.FullName).Location;
     }
 }

Instead of that:

  public static IEnumerable<string> GetReferencesAssembliesPaths(Type type)
  {
      AssemblyName[] asns = type.Assembly.GetReferencedAssemblies();
      foreach (AssemblyName an in asns)
      {
         yield return Assembly.ReflectionOnlyLoad(an.FullName).Location;
      }
  }
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

14 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Reflection on Unity class 1 Answer

How can I get more information about this error: "The classes in the module cannot be loaded"? 1 Answer

Loading Script from Asset Bundle in iOS and WebGL. 2 Answers

Are Assembly definition files are not build system files? 1 Answer

How does Unity call Update() etc without override or reflection? 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges