Comments (8)
Because isomorphic method signatures are combined, It's common that you find nothing about async methods.
Do you have use HybridCLR.RuntimeApi.LoadMetadataForAOTAssembly
to load 'mscorlib.dll' for patching aot metadata? You can read this article .
make sure you:
- install latest com.focus-creative-games.hybridclr_unity(version >= 0.8.0) in github
- install latest hybridclr c++ codes by latest hybridclr_unity
- use
HybridCLR.RuntimeApi.LoadMetadataForAOTAssembly
to load 'mscorlib.dll' 。 'mscorlib.dll' must be stripped aot assembly that was generated during building. - properly config
HybridCLR/Settings
- run
HybridCLR/Generate/All
before build.
from hybridclr.
I have tried following everything, as listed in the doc. I have only slightly modified the project.
I added a new class which I am trying to HotUpdate
public static class AppLoader {
public static async void Init() {
await LoadGame();
}
static async Task LoadGame() {
Debug.Log("Load Game Called");
//Load the Scenes
var sceneAb = await LoadDll.GetStreamingAssetBundle("prefabs");
string[] scenePaths = sceneAb.GetAllScenePaths();
foreach (var s in scenePaths)
Debug.Log($"Scene: {s}");
SceneManager.LoadScene("MyScene");
}
And I call into it from the LoadDll.cs in the StartGame
async void StartGame()
{
Debug.Log("Start Game Called");
await LoadMetadataForAOTAssemblies();
Debug.Log("Loading ASsembly: Assembly-CSharp");
var gameAss = await GetAssembly("Assembly-CSharp.dll");
var appType = gameAss.GetType("AppLoader");
Debug.Log($"AppLoader Loaded: {appType != null}");
var mainMethod = appType.GetMethod("Init");
Debug.Log($"Init Method Loaded: {mainMethod != null}");
mainMethod.Invoke(null, null);
}
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:Log(Object)
<DownLoadAssets>d__11:MoveNext()
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
Start Game Called
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:Log(Object)
<StartGame>d__12:MoveNext()
System.Runtime.CompilerServices.AsyncVoidMethodBuilder:Start(TStateMachine&)
LoadDll:StartGame()
<DownLoadAssets>d__11:MoveNext()
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
LoadMetadataForAOTAssembly:mscorlib.dll. ret:OK
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:Log(Object)
<LoadMetadataForAOTAssemblies>d__13:MoveNext()
System.Runtime.CompilerServices.AsyncTaskMethodBuilder:Start(TStateMachine&)
<StartGame>d__12:MoveNext()
System.Runtime.CompilerServices.AsyncVoidMethodBuilder:Start(TStateMachine&)
LoadDll:StartGame()
<DownLoadAssets>d__11:MoveNext()
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
LoadMetadataForAOTAssembly:System.dll. ret:OK
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:Log(Object)
<LoadMetadataForAOTAssemblies>d__13:MoveNext()
System.Runtime.CompilerServices.AsyncTaskMethodBuilder:Start(TStateMachine&)
<StartGame>d__12:MoveNext()
System.Runtime.CompilerServices.AsyncVoidMethodBuilder:Start(TStateMachine&)
LoadDll:StartGame()
<DownLoadAssets>d__11:MoveNext()
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
LoadMetadataForAOTAssembly:System.Core.dll. ret:OK
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:Log(Object)
<LoadMetadataForAOTAssemblies>d__13:MoveNext()
System.Runtime.CompilerServices.AsyncTaskMethodBuilder:Start(TStateMachine&)
<StartGame>d__12:MoveNext()
System.Runtime.CompilerServices.AsyncVoidMethodBuilder:Start(TStateMachine&)
LoadDll:StartGame()
<DownLoadAssets>d__11:MoveNext()
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
Loading ASsembly: Assembly-CSharp
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:Log(Object)
<StartGame>d__12:MoveNext()
System.Runtime.CompilerServices.AsyncVoidMethodBuilder:Start(TStateMachine&)
LoadDll:StartGame()
<DownLoadAssets>d__11:MoveNext()
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
AppLoader Loaded: True
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:Log(Object)
<StartGame>d__12:MoveNext()
System.Runtime.CompilerServices.AsyncVoidMethodBuilder:Start(TStateMachine&)
LoadDll:StartGame()
<DownLoadAssets>d__11:MoveNext()
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
Init Method Loaded: True
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:Log(Object)
<StartGame>d__12:MoveNext()
System.Runtime.CompilerServices.AsyncVoidMethodBuilder:Start(TStateMachine&)
LoadDll:StartGame()
<DownLoadAssets>d__11:MoveNext()
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
ExecutionEngineException: NotSupportNative2Managed
at AppLoader.Init () [0x00000] in <00000000000000000000000000000000>:0
at System.Runtime.CompilerServices.AsyncVoidMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0
at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <00000000000000000000000000000000>:0
at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <00000000000000000000000000000000>:0
at LoadDll.StartGame () [0x00000] in <00000000000000000000000000000000>:0
at System.Runtime.CompilerServices.AsyncVoidMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0
at LoadDll.StartGame () [0x00000] in <00000000000000000000000000000000>:0
at LoadDll+<DownLoadAssets>d__11.MoveNext () [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) [0x00000] in <00000000000000000000000000000000>:0
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <00000000000000000000000000000000>:0
at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <00000000000000000000000000000000>:0
at LoadDll.StartGame () [0x00000] in <00000000000000000000000000000000>:0
at System.Runtime.CompilerServices.AsyncVoidMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0
at LoadDll.StartGame () [0x00000] in <00000000000000000000000000000000>:0
at LoadDll+<DownLoadAssets>d__11.MoveNext () [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) [0x00000] in <00000000000000000000000000000000>:0 ```
from hybridclr.
We will test you codes. Don't worry.we will help you solve this problem.
from hybridclr.
we test a slightly modified version of you code in hybridclr_trial projects.
- run
HybridCLR/Generate/All
- run
HybridCLR/Build/Win64
It runs correctly, we don't find any error.
we have test the project many times. It should be ok. Could you try the latest hybridclr_trial project again?
public class HotUpdateMain : MonoBehaviour
{
public string text;
// Start is called before the first frame update
void Start()
{
}
public static async void Init()
{
await LoadGame();
}
static async Task LoadGame()
{
Debug.Log("Load Game Called");
//Load the Scenes
var sceneAb = await LoadDll.GetStreamingAssetBundle("prefabs");
string[] scenePaths = sceneAb.GetAllScenePaths();
foreach (var s in scenePaths)
Debug.Log($"Scene: {s}");
}
}
public class LoadDll : MonoBehaviour
{
// ... ignore other codes
public static async Task<AssetBundle> GetStreamingAssetBundle(string dllName)
{
return AssetBundle.LoadFromMemory(GetAssetData(dllName));
}
void StartGame()
{
LoadMetadataForAOTAssemblies();
#if !UNITY_EDITOR
var gameAss = System.Reflection.Assembly.Load(GetAssetData("Assembly-CSharp.dll"));
#else
var gameAss = AppDomain.CurrentDomain.GetAssemblies().First(assembly => assembly.GetName().Name == "Assembly-CSharp");
#endif
Type type = gameAss.GetType("HotUpdateMain");
MethodInfo method = type.GetMethod("Init");
method.Invoke(null, null);
}
}
from hybridclr.
Sorry, I didn't realize there was an update since I posted the issue. I started over, and I have it working! Thanks for your quick response!
from hybridclr.
I am able to reproduce the bug!
https://github.com/Clancey/hybridclr_trial/tree/async_bug
from hybridclr.
We test the project, but we can't reproduce the bug. please sure:
- install latest HybridCLR cpp codes by
HybridCLR/Installer..
. - run
HybridCLR/Generate/All
before build games. You can simply runHybridCLR/Build/Win64
which automately callsHybridCLR/Generate/All
before building.
from hybridclr.
Our english document site will be coming soon.
from hybridclr.
Related Issues (20)
- 执行了一次HybridCLR/Generate/All后,后续更新dll,是否可以只使用CompileDll HOT 2
- function signature mismatch HOT 4
- 打包报错error: expected expression: IL2CPP_POP_ACTIVE_EXCEPTION(); HOT 2
- 开启nullable选项报错的问题 HOT 2
- Unity 2020.3.48f1 + HybridCLR 4.0.14,在开启增量GC的情况下极大概率出现崩溃 HOT 1
- Unity 2023.1.X 中,UnityEditor.Il2Cpp 命名空间已经被移除
- WASPlayer 下引用Windows内容后报错显示aot找不到相关dll HOT 1
- 在 Mumu 12 模拟器上调用网络状态相关接口时发生崩溃 HOT 1
- Editor 2023.2: 找不到 UnityEditor.Il2cpp namespace HOT 1
- UNITY_EDITOR 模式使用Assembly.Load加载的Assembly,无法通过go.GetComponent<T>()获取热更资源上的脚本 HOT 1
- Span<T>在自定义结构体上报错NotSupportedException HOT 5
- Incremental GC下 多维数组触发GC崩溃 HOT 3
- 特定情况下调用特定属性的特定字段崩溃 HOT 4
- WebGL支持的Unity版本 HOT 3
- 主包(win_x64 build player)用PostProcessing时启动会崩溃 HOT 1
- win-x64 player 启动直接闪退 (Build时 HybirdClr 已关闭) HOT 1
- The type or namespace name 'HybridCLR' could not be found HOT 6
- iOS平台下使用HybridCLR在Unity中打包XCode项目时出现3159 duplicate symbols错误 HOT 4
- HybridCLRSettings的hotUpdateAssemblies,hotUpdateAssemblyDefinitions 被清空 HOT 2
- unaligned指令有做具体实现和测试吗 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hybridclr.