473,395 Members | 1,629 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

C# calling Delphi 2010 DLL won;t run

I have a dll library for which the call in .net is as follows.
Expand|Select|Wrap|Line Numbers
  1. Declare Function CopyDesign Lib "OS50.DLL" _
  2. (ByVal I_RPath As String, ByVal I_Flags As Integer, ByVal I_Typ As String, _
  3. ByVal I_CC As Integer, ByVal I_Ref As String, ByVal I_Q As Double, _
  4. ByVal I_T0 As Double, ByVal I_TC As Double, ByVal I_TS As Double, _
  5. ByVal I_TL As Double, ByVal I_TM As Long, ByVal I_TLC As Double, _
  6. ByVal I_TOC As Integer, ByVal I_TOL As Double, ByVal I_TN As Double, _
  7. ByVal I_OP As Integer, ByVal I_SP As Single, ByVal I_CR As Single, _
  8. ByVal O_T1 As String, ByRef O_SzT1 As Integer, _
  9. ByVal O_T2 As String, ByRef O_SzT2 As Integer, _
  10. ByRef DesignData As TDesignData, _
  11. ByRef O_Hint1 As Integer, ByRef O_Hint2 As Integer, _
  12. ByVal O_Err As String, ByRef O_SzErr As Integer) As Integer
  13.  
  14. I have written the following call, but it won't work. 
  15. public struct TDesignData
  16.     {
  17.         public int O_OP1;
  18.         public int O_OP2;
  19.         public double O_Q1;
  20.         public double O_Q2;
  21.         public double O_QU1;
  22.         public double O_QU2;
  23.         public double O_QN1;
  24.         public double O_QN2;
  25.         public double O_QC1;
  26.         public double O_QC2;
  27.         public double O_QH1;
  28.         public double O_QH2;
  29.         public double O_P1;
  30.         public double O_P2;
  31.         public double O_E1;
  32.         public double O_E2;
  33.         public double O_EN1;
  34.         public double O_EN2;
  35.         public double O_VG1;
  36.         public double O_VG2;
  37.         public float O_MT1;
  38.         public float O_MT2;
  39.         public double O_M1;
  40.         public double O_M2;
  41.         public double O_ME1;
  42.         public double O_ME2;
  43.         public double O_QS1;
  44.         public double O_QS2;
  45.         public double O_TE1;
  46.         public double O_TE2;
  47.         public double O_PE1;
  48.         public double O_PE2;
  49.         public double O_TL1;
  50.         public double O_TL2;
  51.         public double O_TH1;
  52.         public double O_TH2;
  53.         public double O_QA1;
  54.         public double O_QA2;
  55.         public double O_VOL1;
  56.         public double O_VOL2;
  57.         public double O_TOL1;
  58.         public double O_TOL2;
  59.         public double O_TJ1;
  60.         public double O_TJ2;
  61.         public double O_PJ1;
  62.         public double O_PJ2;
  63.     }
  64.  
  65.   [DllImport("OS50.DLL", 
  66.                    CallingConvention = CallingConvention.StdCall)]
  67.  
  68.  
  69.     public static extern int CopyDesign(
  70.                          string I_RPath, 
  71.                          int I_Flags,
  72.                          string I_Typ,
  73.                          int I_CC,
  74.                            string I_Ref,
  75.                            double I_Q,
  76.                            double I_T0,
  77.                              double I_TC,
  78.                        double I_TS,
  79.                       double I_TL,
  80.                       long I_TM,
  81.                        double I_TLC,
  82.                        int I_TOC,
  83.                        double I_TOL,
  84.                        double I_TN,
  85.                        int I_OP,
  86.                      float I_SP,
  87.                        float I_CR,
  88.                       string O_T1, 
  89.                    int O_SzT1,
  90.                      string O_T2, 
  91.                      int O_SzT2, 
  92.                 TDesignData DesignData, 
  93.                     int O_Hint1, 
  94.                     int O_Hint2,
  95.                   string O_Err,
  96.                    int O_SzErr);
  97.  
  98.  
  99.  
  100.         public void Run()
  101.         {
  102.  
  103.  
  104.                         I_RPath = RefFiles;
  105.  
  106.                         I_Flags = (CalcWithIPUnits + BIM_Mode);
  107.                         I_Flags = (I_Flags + CalcWithSuperheat);
  108.                         I_Flags = (I_Flags + CalcWithSubcooling);
  109.                         I_CC = 0;
  110.                         I_Ref = "R717";
  111.                         I_TS = 1.8;
  112.                         I_TL = 0;
  113.                         I_TM = 0;
  114.                         I_TLC = 0;
  115.                         I_TOC = 0;
  116.                         I_TOL = 175;
  117.                         I_TN = 0;
  118.                         I_OP = 1;
  119.                         I_SP = 3500;
  120.                         I_CR = 100;
  121.                         I_Typ="OSNA5351";
  122.                         I_T0=-30;
  123.                         I_TC=75;
  124.  
  125.                         errorMsgNum = CopyDesign(I_RPath, 
  126.                                                  I_Flags, 
  127.                                                  I_Typ, 
  128.                                                  I_CC, 
  129.                                                  I_Ref, 
  130.                                                  I_Q, 
  131.                                                  I_T0, 
  132.                                                  I_TC, 
  133.                                                  I_TS, 
  134.                                                  I_TL, 
  135.                                                  I_TM, 
  136.                                                  I_TLC, 
  137.                                                  I_TOC, 
  138.                                                  I_TOL, 
  139.                                                  I_TN, 
  140.                                                  I_OP, 
  141.                                                  I_SP, 
  142.                                                  I_CR, 
  143.                                                  O_T1, 
  144.                                                   O_SzT1, 
  145.                                                  O_T2, 
  146.                                                  O_SzT2, 
  147.                                                DesignData, 
  148.                                                O_Hint1, 
  149.                                                  O_Hint2, 
  150.                                                  O_Err, 
  151.                                                   O_SzErr);
  152.  
  153.             Console.WriteLine(DesignData.O_Q1);
  154.             Console.WriteLine(DesignData.O_M1);
  155.             Console.WriteLine(DesignData.O_P1);
  156.             Console.WriteLine(DesignData.O_VOL1);
  157.             Console.WriteLine(DesignData.O_TOL1);
It gives me Access Violation Exception. Attended to read or write protected memory. I am new to C# and have been trying to resolve this in the last couple days. Any help will be appreciated.
Jan 22 '15 #1
0 1163

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Donald L. Dietmeyer | last post by:
I was given a libxx.so that was probably written in Delphi. I need to wrap it so that I can call the functions/procedures of the library from Python. I tried the usual extension technique...
15
by: windozbloz | last post by:
Bye Bye Billy Bob... I'm back with one more question, then I'll chill. I have scoured the news and net for info about Borlands KYLIX 3 and have found little technical info about it. Their...
1
by: ARTMIC | last post by:
Hello, could someone please help me out, i'm trying to call a Delphi 6.0 custom DLL from inside of a C# windows project. what am i doing wrong? i use the following declaration: public class...
2
by: Prabhat | last post by:
Hello ALL, I have ASP pages that calls some ISAPI dll that created using Delphi for generating reports. The report page opens fine for 1st time when invoked but next time i get error like "Name...
7
by: Bart Roozendaal | last post by:
I am using a C# assembly in Delphi.Win32 using the com interop services. This works fine, but I am looking for a way to debug the C# assembly. When using a Delphi program as a host for the...
2
by: jewalsh2k | last post by:
Hi, I have a delphi dll which I am trying to call from C# but something isn't working, I get an SEHException thrown by the dll but I don't get enough info to debug it. I can't change the dll...
7
by: Ryanivanka | last post by:
hi, I am using a delphi DLL in vc++,static linked with ".h"and "lib". the export functions in DLL are "__stdcall",but the function doesn't work well,it often returns some weird values. when I add...
5
by: kelvin.koogan | last post by:
How can I call a function in a Delphi DLL from C++/CLI? The Delphi function is declared as follows: function Func1(IsDsb: Boolean; FirstStr, SecondStr : String): String; I've tried ...
0
by: Peted | last post by:
Hi i realise this is an esoteric subject, but im hoping someone can help me im working with a legacy application that was originaly developed in delphi 7, and inaddition to this the...
0
by: BornTOCode | last post by:
Hello, I am attempting to call a (Delphi) win32 DLL from a Delphi.Net webservice. I am using a slightly modified version of the hello world webservice that comes with Delphi 2006. The DLL...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.