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

Install failed on Windows Universal #120

Closed
quartsystem opened this issue Aug 15, 2015 · 13 comments
Closed

Install failed on Windows Universal #120

quartsystem opened this issue Aug 15, 2015 · 13 comments

Comments

@quartsystem
Copy link

NuGet no longer able to install the package on a Windows Universal project with VS2015

@NicolasDorier
Copy link
Collaborator

was it able before ? I can't compile on windows universal so I don't know. What error do you have ? (sorry for the delay)

@NicolasDorier
Copy link
Collaborator

Can you also try the "NBitcoin For Mono" package ?

@quartsystem
Copy link
Author

NuGet / Visual Studio 2015 is now able to perform the update to new release(2.1.4.7). All very strange.
The error message was "Unable to find metadata of NBitcoin xxxx".
Thanks anyway for the answer.

@NicolasDorier
Copy link
Collaborator

By the way, I am interested to know if it the lib works fine on Univeral Project, since I did not tried. Let me know.
I don't think you have access to the Node class (to connect to network) on Universal project, can you confirm ?

If it is a problem for you, you can try NBitcoin For Mono package which include everything and should also works fine on Universal.

@quartsystem
Copy link
Author

I'm developing a client for Windows 10 in my spare time.
I'll keep you updated on the tests that will.

@quartsystem
Copy link
Author

On universal Windows (app for Windows 10) NBitcoin.Mono fails installation with NuGet.
With NBitcoin, when launching the following code is generated an exception:

var k = new NBitcoin.Key();

System.InvalidOperationException: You must set the RNG (RandomUtils.Random) before generating random numbers
at NBitcoin.RandomUtils.GetBytes(Byte[] output)
at NBitcoin.Key..ctor(Boolean fCompressedIn)
at NBitcoin.Key..ctor()
at TestInstallNBitcoin.MainPage..ctor()
at TestInstallNBitcoin.TestInstallNBitcoin_XamlTypeInfo.XamlTypeInfoProvider.Activate_0_MainPage()
at TestInstallNBitcoin.TestInstallNBitcoin_XamlTypeInfo.XamlUserType.ActivateInstance()
at Windows.UI.Xaml.Controls.Fra

@quartsystem
Copy link
Author

On Windows 10, PRNG uses the CryptographicBuffer. I solved this code:

public class CryptographicBufferRandom : IRandom
{
    #region IRandom Members
    public void GetBytes(byte[] output)
    {
        // https://msdn.microsoft.com/en-us/library/windows.security.cryptography.cryptographicbuffer.aspx
        IBuffer buffer = CryptographicBuffer.GenerateRandom((uint)output.Length);
        buffer.CopyTo(output);
    }
    #endregion
}

To generate the key
NBitcoin.RandomUtils.Random = new CryptographicBufferRandom();
var newKey = new NBitcoin.Key();

@NicolasDorier
Copy link
Collaborator

thanks, will be useful when I'll make a specific version for universal

@GoldNRoll
Copy link

GoldNRoll commented Aug 1, 2017

Hello,

Any chance this will be solved for Windows 10?

NBitcoin.4.0.0.13

Any code fails with this error:
System.InvalidOperationException: You must set the RNG (RandomUtils.Random) before generating random numbers

using System;
using NBitcoin;

namespace Blockchain
{
class Program
{
static void Main(string[] args)
{
Key privateKey = new Key();
Console.WriteLine("Private Key: {0}", privateKey);
PubKey publicKey = privateKey.PubKey;
Console.WriteLine("Public Key: {0}", publicKey);
}
}
}

Thanks, Alexandru

@NicolasDorier
Copy link
Collaborator

@GoldNRoll set RandomUtils.Random to an instance of CryptographicBufferRandom made by @quartsystem just above.

Windows Universal will soon support .NETStandard 2.0, so it will soon be not needed.

Actually I think this is supported, in fall creator update https://blogs.windows.com/buildingapps/2017/05/19/introducing-xaml-standard-net-standard-2-0/

@GoldNRoll
Copy link

Perfect, thanks!!

@NicolasDorier
Copy link
Collaborator

NicolasDorier commented Aug 7, 2017

@GoldNRoll sorry I incorrectly diagnotised your problem, turns out you were not using UWP so my response does not apply.

I fixed the problem, now you can reference NBitcoin without the issue.

Someone reported it ProgrammingBlockchain/ProgrammingBlockchain#73

The issue was that I dropped net452 support for I don't know what reason, but some version of Visual Studio still use this old .net version for new project template. I added back the support, so now you won't get error.

@GoldNRoll
Copy link

GoldNRoll commented Aug 7, 2017

Hi Nicolas,

Perfect, I updated NBitcoin to 4.0.0.15 and now it works in console application :)
Visual Studio 2017 fresh install still comes with framework 4.5.2

Thank you!!

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

4 participants
@NicolasDorier @quartsystem @GoldNRoll and others