Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio 2012 带MonoTouch/Xamarin.iOS类型初始化异常/EntryPointNotFoundException的Swig_Visual Studio 2012_Xamarin.ios_Swig - Fatal编程技术网

Visual studio 2012 带MonoTouch/Xamarin.iOS类型初始化异常/EntryPointNotFoundException的Swig

Visual studio 2012 带MonoTouch/Xamarin.iOS类型初始化异常/EntryPointNotFoundException的Swig,visual-studio-2012,xamarin.ios,swig,Visual Studio 2012,Xamarin.ios,Swig,我尝试使用SWIG将非托管C++封装到XAMARI.IOS项目中。根据本教程,我已成功地将其打包到一个C#项目中: 当我尝试合并MonoTouch时,只要调用C++代码,就会总是出现运行时错误。 我知道在使用单触的SWIG时需要做一些小的调整,但我肯定错过了一些东西。我一直在关注Stephane的博客作为参考 我的C#/Monotouch项目之间的差异: 单触式 swig-csharp-c++-outdir myPath-dllimport\u Internalcpp\u file.i 然后

我尝试使用SWIG将非托管C++封装到XAMARI.IOS项目中。根据本教程,我已成功地将其打包到一个C#项目中:

当我尝试合并MonoTouch时,只要调用C++代码,就会总是出现运行时错误。

我知道在使用单触的SWIG时需要做一些小的调整,但我肯定错过了一些东西。我一直在关注Stephane的博客作为参考

我的C#/Monotouch项目之间的差异:

单触式
  • swig-csharp-c++-outdir myPath-dllimport\u Internalcpp\u file.i
  • 然后在我的cppinvoke.cs上运行ruby脚本(由James Moore创建)

    ARGF.each do |l|
       case l
       when /public delegate void Exception(Argument)?Delegate/
          puts "  [MonoTouch.MonoNativeFunctionWrapper]", l
       when /static void SetPendingArgument(Null|OutOfRange)?Exception/
          puts "  [MonoTouch.MonoPInvokeCallback (typeof (ExceptionArgumentDelegate))]", l
       when /static void SetPending.*Exception/
          puts "  [MonoTouch.MonoPInvokeCallback (typeof (ExceptionDelegate))]", l
       when /static string CreateString/
          puts "  [MonoTouch.MonoPInvokeCallback (typeof (SWIGStringDelegate))]", l
       else
          puts l
       end
    end
    
C#
  • swig-csharp-c++-outdir myPath cpp_file.i
以下是我尝试运行项目时遇到的例外情况:

未处理的异常:

System.TypeInitializationException:异常由 cppPINVOKE的类型初始值设定项

