0

I am using Unity 2017.2.1f1 running Experimental .NET 4.6 equivalent scripting runtime version with .NET 4.6 compatibility level.

However when i install te latest version of Stripe.net (which requires .NET 4.0) using nuget packet manager i get the error Error CS0246 The type or namespace name 'Stripe' could not be found (are you missing a using directive or an assembly reference?) when trying to use the stripe namespace.

I am fairly sure this is being caused by Monodevelop somehow interfering as i am able to use the Stripe namespace when I create a clean .net project and get the very same package with nuget.

Is there a different way to install the Stripe.net library that would allow me to use the namespace?

using Stripe; // not found (in a Unity project)
public class StripeAuthenticate 
{
   void InitStripe()
   {
       StripeConfiguration.SetApiKey("stripe_key");
   }
}

I tried removing the Monobehaviour inheritence but that did not do anything either.

I have tried following the steps here but since i was already using nuget from the start that didn't do anything for me.

edit: I am aware of UniStripe but this hasn't been updated in years, coupled with the negative reviews I do not feel comfortable using this

Remy
  • 4,843
  • 5
  • 30
  • 60

1 Answers1

1

Apparantly the issue lies with Nuget rather than with Monobehaviour.

As Unity pulls all its resources starting from the /Assets/ folder it does not find any libraries installed through the nuget package manager which defaults its download location to what seems to be $(Solutiondir)/packages/<packageName> which is above unity's asset folder.

I got around this issue using the following steps:

  • Install Stripe using nuget
  • Navigate to SolutionDir/packages
  • Copy Stripe and newtonsoft /lib/ folder to a temporary location
  • Uninstal the packages using nuget
  • Move the /lib/ folder into a directory inside /assets/

without uninstalling the packages using nuget first i was getting a ton of error messages saying stripe was already defined.

Remy
  • 4,843
  • 5
  • 30
  • 60
  • In my case this doesn't work, if I do that, the follow message appears: PrecompiledAssemblyException: Multiple precompiled assemblies with the same name Stripe.net.dll included or the current platform. Only one assembly with the same name is allowed per platform. – Lotan Jul 19 '20 at 01:01
  • @Lotan Somewhere in your project is another dll that shares the same name, make sure you delete the other version from your project before importing a new version – Remy Jul 19 '20 at 15:09
  • I did that, the only way was to remove all Stripe and Newtonsoft dll's except net45 directory :( – Lotan Jul 19 '20 at 15:18