【问题标题】:Stripe integration in UnityUnity 中的条带集成
【发布时间】:2019-01-09 02:40:48
【问题描述】:

我正在使用 Unity 2017.2.1f1 运行具有 .NET 4.6 兼容性级别的 Experimental .NET 4.6 等效脚本运行时版本。

但是,当我使用 nuget 数据包管理器安装最新版本的 Stripe.net(需要 .NET 4.0)时,我在尝试使用条带命名空间时收到错误 Error CS0246 The type or namespace name 'Stripe' could not be found (are you missing a using directive or an assembly reference?)

我相当确定这是由 Monodevelop 以某种方式干扰造成的,因为当我创建一个干净的 .net 项目并获得与 nuget 完全相同的包时,我能够使用 Stripe 命名空间。

是否有其他方法可以安装允许我使用命名空间的 Stripe.net 库?

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

我尝试删除 Monobehaviour 继承,但这也没有做任何事情。

我已经尝试按照here 的步骤进行操作,但由于我从一开始就已经在使用 nuget,这对我没有任何帮助。

编辑:我知道UniStripe,但这已经很多年没有更新了,再加上负面评论,我觉得使用它并不舒服

【问题讨论】:

    标签: c# unity3d stripe-payments


    【解决方案1】:

    显然问题在于 Nuget 而不是 Monobehaviour。

    由于 Unity 从 /Assets/ 文件夹开始提取其所有资源,它没有找到通过 nuget 包管理器安装的任何库,该包管理器默认其下载位置似乎是 $(Solutiondir)/packages/<packageName>,它位于 unity 的资产文件夹上方。

    我通过以下步骤解决了这个问题:

    • 使用 nuget 安装 Stripe
    • 导航到 SolutionDir/packages
    • 复制 Stripe 和 newtonsoft /lib/ 文件夹到一个临时位置
    • 卸载使用 nuget 的包
    • 将 /lib/ 文件夹移动到 /assets/ 内的目录中

    在没有首先使用 nuget 卸载软件包的情况下,我收到大量错误消息,说已经定义了条带。

    【讨论】:

    • 在我的情况下这不起作用,如果我这样做,会出现以下消息: PrecompiledAssemblyException: Multiple precompiled assembly with the same name Stripe.net.dll include or the current platform.每个平台只允许一个同名程序集。
    • @Lotan 项目中的某个地方有另一个同名的 dll,请确保在导入新版本之前从项目中删除另一个版本
    • 我这样做了,唯一的方法是删除除 net45 目录之外的所有 Stripe 和 Newtonsoft dll :(
    猜你喜欢
    • 2014-01-21
    • 2020-11-16
    • 1970-01-01
    • 2018-02-16
    • 1970-01-01
    • 2020-11-18
    • 1970-01-01
    • 2018-05-08
    • 1970-01-01
    相关资源
    最近更新 更多