-
Notifications
You must be signed in to change notification settings - Fork 151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
InvalidCastException while generating proxies #660
Comments
Hi @AArnott! Just kindly asking whether you had a chance to look into the issue? Regards :) |
An interesting problem. I would certainly like JsonRpc proxies to work in the case of multiple ALCs. I don't think we have any tests to cover that scenario so I'm not too surprised if we have a bug in that area. |
@vmykytiuk it's a runtime bug. |
@snikeguo, thanks for sharing. But it's not the same problem, since we don't use |
Hey @AArnott,
Thank you for your great efforts on this, really appreciate it!
I'm using vs-streamjsonrpc in my plugin framework scenario and looks like I found the bug.
When I try to use Attach method it throws the following exception:
Unable to cast object of type '_proxy_PluginRpcContract.IGreeter_5143f248-4875-4810-b2d9-c9f6b0f4efeb' to type 'PluginRpcContract.IGreeter'.
It works fine for the first invocation, but all next invocations fail with that exception. I guess the problem is related to the multiple assemblies loaded in different Assembly Load Context. Each plugin (with its own dependencies) "lives" in a separate Assembly Load Context. The assembly where the contract (PluginRpcContract.IGreeter) for the proxy is defined also "lives" in the same ALC as the plugin itself, so there are multiple assemblies (PluginRpcContract) with the same name loaded in different ALCs.
I suppose the problem is related to ProxyGeneration.GetProxyModuleBuilder method, because when I commented out some code and return new ModuleBuilder for each interfaceType - it works and does not throw exception above.
Attaching the archive that reproduces the issue: StreamJsonRpcTest.zip
Could you please take a look? Maybe I am doing something wrong?
Thanks,
Vasyl
The text was updated successfully, but these errors were encountered: