Search Unity

How to load dll file from addressables?

Discussion in 'Addressables' started by NickZhao, Jul 25, 2019.

  1. NickZhao

    NickZhao

    Joined:
    Jun 22, 2018
    Posts:
    5
    Hi,

    I have a dll contains most of my game logic code and I try to use ILRuntime to call the dll. But I found addressables system doesn't support .dll extension. I tried to change .dll to .bytes and build. The result assetbundle is only 2kb(my dll is 177 kb).

    When I try to verify the path using Addressables.LoadResourceLocationsAsync("Hotfix"), it give me the follow error:
    Exception encountered in operation Hotfix:
    UnityEngine.AddressableAssets.Addressables:LoadResourceLocationsAsync(Object, Type)

    Can someone show me the correct process to load a dll from addressables system? Thanks!

    @unity_bill
     
  2. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    1,092
    You can't load a dll from Addressables (asset bundles). Loading a dll from addressables would introduce security issues.
    Addressables are meant for updating assets, not code. If you want to introduce code changes into your game, you'll have to make a new build.
     
    danilonishimura likes this.
  3. NickZhao

    NickZhao

    Joined:
    Jun 22, 2018
    Posts:
    5
    But how other games do code hotfix? I know using Lua or ILRuntime is able to do code hotfix via assetbundle system. I just dont know how to save and load them using addressables system.
     
  4. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    1,092
    You can not do code hotfixes through addressables. When people hotfix something it is a new build with some quick dirty code to fix the issue. Hence hotfix.
     
  5. NickZhao

    NickZhao

    Joined:
    Jun 22, 2018
    Posts:
    5
    Last edited: Jul 27, 2019
  6. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    1,092
    And as that post mentioned by superpig, it is unsupported territory.
    As far as I know dll's don't get packed into bundles, it may have been working in the past but not currently.
    For iOS it is strictly against Apple's rules to update code via remote updates.
    Maybe for the windows platform you can load the dll using the Assembly namespace.
    Also if you do manage to use external dlls for Windows, people can decompile your dll's and read/steal your code. You'd have to obfuscate it in order to make it non-human readable.

    Too much of a hassle if you'd ask me, I rather build a new player build which is only <100mb. All graphical assets are in my addressables (Asset Bundles) on a remote location.
     
    Last edited: Jul 27, 2019
    FlightOfOne and unity_bill like this.
  7. NickZhao

    NickZhao

    Joined:
    Jun 22, 2018
    Posts:
    5
    I don't want to argue about the IOS restriction. Different people have different opinion.

    But I think one thing you are right. Addressables/AssetBundle is not build for dll/code update. I should handle download/update by myself.

    Thanks!