2

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.

Federico Navarrete
  • 3,069
  • 5
  • 41
  • 76
Bogdan Daniel
  • 2,689
  • 11
  • 43
  • 76
  • I test it on my side, use the same configuration as you said, but can'y reproduce this issue. Could you please delete bin and obj folder in your solution and try again? – York Shen Oct 23 '18 at 05:31
  • @YorkShen-MSFT I'm pretty sure that I've tried that. I will create a new app and test it again, but it should fail. I'll get back to you once its done. – Bogdan Daniel Oct 23 '18 at 05:38
  • 1
    @YorkShen-MSFT (Unfortunately) you are correct. The problem started first with a wrong Assembly name which I fixed. After that I do not remember deleting the `bin` and `obj` folders for some time(I was just rebuilding the project), and maybe when I wrote the `using` statement I deleted them and it was just a coincidence that it worked. I ll just leave the question here for some time in case someone encounters the same problem, but for now, I cannot reproduce it. – Bogdan Daniel Oct 23 '18 at 07:14

0 Answers0