c#鑳藉惁璋冪敤 鎵╁睍DLL锛圡FC锛夛紝濡備綍璋冪敤锛?
c#鑳藉惁璋冪敤 鎵╁睍DLL锛圡FC锛夛紝濡備綍璋冪敤锛?nbsp; --------------------编程问答-------------------- 褰撶劧鑳斤紝鍙埌缃戜笂鎼滄悳鈥淐# 璋冪敤DLL鈥? --------------------编程问答-------------------- MFC extension DLL can be used only with MFC applications.So I would say no.
But you can create a native dll that consumes the extension Dll but exposes itself as a regular DLL (like a proxy),
and from you C# program you can P/Invoke the proxy dll.
Hope this might help.
--------------------编程问答-------------------- mfc鐢熸垚鐨勪笢瑗胯矊浼奸渶瑕乵fcxxx.dll, yyy.dll鐨勬敮鎸?.. --------------------编程问答-------------------- 椹厠 --------------------编程问答-------------------- c#鑳藉惁璋冪敤 鎵╁睍DLL锛圡FC锛夛紝濡備綍璋冪敤锛? --------------------编程问答-------------------- MFC extension DLL can be used only with MFC applications.
So I would say no.
But you can create a native dll that consumes the extension Dll but exposes itself as a regular DLL (like a proxy),
and from you C# program you can P/Invoke the proxy dll.
--------------------编程问答-------------------- up --------------------编程问答-------------------- 杩欐槸璋冪敤鐨勪竴涓枃浠舵煡鎵剧殑dll鍑芥暟.MSDN閲岄潰灏辨湁
--------------------编程问答-------------------- 鎴戣鐨勬槸MFC鎵╁睍DLL --------------------编程问答-------------------- MFC鎵╁睍DLL浠呭彲浠ヨ鍏变韩MFC鐗堟湰鐢熸垚鐨凪FC鍙墽琛屾枃浠朵娇鐢? 鎵€浠ユ垜璁や负杩欑被dll鏄笉鑳藉湪C#涓娇鐢ㄧ殑銆?br /> --------------------编程问答-------------------- 鎶婂畠鐩存帴娣诲姞鍒板紩鐢ㄩ噷灏卞彲浠ヤ簡鐢ㄤ簡鍚? --------------------编程问答-------------------- 鍙互璋冪敤鐨?缁欎綘涓€涓畝鍗曠殑渚嬪瓙锛屾妸浣犵殑dll鏀惧湪浣犵▼搴忕殑debug鐩綍涓嬮潰灏卞彲浠?杩欎釜鏄帶鍒跺彴绋嬪簭锛屼綘鍐欐垚WINFORM涔熸槸鍙互鐨勶紒
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public class FindData
{
public int fileattributes = 0;
public int CreationTime_LowDateTime = 0;
public int CreationTime_HighDateTime = 0;
public int LastAccessTime_LowDateTime = 0;
public int lastAccessTime_HighDateTime = 0;
public int LastWriteTime_LowDateTime = 0;
public int LastWriteTime_HighDateTime = 0;
public int nFileSizeHigh = 0;
public int nFileSizeLow = 0;
public int dwreserved0 = 0;
public int dwreserved1 = 0;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
public String fileName = null;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 14)]
public string alternateFileName = null;
}
public class LibWrap
{
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr FindFirstFile(string filename, [In, Out]FindData findfiledate);
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
public static extern int CreateFileA(string filename);
[DllImport("file.dll")]
public static extern int MyFile_Create(string filename);
[DllImport("file.dll")]
public static extern int MyFile_Append(string filename, string text);
}
using System;
using System.Runtime.InteropServices;
class HelloWorld
{
[DllImport("TestLib1.dll")] //瀵煎叆浣犵殑DLL鐨勶紝鈥溾€濋噷闈㈡槸DLL鐨勫悕绉帮紒
public static extern void DisplayHelloFromDLL (); //DLL閲岄潰鐨勫嚱鏁?br />
static void Main ()
{
Console.WriteLine ("This is C# program");
DisplayHelloFromDLL ();
}
} --------------------编程问答-------------------- --------------------编程问答-------------------- c++ 鍐嶅皝瑁呬竴娆? --------------------编程问答-------------------- 鐢╩fc鍐欑殑dll璨屼技涓嶈兘璋冪敤鎶娿€?br />
鎴戞敮鎸佽繖涓鐐?br /> MFC extension DLL can be used only with MFC applications.
So I would say no.
But you can create a native dll that consumes the extension Dll but exposes itself as a regular DLL (like a proxy),
and from you C# program you can P/Invoke the proxy dll.
--------------------编程问答-------------------- c++ 鍐嶅皝瑁呬竴娆? --------------------编程问答-------------------- 鎴戜篃鏄敤C#璋冪敤MFC鎵╁睍dll銆?br />
鍦╠ll杈撳嚭鍑芥暟涓樉绀轰竴涓獥浣撱€?br />
鎻愮ず鍑洪敊锛宒ebug assert failed
File锛歛fxwin1.inl
line锛?2
--------------------编程问答-------------------- 闂瑙e喅浜嗘病鏈夛紝鎴戜篃纰板埌浜嗚繖涓棶棰橈紒 --------------------编程问答-------------------- 濡傛灉娌℃湁鐢ㄥ埌mfc鐨勭壒娈婃暟鎹被鍨嬶紝鏄彲浠ョ殑銆傚鏋滅敤鍒颁簡mfc鏈夌殑绫诲瀷锛堝睘浜巑fc鐙湁鐨?,灏遍渶瑕佸厛寤轰竴涓猇C++鐨勯」鐩紝灏嗘暟鎹被鍨嬭浆鎹竴涓嬨€傚彉鎴?net鍙敤鐨勶紒鎵嶅彲浠ャ€?