未处理的异常:System.TypeInitializationException:异常 由cppPINVOKE的类型初始值设定项引发---> System.TypeInitializationException:异常由 SwigeExceptionHelper的类型初始值设定项---> System.EntryPointNotFoundException:SwigregisterException回调\u cpp at(包装器管理为本机) cppPINVOKE/SwigeExceptionHelper:SWIGRegisterExceptionCallbacks\u cpp (cppPINVOKE/SwigeExceptionHelper/ExceptionLegate,cppPINVOKE/SwigeExceptionHelper/ExceptionLegate,cppPINVOKE/SwigeExceptionHelper/ExceptionLegate,cppPINVOKE/SwigeExceptionHelper/ExceptionLegate,cppPINVOKE/SwigeExceptionHelper/ExceptionLegate,CPPPPINFINVOKE/SwigeExceptionHelper/ExceptionLegate,CPPPPINVOKE/SwigeExceptionHelper/ExceptionLegate,cppPINVOKE/SwigeExceptionHelper/ExceptionLegate,cppPINVOKE/SwigeExceptionHelper/ExceptionLegate,cppPINVOKE/SwigeExceptionHelper/ExceptionLegate) 在cppPINVOKE+SwigeExceptionHelper..cctor()[0x000ef]中 c:\Users\joshs\Documents\Visual Studio 2012\Projects\stackoverflowswighwithxamarin\stackoverflowswighwithxamarin\Generated\cppinvoke2.cs:121 ---内部异常堆栈跟踪结束---在c:\Users\joshs\Documents\Visual Studio中的cppPINVOKE..cctor()[0x00000]处 2012\Projects\stackoverflowswighwithxamarin\stackoverflowswighwithxamarin\Generated\cppinvoke2.cs:141 ---内部异常堆栈跟踪结束---在c:\Users\joshs\Documents\Visual Studio中的cpp_文件..ctor()[0x00000]处 2012\Projects\stackoverflowswighwithxamarin\stackoverflowswighwithxamarin\Generated\cpp_file.cs:43 在StackOverflowWighwithXamarin.MyViewController.b_u0处 (System.Object发送方,System.EventArgs e)[0x00001]位于 c:\Users\joshs\Documents\Visual Studio 2012\Projects\stackoverflowswighwithxamarin\stackoverflowswighwithxamarin\MyViewController.cs:38 在中的MonoTouch.UIKit.UIControlEventProxy.Activated()[0x00000]处 /开发者/单点触摸/来源/单点触摸/src/UIKit/UIControl。cs:30 at (包装器管理为本机)MonoTouch.UIKit.ui应用程序: UIApplicationMain(int,string[],intptr,intptr)位于 MonoTouch.UIKit.UIApplication.Main(System.String[]参数, System.String principalClassName,System.String delegateClassName) [0x0004c]英寸 /开发者/MonoTouch/Source/MonoTouch/src/UIKit/UIApplication.cs:38
在StackOverflowWighwithxamarin.Application.Main(System.String[] c:\Users\joshs\Documents\Visual Studio中的args)[0x00001] 2012\Projects\stackoverflowswighwithxamarin\stackoverflowswighwithxamarin\Main.cs:17 2013-10-3114:45:48.261与Xamarin的StackOverflows[13645:21e03] 未处理的托管异常:类型引发了异常 位于的cppPINVOKE(System.TypeInitializationException)的初始值设定项 c:\Users\joshs\Documents\Visual Studio中的cpp_文件..ctor()[0x00000] 2012\Projects\stackoverflowswighwithxamarin\stackoverflowswighwithxamarin\Generated\cpp_file.cs:43 在StackOverflowWighwithXamarin.MyViewController.b_u0处 (System.Object发送方,System.EventArgs e)[0x00001]位于 c:\Users\joshs\Documents\Visual Studio 2012\Projects\stackoverflowswighwithxamarin\stackoverflowswighwithxamarin\MyViewController.cs:38 在中的MonoTouch.UIKit.UIControlEventProxy.Activated()[0x00000]处 /开发者/单点触摸/来源/单点触摸/src/UIKit/UIControl。cs:30 at (包装器管理为本机) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)位于MonoTouch.UIKit.UIApplication.Main (System.String[]参数,System.String principalClassName,System.String /Developer中的delegateClassName)[0x0004c]/ MonoTouch/Source/MonoTouch/src/UIKit/UIApplication.cs:38 at StackOverflowWithXamarin.Application.Main(System.String[]args) [0x00001]在c:\Users\joshs\Documents\Visual Studio中 2012\Projects\stackoverflowswighwithxamarin\stackoverflowswighwithxamarin\Main.cs:17 mono rt:Stacktrace:

那么,为什么我会遇到这个异常,如何修复它呢?
编辑(2013-11-1) 我的(更多/更少)完整设置:

VS2012 StackOverflowWighthXamarin.sln包含两个项目

  • cpp.vcxproj(C++项目)
  • StackOverflowWithXamarin.csproj(由VS创建的Xamarin iOS项目(即编号xibs))
    • Xamarin项目是在VS2012文件->新建->项目中创建的…->Visual C->iOS->iPad->HelloWorld应用程序
cpp项目 cpp_文件.h

#pragma once

#ifdef cpp_EXPORTS
#define cpp_API __declspec(dllexport)
#else
#define cpp_API __declspec(dllimport)
#endif

class cpp_API cpp_file
{
public:
    cpp_file(void);
    ~cpp_file(void);

    int times2(int arg);
};
cpp_file.cpp

#include "cpp_file.h"
cpp_file::cpp_file(void)
{
}
cpp_file::~cpp_file(void)
{
}
int cpp_file::times2(int arg)
{
    return arg * 2;
}
cpp_文件.i

%module cpp

%{
#include "cpp_file.h"
%}

%include <windows.i>
%include "cpp_file.h"
%cpp模块
%{
#包括“cpp_file.h”
%}
%包括
%包括“cpp_file.h”
在VS2012中,cpp_file.i文件被设置为自定义生成选项。它运行命令

swig-csharp-c++-outdir“$(SolutionDir)stackoverflowswighwithxamarin\Generated”cpp_file.i

%module cpp

%{
#include "cpp_file.h"
%}

%include <windows.i>
%include "cpp_file.h"
自定义生成工具的输出指定为:

cpp_文件_wrap.cxx

……但我从来没用过这个文件,我不知道它是干什么用的

构建我的