x


C++ dll plugin problem.

I just made C++ dll. when i read the dll in Unity, Unity crash down. Folloing is the steps.

tool: vs2008

step 1) vs2008 => new => Project ==> Visual C++ ==> CLR ==> Class Library projectname is clrtest.

step 2) clrtest.h

#pragma once 
#using <mscorlib.dll> 

using namespace System; 

namespace clrtest { 

    public ref class Class1 
    { 
        public: 
        int Add(int a, int b) { return a + b; }; 
    }; 
} 

step 3) compile ==> copy clrtest.dll into unity plugin folder.

step 4) in unity c# script

using UnityEngine; 
using System; 
using System.Collections; 
using System.Collections.Generic; 
using System.Runtime.InteropServices; 

using clrtest; 

public class mycowcontrol : MonoBehaviour {  

    void Start() 
    { 
        clrtest.Class1 temp = new clrtest.Class1(); 
        int x = temp.Add(1, 2); 
        Debug.Log("1+2 = " + x); 
    } 

} 

step 5) execute and just down.

I don't know why the unity is down. is any problem my c++ dll making procedure?

please let me know if you have any idea. Any help would be much appreciated.

more ▼

asked Apr 22 '10 at 11:38 AM

smithlim gravatar image

smithlim
1 2 2 3

Please surround all your code using the "Code" button, or using the

 tags, to make it easier for other people to read.
Apr 23 '10 at 02:42 AM qJake
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first
more ▼

answered Jul 18 '10 at 09:56 PM

SteveFSP gravatar image

SteveFSP
1k 8 13 29

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x396
x234

asked: Apr 22 '10 at 11:38 AM

Seen: 2881 times

Last Updated: Jul 18 '10 at 10:07 PM