Xamarin Linking Sdk Assemblies Only - using AssemblyName vs AssemblyName.Class.Method

241 Views Asked by At

I have a DLL MyAssemblyOne.dll which only contains one class with static methods:

namespace MyAssemblyOne 
{
   public class MyClassOne 
   {
      public static string MyStaticMethod()
      {
         ...
      }
   }
} 

All is good so far, the assembly MyAssemblyOne.dll is generated.

Now I have another DLL, MyAssemblyTwo.dll which has a dependency on MyAssemblyOne.dll and uses it like:

    no using here;
    namespace MyAssemblyTwo 
    {
       public class MyClassFromAssemblyTwo 
       {
          public string SomeRandomMethod()
          {
             ...
             var smth = MyAssemblyOne.MyClassOne.MyStaticMethod();
             ...
          }
       }
    }

Now I create a Xamarin project with Linking set to Sdk Assemblies Only and Use Shared Runtime disabled(basically Release mode), and I add my two DLLs - MyAssemblyTwo.dll and MyAssemblyOne.dll. The app builds ok, but when I run it I get something like: cannot find MyAssemblyOne.dll.

Please note that this works if the Linking option is set to None.

However, if I change MyAssemblyTwo usage of MyAssemblyOne to be:

using MyAssemblyOne;

namespace MyAssemblyTwo 
{
   public class MyClassFromAssemblyTwo 
   {
      public string SomeRandomMethod()
      {
         ...
         var smth = MyClassOne.MyStaticMethod();
         ...
      }
   }
}

everything works fine even with the Linking set to Sdk Assemblies Only.

How does the linker work? Why if I have a using statement everything is fine, but if I use the assembly name directly in the code it breaks.

It is worth mentioning that MyAssemblyOne and MyAsseblyTwo are .netstandard20 projects.

0

There are 0 best solutions below