Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by DarkOverlord · Mar 31, 2015 at 10:01 AM · c#dllc++

Unity crushes while running dll functions(log+code)

http://rghost.ru/79NkzRx7p - here is log file

 using UnityEngine; 
 using System.Collections; 
 using System; 
 using System.Runtime.InteropServices; 
 public class Grapher2 : MonoBehaviour {      
     [DllImport ("1" )]      
     private static extern void Create_polygon( int aa,int log_, int N_x, int N_y, double N_t);     
     [DllImport ("1" )]      
     private static extern void Get_partition ();     
     [DllImport ("1" )]
   private static extern double Get_length();
   [DllImport ("1" )]
   private static extern double Get_height ();
  [DllImport ("1" )]
   private static extern int Get_x ();
  [DllImport ("1" )]
   private static extern int Get_y ();
  [DllImport ("1" )]
   private unsafe static extern void Solve(double time_start,int NT,double * Temp);
  [DllImport ("1" )]
   private static extern double Get_Temp_By_ij( int i,  int j);
  [DllImport ("1" )]
   private static extern double Get_Temp_By_xy( double x,  double y);

//some more code here//

     void Update () { 
     if (currentResolutionx != resolutionx ||currentResolutiony != resolutiony || points == null) { 
         CreatePoints(); 
     } 

     if (Input.GetButton("Fire1")) {
         Vector2 mouse =  Camera.main.ScreenToWorldPoint(Input.mousePosition);
         if(mouse.x<=Graph.x+1 && mouse.x>=Graph.x && mouse.y>=Graph.y && mouse.y<=Graph.y+1) {
             scannedpoint = mouse;
             Point.transform.position = scannedpoint;
             Graph2.GetComponent<Grapher1>().scannedpoint = scannedpoint;
             SPP.GetComponent<SPP>().x = ((scannedpoint.x)*xk).ToString();
             SPP.GetComponent<SPP>().y = ((scannedpoint.y)*yk).ToString();
                 }
             }
     if (ExperiementOn) { 
         unsafe {
             fixed(double* qwe = &(TT[0])){
                 Debug.Log("Fu 3");
                     time_start += SMALL_TIME_STEP * Time_steps;
                     Solve (time_start,Time_steps,qwe);
                     Debug.Log("DD 4"); 
                     Debug.Log("DD 5");
                     CLOCK.GetComponent<Timer> ().delta = SMALL_TIME_STEP * Time_steps;
                     for (int i = 0; i < points.Length; i++) { 
                         float Temp = (float)((double)(*(qwe+i*8)));
                         if (Temp > 0) points [i].color = RGBfromTemp (Temp);  
                         points [i].color = new Color(1f,1f,0f);
                         points [i].size = size;
                                                         }    
                                         }
                 }
                     particleSystem.SetParticles (points, points.Length); 
             }
 }

I use unity3d in order to make a visualization for a computer experiement, which is written in C++. So i wrapped it into dll file and tried it. Some functions worked fine, some did not. The probable issue might be the following: i allocate memory for an array of doubles in c# code, then pass the pointer to c++ dll function and then try to read from it. Can't see anything wrong with it, but if i erase the part of the code responsible for that, it does not crash.

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image DarkOverlord · Mar 31, 2015 at 10:23 AM 0
Share

Report says my dll caused access violation, can't give more info

avatar image DarkOverlord · Mar 31, 2015 at 12:04 PM 0
Share

Solved. I was not careful when accessing memory in c# code.

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

Shared memory between c# and c++ 1 Answer

Importing C++/CLI DLL causes errors 0 Answers

Multiple Cars not working 1 Answer

How to assign a function to UnityEvent without the use of lambdas? 1 Answer

Distribute terrain in zones 3 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges