Skip to content
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

Can not compile typed context: Assembly 'Madd0.AzureStorageDriver' #20

Closed
Valtarr opened this issue Jan 26, 2020 · 13 comments
Closed

Can not compile typed context: Assembly 'Madd0.AzureStorageDriver' #20

Valtarr opened this issue Jan 26, 2020 · 13 comments

Comments

@Valtarr
Copy link

Valtarr commented Jan 26, 2020

When trying to connect to Azure TableStorage from LinqPad6 (using nuget driver) I recieve an error:
Error: Can not compile typed context: Assembly 'Madd0.AzureStorageDriver' with identity 'Madd0.AzureStorageDriver, Version 2.1.0.0, Culture=neutral, PublicKeyToken=null' uses 'System.Runtime, Version 4.2.2.0, Culture=neutral, ...
In LinqPad5 the same connection is working and I am able to connect using TableStorage driver.
Are there some prerequisites needed? LinqPad is working by itself. And able to connect to SQL.

I saw closed ticked, but the problem seems not solved... Driver version 2.1.0.0

@madd0
Copy link
Owner

madd0 commented Jan 27, 2020

I had good hope since nobody else had seen the error since the update...
Any chance you have more details after the ...? I'd like to see what version it's looking for.
Also, any information about your environment, especially what version(s) of the .net core runtimes or SDKs you have installed, might help.

@Valtarr
Copy link
Author

Valtarr commented Jan 27, 2020

Probably not so many TS users 🙃
But believe - when you need to analyze TS content - LinqPad with your driver is like a dream.
Better could be only if it would be able to modify entities and implemented full linq (like .Take(x))

Requested data:
dotnet --version => 3.1.101
LinqPad version: 6.5.5 (x64)
LinqPad "About" info:

.NET Core version (host): 3.1.1
.NET Core version (queries): 3.1.1
Roslyn Version: 3.3.1-beta4-19462-11
FSharp.Compiler.Service version: 32.0.0.0

Info from driver:

Cannot compile typed context: Assembly 'Madd0.AzureStorageDriver' with identity 'Madd0.AzureStorageDriver, Version=2.1.0.0, Culture=neutral, PublicKeyToken=null' uses 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' which has a higher version than referenced assembly 'System.Runtime' with identity 'System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' (line : (0,0)-(0,0))

Hm... Looks like you are using some Preview SDK (with newer System.Runtime) - as I am using the last stable and have lower version 🧐

@Valtarr
Copy link
Author

Valtarr commented Jan 27, 2020

I think using System.Runtime 4.2.1 could solve the issue 🤔

@madd0
Copy link
Owner

madd0 commented Jan 30, 2020

Thanks for the information. I'm running the exact same environment as you are.

.NET Core 3.1 uses System.Runtime 4.2.2. Since the driver itself targets 3.1 and that the generated code references the driver, it will need System.Runtime 4.2.2 in the end anyway.

I do not have reliable reproduction steps, but I did manage to encounter the exception when I opened LinqPad 6 today (I don't use 6 much because I only have a license for 5 and I can't live without autocomplete).

What the debugger is showing me is that, although the driver DLL that was loaded targets .NET Core 3.1, LinqPad is giving it 3.0 DLLs to compile the generated code, which results in the exception you are getting.

I've reached out to the author hoping he'll have an idea of what might be going wrong. I'll also try to investigate further during the course of the weekend.

@Valtarr
Copy link
Author

Valtarr commented Jan 30, 2020

Thanx for feedback. Hope LinqPad then will be fixed.
The best thing in 6th I think is #link functionality. You should not keep everything useful and reusable in one file 🙃

@madd0
Copy link
Owner

madd0 commented Feb 3, 2020

Quick update: After exchanging with Joe Albahari, I have a better understanding of what is going wrong. We have discussed of possible improvements in LinqPad to avoid the issue in the future, and I have an idea for a workaround in the meantime. I hope I'll be able to patch and test before the end of the week.

@Valtarr
Copy link
Author

Valtarr commented Feb 3, 2020

Great news! :)

madd0 added a commit that referenced this issue Feb 4, 2020
This is a workaround for issue #20, which appears to be the opposite of #19. In the latter, the driver was given .net core 3.1 references when it was trying to target 3.0. This time, the driver is given 3.0 references while trying to target 3.1.
It looks like LinqPad is downloading the 3.1 version of the driver, which tries to generate a dynamic assembly by targeting 3.1 too. This is necessary because the generated code references the driver assembly, which in this scenario targets 3.1. However, LinqPad is providing reference assemblies for .net core 3.0, which results in a compiler error.
I talked about the problem with Joe Albahari and hope that in the future the driver will be able to request version-specific reference assemblies from LinqPad. In the meanwhile, since the dynamic assembly should be 3.0-compatible if it doesn't reference the 3.1 driver itself, I have removed the reference and am now compiling the required classes with the rest of the code. This way, whether LinqPad provides 3.0 or 3.1 references, the generated code is totally agnostic and works with both.
@madd0
Copy link
Owner

madd0 commented Feb 4, 2020

Hopefully this'll do the trick: https://www.nuget.org/packages/Madd0.AzureStorageDriver/2.1.1

@Valtarr
Copy link
Author

Valtarr commented Feb 4, 2020

I updated and can confirm it works now.
Good work! Thanx.

@Valtarr
Copy link
Author

Valtarr commented Feb 4, 2020

Are you going to make .Take(N) and .Skip(N) LinQ methods work?
It would be good to take some data without enumerating full table.

@madd0
Copy link
Owner

madd0 commented Feb 4, 2020

I'll look into it. In the meanwhile, specifying AsQueryable does the trick. For example:

MyTable.AsQueryable().Take(10)

Calls:

https://xxxxx.table.core.windows.net/MyTable?$top=10

@madd0 madd0 closed this as completed Feb 4, 2020
@Valtarr
Copy link
Author

Valtarr commented Feb 4, 2020

Nice trick. Didn't know :)
However Skip is still not working.

@madd0
Copy link
Owner

madd0 commented Feb 4, 2020

Ah, right, that's because Skip is not supported by the SDK, afaik 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants