xcode에서 'iOS 장치'를 타겟팅하는 정적 라이브러리를 컴파일하고이를 모노 터치 응용 프로그램에 연결했습니다. 앱을 빌드하고 실행하면 즉시 오류가 발생합니다.정적 라이브러리 나누기 빌드
Mono.Debugger.Soft.VMDisconnectedException: Exception of type 'Mono.Debugger.Soft.VMDisconnectedException' was thrown. at Mono.Debugger.Soft.Connection.SendReceive (CommandSet command_set, Int32 command, Mono.Debugger.Soft.PacketWriter packet) [0x00000] in :0 at Mono.Debugger.Soft.Connection.VM_GetVersion () [0x00000] in :0 at Mono.Debugger.Soft.Connection.Connect() [0x00000] in :0 at Mono.Debugger.Soft.VirtualMachine.connect() [0x00000] in :0 at Mono.Debugger.Soft.VirtualMachineManager.ListenInternal (System.Net.Sockets.Socket dbg_sock, System.Net.Sockets.Socket con_sock) [0x00000] in :0
그리고 애플리케이션 출력이 없습니다. 라이브러리에 서명하거나 서명하지 않아도 상관 없습니다. 여러 버전을 시도하고 컴파일러 간 전환을 설정했습니다 (마지막 컴파일러는 GCC 4.2 컴파일러 사용). Whm
시뮬레이터 용 라이브러리를 빌드하고 장치에서 실행되도록 앱에 연결하면 장치에서 실제로 실행되지만 함수가 p/호출되자 마자 앱이 종료되고 시스템 출력이 설명됩니다 pinvoke는 해결할 수 없습니다.
이것은 시뮬레이터에서 실행되기 때문에 빌드 설정이나 어딘가에있을 수 있습니다. JIT 대 AOT 문제 일 수 있습니다. '
편집 :
[DllImport("__Internal")]
private static extern int CreateWorld(b2Vec2 grav, OnIOSContact startContact, ContactOver endContact);
delegate bool OnIOSContact(MyCollisionEvent ev);
delegate bool ContactOver(MyCollisionEvent ev);
[MonoTouch.MonoPInvokeCallback(typeof(OnIOSContact))]
static bool StatContactStart(MyCollisionEvent ev){...}
[MonoTouch.MonoPInvokeCallback(typeof(ContactOver))]
static bool StatContactEnd(MyCollisionEvent ev){...}
[StructLayout(LayoutKind.Sequential, Size=8),Serializable]
struct MyCollisionEvent
{
public IntPtr ActorA;
public IntPtr ActorB;
}
[StructLayout(LayoutKind.Sequential, Size=8),Serializable]
public struct b2Vec2
{
public b2Vec2(float _x, float _y)
{
x = _x;
y = _y;
}
public float x;
public float y;
}
과 뒤의 C 코드 :
extern "C"
int CreateWorld(b2Vec2 gravity, bool (*startContact)(Contact), bool (*endContact)(Contact))
//contact struct to match MyCollisionEvent in C# code
typedef struct
{
b2Body *bodyA;
b2Body *bodyB;
}Contact;
/// A 2D column vector.
struct b2Vec2
{
/// Default constructor does nothing (for performance).
b2Vec2() {}
/// Construct using coordinates.
b2Vec2(float32 x, float32 y) : x(x), y(y) {}
/// Set this vector to all zeros.
void SetZero() { x = 0.0f; y = 0.0f; }
/// Set this vector to some specified coordinates.
void Set(float32 x_, float32 y_) { x = x_; y = y_; }
/// Negate this vector.
b2Vec2 operator -() const { b2Vec2 v; v.Set(-x, -y); return v; }
/// Read from and indexed element.
float32 operator() (int32 i) const
{
return (&x)[i];
}
/// Write to an indexed element.
float32& operator() (int32 i)
{
return (&x)[i];
}
/// Add a vector to this vector.
void operator += (const b2Vec2& v)
{
x += v.x; y += v.y;
}
/// Subtract a vector from this vector.
void operator -= (const b2Vec2& v)
{
x -= v.x; y -= v.y;
}
/// Multiply this vector by a scalar.
void operator *= (float32 a)
{
x *= a; y *= a;
}
/// Get the length of this vector (the norm).
float32 Length() const
{
return b2Sqrt(x * x + y * y);
}
/// Get the length squared. For performance, use this instead of
/// b2Vec2::Length (if possible).
float32 LengthSquared() const
{
return x * x + y * y;
}
/// Convert this vector into a unit vector. Returns the length.
float32 Normalize()
{
float32 length = Length();
if (length < b2_epsilon)
{
return 0.0f;
}
float32 invLength = 1.0f/length;
x *= invLength;
y *= invLength;
return length;
}
/// Does this vector contain finite coordinates?
bool IsValid() const
{
return b2IsValid(x) && b2IsValid(y);
}
float32 x, y;
};
편집 2 :
내가 언급해야
이 사물의 C#을 측면입니다 이 게시물을 처음 썼을 때 앱을 몇 번 실행시킬 수있었습니다. 일반적으로 라이브러리를 서명하는 것과 같이 약간 다른 빌드 설정을 사용하여 프로젝트/라이브러리를 다시 작성하는 작업이 포함되었지만 이러한 성공적인 빌드를 만드는 데 필요한 단계를 식별 할 수 없었습니다 ...
매번 (관련없는 버그로 인해) 추락했지만 코드를 약간 수정 (예 : 줄을 주석 처리하는 경우)하여 다시 동일한 오류가 발생했습니다. 라인을 복구한다고해서 오류가 사라지는 것은 아닙니다.
게시를 편집하여 C# (속성 포함)과 C? 덕분에 – poupou
완료되었습니다. 그것이 호출 된 특정 함수입니다 (이것은 분홍색으로 채워지는 첫 번째 함수이기도합니다). 라이브러리가 시뮬레이터 용으로 빌드 된 경우에도 장치에서 작동해야하는지 확실하지 않습니다. – tweetypi
비 기본 유형의 관리/기본 정의도 포함하십시오 (예 : b2Vec2, 연락처, OnIOSContact 및 ContactOver. 임의의 충돌은 관리/네이티브 표현이 일치하지 않을 때 스택을 잘못 처리하여 발생했을 수 있습니다. – poupou