Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

When adding a nuget package / assembly with a different namespace it cannot be resolved #459

Closed
anegg0 opened this issue Jun 26, 2018 · 15 comments

Comments

@anegg0
Copy link

anegg0 commented Jun 26, 2018

The "Nethereum.Accounts" package includes the "Nethereum.Web3.Accounts" namespace. The reason for this to avoid a major change until the next version.

There is also a package "Nethereum.Web3" with the same namespace.
Adding an "using" declaration for "Nethereum.Web3.Accounts" results in an error as it cannot be resolved.

Steps to Reproduce

  1. Create a new workbook and add #r "Nethereum.Accounts" and a using Nethereum.Accounts; statements
  2. Try to resolve the statements

Expected Behavior

The namespace is found in its package / assembly.

Actual Behavior

"Using" statement resolution returns an Error: " (1,17): error CS0234: The type or namespace name 'Accounts' does not exist in the namespace 'Nethereum' (are you missing an assembly reference?) `

Environment

Windows 10, Xamarin Workbooks 1.4.1

Can't do that: the app crashes on Help → Copy Version Information

Xamarin Workbooks 2018-06-26.log

@sandyarmstrong
Copy link
Member

Hi @anegg0, thanks for filing.

I have created a very simple sample workbook that references the Nethereum.Accounts package and resolves the Nethereum.Web3.Accounts namespace without any issues: https://gist.github.com/sandyarmstrong/a5ce4d5241c58387658ded12e46b2d66.

It sounds like you added the Nethereum.Web3 package instead? I also found that when adding that package, I had to manually add a #r "Nethereum.Accounts" submission to get access to the Nethereum.Web3.Accounts namespace (see https://gist.github.com/sandyarmstrong/cb4628bc8a4bad274e59a281d0b47747). This is likely a bug in our NuGet implementation, but the workaround isn't too bad.

As for a Netherum.Accounts namespace, I looked at the DLL and there is no such namespace. If you add the same NuGet package to a project in Visual Studio, it doesn't seem like you'd have access to a Netherum.Accounts namespace either. Please let me know if there's something I'm missing, though.


Thanks for letting us know about the crash on Copy Version Information. I'm looking into a fix. Do you by any chance have some sort of clipboard utility program like TeraCopy installed?

@anegg0
Copy link
Author

anegg0 commented Jul 3, 2018

Thank you for your response @sandyarmstrong and apologies for the delay. I can install Teracopy of course. Just let me know what trace you need, glad to help.

@sandyarmstrong
Copy link
Member

@anegg0 Sorry, what I meant about TeraCopy was that if you had it installed (or a similar utility), it might be indirectly responsible for the crash when running Copy Version Information. We are working on a bug fix release that will hopefully prevent that crash.

@anegg0
Copy link
Author

anegg0 commented Jul 3, 2018 via email

@sandyarmstrong
Copy link
Member

You're running Windows in a VM? That could actually be related. Can you share what version of Linux, what virtualization software, etc? Thanks!

@anegg0
Copy link
Author

anegg0 commented Jul 3, 2018

host: Linux Mint 18.3 Sylvia
guest: Win 10 version 1709 on a virtualbox 5.1.34_Ubuntu r121010 :
Workbooks version: latest

@sandyarmstrong
Copy link
Member

Closing this issue as per #459 (comment).

If I am misunderstanding the issue, please let me know and we can reopen.

@anegg0
Copy link
Author

anegg0 commented Jul 6, 2018

I provided the elements you requested regarding my environment, are there any other elements you need?
Please note: we are currently changing our namespace, hopefully that'll help with our issue...

@sandyarmstrong
Copy link
Member

From what I understand, the main issue you were asking about was why you could not access the Nethereum.Accounts namespace. But it seems there is no Nethereum.Accounts namespace in the NuGet packages you mentioned.

So the bugs that came out of this report were:

@juanfranblanco
Copy link

Just extra feedback as I have tested this on my environment (s). Windows and Mac.

The main issue is combining two packages. Nethereum.Web3 and Nethereum.Accounts.

Nethereum.Accounts contains the namespace Nethereum.Web3.Accounts

In this scenario even if you force #r to include the package, it cannot be resolved.

Hence the thought that it was trying to be resolved by package name / DLL and ignoring the others.

Although it is interesting that it worked for you. Maybe having the two using statements or might have been the order of #r?

@sandyarmstrong
Copy link
Member

Can you provide a simple working C# console project that references the packages and has the behavior you want? That would make it easier for me to understand where Workbooks is falling short for you.

@sandyarmstrong sandyarmstrong reopened this Jul 6, 2018
@juanfranblanco
Copy link

Sure I'll post one tomorrow.

@juanfranblanco
Copy link

juanfranblanco commented Jul 7, 2018

Ok, I got it working on a new workbook following these steps. So yes it is probably now just #329
Note (Edit): The issue before was when upgrading the workbooks packages too, but this will do for the time being.

Step 1. Create a new workbook adding Nethereum.Web3 as a package.
Step 2. Add "using Nethereum.Web3;" (all ok now)
Step 3. Add "using Nethereum.Web3.Accounts;" (not happy)
Step 4. Add "#r Nethereum.Accounts"; (not happy, so nuget not resolved)
Step 5. Add Nethereum.Accounts as a package, automatically adds the #r
Step 6. Result not complaining about using..
Step 7. Further test creating an Account + Web3 all working.

image

@juanfranblanco
Copy link

Source:

uti: com.xamarin.workbook
id: d0e8c854-3cea-42cd-896d-68708b95610b
title: test
platforms:
- Console
packages:
- id: Nethereum.Web3
  version: 2.5.1
---

/```csharp
#r "Nethereum.Web3"
/```

/```csharp
#r "Nethereum.Accounts"
/```

/```csharp
using Nethereum.Web3;using Nethereum.Web3.Accounts;
/```

/```csharp
var account = new Account("0xb5b1870957d373ef0eeffecc6e4812c0fd08f554b37b233526acc331bf1544f7");
/```

@anegg0
Copy link
Author

anegg0 commented Dec 12, 2018

@sandyarmstrong thank you for your help. Although we could never clearly identify the cause of the issue, we found a workaround, so I guess this issue is fine to close.

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

No branches or pull requests

3 participants