Delphi字符串变量与C#String不同 [英] Delphi String Variable not same from C# String

查看:98
本文介绍了Delphi字符串变量与C#String不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Delphi程序是:

My Delphi Procedure is:

procedure seturunAdiGonder(_urunAdi: string); stdcall;
begin
  urunAdiGonder(Terazi, _urunAdi);
end;





和我的C#代码:



And my C# Code:

 [DllImport("UcgeBizerbaScale.dll",
                   CallingConvention = CallingConvention.StdCall,
                   CharSet = CharSet.Ansi)]
        public static extern void seturunAdiGonder(string ad);

string a = textBox1.Text;
            seturunAdiGonder(a);



当我使用c#代码时出现错误应用程序中出现未处理的异常。如果单击继续,应用程序将忽略这个错误和attemot继续。如果你单击退出,应用程序将立即关闭



尝试读取或写入受保护的内存。这通常表明其他内存是。



详细信息部分:

有关调用的详细信息,请参阅此消息的结尾

实时(JIT)调试而不是此对话框。



**************例外文字*** ***********

System.AccessViolationException:尝试读取或写入受保护的内存。这通常表示其他内存已损坏。

at WindowsFormsApplication1.Form1.seturunAdiGonder(String ad)

at WindowsFormsApplication1.Form1.button4_Click(Object sender,EventArgs e)

at System.Windows.Forms.Cont rol.OnClick(EventArgs e)

在System.Windows.Forms.Button.OnClick(EventArgs e)

在System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) )

在System.Windows.Forms.Control.WmMouseUp(Message& m,MouseButtons按钮,Int32点击)

在System.Windows.Forms.Control.WndProc(消息& m)

在System.Windows.Forms.ButtonBase.WndProc(消息& m)

在System.Windows.Forms.Button.WndProc(消息& m)

在System.Windows.Forms.Control.ControlNativeWindow.OnMessage(消息& m; m)

在System.Windows.Forms.Control.ControlNativeWindow.WndProc(消息& m)

在System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd,Int32) msg,IntPtr wparam,IntPtr lparam)





**************已装载的装配** ************

mscorlib

汇编版本:2.0.0.0

Win32版本:2.0.50727.3607( GDR.050727-3600)

CodeBase:file:/// c:/Windows/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll

--- -------------------------------------

WindowsFormsApplication1

汇编版本:1.0.0.0

Win32 Versi on:1.0.0.0

CodeBase:file:/// D:/Debug/WindowsFormsApplication1.exe

-------------- --------------------------

System.Windows.Forms

汇编版本: 2.0.0.0

Win32版本:2.0.50727.3053(netfxsp.050727-3000)

CodeBase:file:/// C:/ Windows / assembly / GAC_MSIL / System。 Windows.Forms / 2.0.0.0__b77a5c561934e089 / System.Windows.Forms.dll

-------------------------- --------------

系统

汇编版本:2.0.0.0

Win32版本:2.0。 50727.3614(GDR.050727-3600)

CodeBase:file:/// C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll

----------------------------------------

系统。绘图

汇编版本:2.0.0.0

Win32版本:2.0.50727.3053(netfxsp.050727-3000)

CodeBase:file:// /C:/Windows/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll

----------------------------------------



************** JIT调试**************

要启用实时(JIT)调试,此

应用程序或计算机(machine.config)的.config文件必须具有

jitDebugging值。 system.windows.forms部分。

应用程序也必须通过调试编译

启用。



For例如:



< configuration>

< system.windows.forms jitdebugging =true>





启用JIT调试后,任何未处理的异常

将被发送到计算机上注册的JIT调试器

而非由此对话框处理。。



有人可以帮助我吗?



谢谢


when i use c# code i got an error "Unhandled exception has occured in your application.If you click Continue,the application ignore this error and attemot to continue.If you click quit,the application will close immediately

Attempted to read or write protected memory.This is often an indication that other memory is currupt.".

Detail Part:"
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at WindowsFormsApplication1.Form1.seturunAdiGonder(String ad)
at WindowsFormsApplication1.Form1.button4_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3607 (GDR.050727-3600)
CodeBase: file:///c:/Windows/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
WindowsFormsApplication1
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///D:/Debug/WindowsFormsApplication1.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3614 (GDR.050727-3600)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.3053 (netfxsp.050727-3000)
CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
<system.windows.forms jitdebugging="true">


When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.".

can anybody help me?

Thanks

推荐答案

例如,请参阅:从c#调用dll中的Delphi方法 - Stack Overflow [ ^ ]。
See, for instance, this: "Calling a Delphi method in a dll from c# - Stack Overflow"[^].


这篇关于Delphi字符串变量与C#String不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